ntp時間同步

m61管理機  服務端配置

查看是否安裝看ntp

rpm -qa ntp

若沒有  yum -y install ntp

配置ntp服務

 vim /etc/ntp.conf

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

9 restrict default nomodify #<==允許所有IP段

19 #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

20 restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap #<==允許指定的IP段

#允許所有的和允許指定的選擇其一就可。

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章