问题
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