如何将机器ID/主机名映射/解映射到对象ID中的3个字节? [英] How machine id/host name is mapped/demapped to 3 byte in object id?

查看:93
本文介绍了如何将机器ID/主机名映射/解映射到对象ID中的3个字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将计算机ID/主机名映射/解映射到对象ID中的3个字节?

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

在Linux上我应该在哪里寻找机器ID?

And where should i look for machine id in linux?

domU-12-31-39-13-02-56看起来很奇怪,我不确定它是否正确?

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

?>

推荐答案

该函数不是从ObjectID获取主机名,而是向您显示PHP用于生成唯一ID的主机名:

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

ObjectID 3字节机器字段是机器主机名,mac/网络地址或虚拟机ID的(md5)哈希值的前三个字节.因此,即使您愿意,也无法将其撤消.

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.

然后您得到的值就是主机名(根据gethostname函数)-尽管它看起来很奇怪,但可能是正确的. domU通常代表虚拟化环境中的来宾操作系统,其余的可能是您的主机操作系统(dom0)或唯一标识您特定虚拟机的VM软件自动生成的ID.

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

这篇关于如何将机器ID/主机名映射/解映射到对象ID中的3个字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆