ntp时间同步

m61管理机  服务端配置vim

查看是否安装看ntpcentos

rpm -qa ntp服务器

若没有  yum -y install ntpsocket

配置ntp服务ide

 vim /etc/ntp.conf测试

8 #restrict default kod nomodify notrap nopeer noquery #<==第八行注释掉,在第八行下加上一行。ui

9 restrict default nomodify #<==容许全部IP段spa

19 #restrict 192.168.1.0 mask 255.255.255.0 nomodify notraprest

20 restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap #<==容许指定的IP段server

#容许全部的和容许指定的选择其一就可。

24 #server 0.centos.pool.ntp.org iburst #<==将默认时间同步源注释掉,改用可用源

25 #server 1.centos.pool.ntp.org iburst

26 #server 2.centos.pool.ntp.org iburst

27 #server 3.centos.pool.ntp.org iburst

28 server ntp1.aliyun.com

29 server time.nist.gov

启动ntp服务器

若是计划任务有时间同步,先注释,两种用法会冲突

[root@ntp ~]# crontab -e

#time sync by lidao at 2016-09-08

#*/5 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1

[root@ntp ~]# /etc/init.d/ntpd start

[root@m01-61 ~]# ntpdate 10.0.0.61

15 Feb 09:31:03 ntpdate[15370]: the NTP socket is in use, exiting

 crontab -e

#time sync by lidao at 2016-09-08

#*/5 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1

*/5 * * * * /usr/sbin/ntpdate 10.0.0.12 >/dev/null 2>&1



############# ntp客户端的时间同步###########

客户机要等几分钟再与新启动的ntp服务器进行时间同步,不然会提示no server suitable for synchronization found错误。

crontab -e

#time sync by Mr.sun at 2016-09-08

#*/5 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1

*/5 * * * * /usr/sbin/ntpdate 10.0.0.12 >/dev/null 2>&1

测试是否成功

ntpdate 10.0.0.61

相关文章
相关标签/搜索