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