linux系统间如何时间同步?
Linux可以通过停止ntp服务来关闭时间同步。
①关闭ntp服务(暂时设置重启后自动开启)servicentpdstop②设置永久关闭ntp服务(重启后也会关闭)chkconfigntpdoff
在各种Linux系统的服务器上设置时间同步的方法
空闲主机rm-rf/etc/localtimeln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime#修改时区为东八区。
date-R#查看时区设置。
接下来调整系统时间,同步时间服务器Debian系统安装NTP时间校正包:代码如下:apt-getinstallntpdate#InstallntpCentOS系统安装NTP时间校正包:代码如下:yum-yinstallntpdatentp#安装ntpUbuntu系统安装校正包NTP时间:代码如下:sudoapt-getinstall-yntpdantp修改/etc/ntp.confvi/etc/ntp.conf即可看下面的内容:代码如下:server0.centos.ntp.orgservertime.windows.comservertime.nist.gov这是默认的ntp同步服务器你可以自己更改全局ntp服务器地址:http://www.pool.ntp.org/我改成:代码如下:servercn.pool.ntp.org//这是中国ntp服务器servertime-a.nist.govservertime.windows.comservertime.nist.gov然后保存即可出口(vi退出方法参见:http://www.dabu.info/personal-summary-personally-i-careously-collected-must-be-familiar-with-vim-shortcut-key-operation.html)然后输入以下命令:代码如下:ntpdate-dcn.pool.ntp.org#调试查看时间差ntpdatecn.pool.ntp.org#同步时间date-R#检查时间是否同步。
bootstart启动ntp服务,定期同步时间chkconfig--levels235ntpdon#启动ntp同步/etc/init.d/ntpdstartXENVPS建议安装ntp服务,可以解决vps重启后时间不准确的问题。
有时,根据鸡的硬件时钟,它总是死七八分钟。
无路可走。
对于大多数网络服务,比如GoogleAuthenticator等,如果时间不同步,就无法进行身份验证,网站自然也无法登录。
代码如下:rm-rf/etc/localtimeln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime#将时区更改为东八区。
date-R#查看时区设置。
接下来调整系统时间,同步时间服务器Debian系统安装NTP时间校正包:代码如下:apt-getinstallntpdate#InstallntpCentOS系统安装NTP时间校正包:代码如下:yum-yinstallntpdatentp#安装ntpUbuntu系统安装校正包NTP时间:代码如下:sudoapt-getinstall-yntpdantp修改/etc/ntp.confvi/etc/ntp.conf即可看下面的内容内容:代码如下:server0.centos.ntp.orgservertime.windows.comservertime.nist.gov这是默认的ntp同步服务器你可以自己更改全局ntp服务器地址:http://www.ntp.orgpool.ntp.org/我改成:代码如下:servercn.pool.ntp.org//这个中文NTP服务器是servertime-a.nist.govservertime.windows.comservertime.nist.gov然后保存并退出(vi退出方法参见:http://www.dabu.info/personal-summary-personally-i-careously-collected-must-be-familiar-with-vim-shortcut-key-operation.html)然后输入以下命令:代码如下:ntpdate-dcn.pool.ntp.org#调试看时间差ntpdatecn.pool.ntp.org#同步时间date-R#检查时间是否同步#配置开机启动ntp服务,定时同步时间chkconfig--levels235ntpdon#启动ntp同步/etc/init.d/ntpdstart#首先设置VPSXEN使用系统独立时间模式echo1/proc/sys/xen/independent_wallclock然后尝试上面的独立主机配置方法。
正确配置时间后,编辑系统配置文件,使配置永久生效。
代码如下:vi/etc/sysctl.confxen.independent_wallclock=1#在文件中添加并保存OpenVZVPS(使用通过BurstVPSOpenVZVPS直接从物理机读取时间,不允许主机时间修改)。
您只需修改时区即可。
我还没有使用过openvzvps,所以不知道是否可以使用ntp服务,你可以尝试安装ntpservice。
如果可以的话请告诉我。
代码如下:rm-rf/etc/localtimeln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime#将时区更改为东八区。
date-R#检查时区和时间目前,如果时区和时间正确,则配置成功;如果时间不正确,则需要联系托管服务商的技术支持,要求他们进行同步。
鸡(物理机)时间,你的VPS时间就正常了。