好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

linux上配置NTP日期时间同步

linux中时间日期我们一般是默认的但有时会发现不正常,有时我们在一些应用中会碰到对时间同步的要求严格,这时我们就可以考虑到使用NTP同步了,下面我就来给各位介绍NTP日期时间同步教程,希望文章对各位会带来帮助.

在linux 上配置NTP 时间同步,具休操作步骤,整理如下:

1.安装软件包,在服务端和客户端,代码如下:

yum install ntp  

2.服务器端配置,例如,首先,服务端设定IP地址为:192.168.146.110,修改ntp配置文件,代码如下:

  • vim /etc/ntp.conf  
  • server 0.redhat.pool.ntp.org //设定上级服务器   
  • restrict 192.168.146.0 mask 255.255.255.0 nomodify //设定哪些client机器可以和ntp server进行同步  
  •  
  • //启动NTP服务前,手动校正一次时间   
  • ntpdate 0.redhat.pool.ntp.org  
  • service ntpd restart  
  • chkconfig ntpd on 
  • //phpfensi.com  
  • //查看ntp服务状态   
  • netstat -ln | grep 123  
  • ntpstat 

    3.客户端配置,代码如下:

    ntpdate 192.168.146.110 //与NTP server 同步时间  

    或者定期同步,代码如下:

  • crontab  -e  
  • */5 * * * * /usr/sbin/ntpdate  -u 192.168.146.110     //每五分钟同步一次   
  •    重启crond服务/etc/init.d/crond restart  
  • ntpq -p //查看同步状态
  •  

    查看更多关于linux上配置NTP日期时间同步的详细内容...

  •   阅读:69次