NTP服務器配置

一、常用的NTP服務器IP

210.72.145.44 (國家授時中心服務器IP地址)
202.112.10.36 # 1.cn.pool.ntp.org
59.124.196.83 # 0.asia.pool.ntp.org
s2m.time.edu.cn 北京大學
s2c.time.edu.cn 北京郵電大學

二、搭建NTP服務器
NTP服務端配置步驟如下
1、安裝ntp
yum -y install ntp
2、開機啓動
chkconfig ntpd on
chkconfig --list ntpd
3、先手工同步下時間
ntpdate -u 210.112.145.44
4、配置ntpd主配置文件ntp.conf
vim /etc/ntp.conf 增加如下內容

 # 允許內網其他機器同步時間
 restrict 192.168.239.0 mask 255.255.255.0 nomodify notrap

 # 中國這邊最活躍的時間服務器 : http://www.pool.ntp.org/zone/cn
 server 210.72.145.44 perfer   # 中國國家受時中心
 server 202.112.10.36             # 1.cn.pool.ntp.org
 server 59.124.196.83             # 0.asia.pool.ntp.org

 # allow update time by the upper server 
 # 允許上層時間服務器主動修改本機時間
 restrict 210.72.145.44 nomodify notrap noquery
 restrict 202.112.10.36 nomodify notrap noquery
 restrict 59.124.196.83 nomodify notrap noquery

 # 外部時間服務器不可用時,以本地時間作爲時間服務
 server  127.127.1.0     # local clock
 fudge   127.127.1.0 stratum 10

5、開啓ntp服務,並查看商品
/etc/init.d/ntpd start
netstat -atunlp | grep ntp
6、查看時間同步狀態 ntpstat (表示本地時間服務器已經和外網的NTP服務同步上了)
[root@localhost ~]# ntpstat
synchronised to NTP server (202.112.10.36) at stratum 6
time correct to within 1171 ms
polling server every 64 s

三、NTP客戶端配置步驟
只需要建立一條計劃任務就OK
crontab -e 加入如下兩條內容。 (每分鐘同步一次)

#client ntp sync to ntp server 192.168.239.133

          • /usr/sbin/ntpdate -u 192.168.239.133 >/dev/null 2>&1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章