服务器端:

1、ntp一般操作系统自带

[root@m01 ~]# rpm -qa ntp
ntp-4.2.6p5-10.el6.centos.x86_64
如果米有:yum -y install ntp
2、
[root@m01 ~]# vim /etc/ntp.conf 
  8 #restrict default kod nomodify notrap nopeer noquery
  9 #restrict -6 default kod nomodify notrap nopeer noquery
 10 restrict default nomodify
 22 #server 0.centos.pool.ntp.org iburst
 23 #server 1.centos.pool.ntp.org iburst
 24 #server 2.centos.pool.ntp.org iburst
 25 #server 3.centos.pool.ntp.org iburst
 26 server ntp1.aliyun.com
 27 server time.nist.gov


3、注释定时任务中的时间同步:

[root@m01 ~]# crontab -e
#time sync by hz at 2016-8-17
#*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1

4、启动NTP服务:

[root@m01 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+time5.aliyun.co 10.137.38.86     2 u  128   64    2   28.206   -4.263   0.002
*nist1-lnk.binar .ACTS.           1 u   63   64    3  262.883  -14.135   6.661
[root@m01 ~]# ntpstat
synchronised to NTP server (216.229.0.179) at stratum 2 
   time correct to within 4085 ms
   polling server every 64 s
[root@m01 ~]# /etc/init.d/ntpd start
正在启动 ntpd:                                            [确定]

5、客户端时间同步:

[root@oldboy ~]# date
2016年 10月 20日 星期四 19:23:07 CST
[root@oldboy ~]# ntpdate 10.0.0.61
20 Oct 19:28:15 ntpdate[11300]: step time server 10.0.0.61 offset 281.623836 sec
[root@oldboy ~]# date
2016年 10月 20日 星期四 19:28:19 CST

6、加入到定时任务:

[root@oldboy ~]# crontab -e
#update time
*/5 * * * * /usr/sbin/ntpdate 10.0.0.61 >/dev/null 2>&1