我有一个专门的networking服务器,运行centos Xen虚拟化,并在虚拟机上安装了centos。 我没有访问父服务器,我只能操纵我完全控制的虚拟机。 我没有任何东西,但操纵虚拟机上的date/时间的问题。 现在的主要问题是在我的服务器上运行的时间比“正常”运行速度快一点。 我估计,每24小时它会超前一分钟。 这是不好的,因为我有脚本需要在特定的时间运行,他们正在运行几分钟。 到目前为止,我发现的唯一“修复”是重启服务器,但是我不想每天晚上都重新启动以修复时间!
这是我所尝试的:
1)手动设置时间:
root@host [~]# date Mon May 13 06:52:22 WAKT 2013 root@host [~]# date 051306492013 Mon May 13 06:49:00 WAKT 2013 root@host [~]# date Mon May 13 06:52:54 WAKT 2013
date和时间在set命令之后反映在屏幕上,但是当我在一秒钟之后运行date命令时,它返回到date“实际”。 如果我重新启动服务器,时间将被正确重置,但我正在尝试避免此重新启动。
2)我正在阅读关于设置可能帮助我的硬件时钟,但我无法做出任何改变或做任何事情,我相信这是因为我在一个VM:
root@host [~]# /sbin/hwclock --show Cannot access the Hardware Clock via any known method. Use the --debug option to see the details of our search for an access method. root@host [~]# hwclock --systohc Cannot access the Hardware Clock via any known method. Use the --debug option to see the details of our search for an access method.
3)我启用了ntp,我相信这是工作,但像手动设置时间,时间变化不“粘”,直到重新启动后:
root@host [~]# date Mon May 13 06:55:36 WAKT 2013 root@host [~]# service ntpd stop Shutting down ntpd: [ OK ] root@host [~]# ntpdate pool.ntp.org 13 May 06:55:52 ntpdate[7146]: step time server 192.95.20.208 offset -229.150633 sec root@host [~]# service ntpd start Starting ntpd: [ OK ] root@host [~]# date Mon May 13 06:56:10 WAKT 2013
另外请注意,我现在正在使用一些奇怪的时区,因为我试图解决另一个问题,我正在重置时区: https : //serverfault.com/questions/494635/timezone-changing-by-itself-on -virtualized-centos-install,所以不要太在意时区。 无论我在哪个时区,我都需要时间来纠正。
有没有人处理过这个? 我拒绝相信没有办法在没有重启的情况下在我的Linux机器上设置时间。 任何想法或build议是最受欢迎的!
如果你正在运行一个半虚拟化的xen虚拟机,你可以检查;
的/ proc / SYS / xen /目录将independent_wallclock
如果它存在且包含0,请尝试(以root身份):
echo 1 > /proc/sys/xen/independant_wallclock
然后启动你的ntp服务器。