时间:2023-06-02 16:16:41 来源: 人气:
独立主机, rm -rf /etc/localtime, ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。, date -R #查看的时区设置。, 接下来调整系统时间与时间服务器同步, Debian系统安装NTP校时包:, 代码如下:, apt-get install ntpdate #安装ntp, CentOS系统安装NTP校时包:, 代码如下:, yum -y install ntpdate ntp #安装ntp, Ubuntu系统安装NTP校时包:, 代码如下:, sudo apt-get install -y ntpdate ntp, 修改/etc/ntp.conf, vi /etc/ntp.conf 就会看到以下内容:, 代码如下:, server 0.centos.ntp.org,server time.windows.com,server time.nist.gov, 这是默认的ntp同步服务器,大家可以自己改,全球ntp服务器地址:http://www.pool.ntp.org/, 我改成了:, 代码如下:, server cn.pool.ntp.org //这中国的ntp服务器, server time-a.nist.gov, server time.windows.com, server time.nist.gov, 然 后保存退出(vi退出的方法见:http://www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html), 接着输入下面的命令:, 代码如下:, ntpdate -d cn.pool.ntp.org #调试查看时间差异,ntpdate cn.pool.ntp.org #同步时间,date -R # 检查时间是否同步, 修改 ntp 的配置文件, 代码如下:, vi /etc/sysconfig/ntpd,SYNC_HWCLOCK=yes #同步独立主机的硬件时钟, ,#配置开机启动ntp服务,定期同步时间,chkconfig --levels 235 ntpd on #启动ntp同步,/etc/init.d/ntpd start, XEN VPS, 最好是安装ntp服务,这样可以解决vps在重启后时间不准的问题。有时候,依靠母鸡的硬件时钟,总是差七八分钟。实在没辙了。而已很多的web服务,如Google Authenticator等,如果时间不同步,会导致无法验证的地步,自然就网站都登陆不上了。, 代码如下:, rm -rf /etc/localtime,ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。,date -R #查看的时区设置。, 接下来调整系统时间与时间服务器同步, Debian系统安装NTP校时包:, 代码如下:, apt-get install ntpdate #安装ntp, CentOS系统安装NTP校时包:, 代码如下:, yum -y install ntpdate ntp #安装ntp, Ubuntu系统安装NTP校时包:, 代码如下:, sudo apt-get install -y ntpdate ntp, 修改/etc/ntp.conf, vi /etc/ntp.conf 就会看到以下内容:, 代码如下:, server 0.centos.ntp.org,server time.windows.com,server time.nist.gov, 这是默认的ntp同步服务器,大家可以自己改,全球ntp服务器地址:http://www.pool.ntp.org/, 我改成了:, 代码如下:, server cn.pool.ntp.org //这中国的ntp服务器, server time-a.nist.gov, server time.windows.com, server time.nist.gov, 然 后保存退出(vi退出的方法见:http://www.dabu.info/personal-summary-personally-i- carefully-collected-must-be-familiar-with-vim-shortcut-key-operation.html), 接着输入下面的命令:, 代码如下:, ntpdate -d cn.pool.ntp.org #调试查看时间差异,ntpdate cn.pool.ntp.org #同步时间,date -R # 检查时间是否同步, ,#配置开机启动ntp服务,定期同步时间,chkconfig --levels 235 ntpd on #启动ntp同步,/etc/init.d/ntpd start, ,#先设置XEN 的VPS使用和系统无关的时间模式,echo 1 > /proc/sys/xen/independent_wallclock, 然后尝试上面独立主机的配置方法即可。通过配置时间正确后,编辑系统配置文件,让配置永久生效。, 代码如下:, vi /etc/sysctl.conf,xen.independent_wallclock=1 #在文件中增加并且保存, OpenVZ VPS, (Burst VPS 采用), OpenVZ的VPS直接从物理机读取时间不允许对主机进行时间修改,你只需修改时区。我还没用过openvz vps,所以,不清楚能否用ntp服务不,可以试试安装ntp service 看。如果可以的话,请告诉我。, 代码如下:, rm -rf /etc/localtime,ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #修改时区到东8区。,date -R #查看时间和时区, 此时如果时间和时区都正确,配置成功,时间如果不对,需要联系主机服务商的技术支持,让他们把母鸡(物理机)时间同步,你的VPS时间就会正常。,