How machine id/host name is mapped/demapped to 3 byte in object id?

巧了我就是萌 提交于 2019-12-13 13:14:17

问题


How machine id/host name is mapped/demapped to 3 byte in object id?

And where should i look for machine id in linux?

domU-12-31-39-13-02-56 looks very strange and i am not sure it's correct or not?

<?php

$id = new MongoId('4f7351390c211d0a3d000004');

print_r($id->getHostname());

//domU-12-31-39-13-02-56

?>

回答1:


That function is not getting your hostname from the ObjectID, it shows you what hostname PHP is using to generate the unique IDs:

http://php.net/manual/en/mongoid.gethostname.php

The ObjectID 3 byte machine field is the first three bytes of the (md5) hash of the machine host name, or of the mac/network address, or the virtual machine id. So, it can't be reversed back even if you wanted to.

The value you are getting is then the hostname (according to the gethostname function) - and though it looks odd, is probably correct. domU usually represents a guest OS in a virtualized environment, the rest is probably an auto-generated ID by your host OS (the dom0) or VM software that uniquely identifies your particular VM



来源:https://stackoverflow.com/questions/9924701/how-machine-id-host-name-is-mapped-demapped-to-3-byte-in-object-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!