l ntp server 配置
如果能连接外网,在http://support.ntp.org/bin/view/Servers/StratumTwoTimeServers查找二级ntp服务器地址,如果不能连接外网,把下面配置里的restrict 和server 对应的6行(出现ip地址为59.66.66.243, 218.75.4.130, 202.112.31.197)给注释掉。
vi /etc/ntp.conf
#添加下面四行,前三行表示可以同步的时间服务器,
#最后一行表示局域网可以同步的网段,根据自己的网络适当调整
restrict 59.66.66.243 mask 255.255.255.255 nomodify notrap noquery
restrict 218.75.4.130 mask 255.255.255.255 nomodify notrap noquery
restrict 202.112.31.197 mask 255.255.255.255 nomodify notrap noquery
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
#注释下面三行
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#添加下面3个ntp服务器
server 59.66.66.243
server 218.75.4.130
server 202.112.31.197
#添加延迟处理
broadcastdelay 0.008
至此/etc/ntp.conf配置完毕
#设置ntp修改时间同时写入硬件时钟
vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
#设置开机自动启动ntp服务
chkconfig ntpd on
#手工同步一遍系统时间和写入硬件时间
ntpdate 192.168.100.67
hwclock -w
#启动ntp服务,开始同步
service ntpd start
l ntp client 配置
vi /etc/ntp.conf
#添加下面2行
restrict 192.168.100.67 #192.168.100.67 为ntp server的地址
server 192.168.100.67
#设置同步统时间同时把系统时间写到硬件时钟里
vi /etc/sysconfig/ntpd
set SYNC_HWCLOCK=yes
#手工同步一遍系统时间和写入硬件时间
ntpdate 192.168.100.67
hwclock -w
#设置开机自动启动ntp服务
chkconfig ntpd on
#启动ntp服务,开始时间同步
service ntpd start
最后观察同步状态
ntpq -p
在输出的remote列上有*号,且对应的是ntp.conf 里配置的地址就表示同步好了
ntpstat
ntp q -p 的解释参考http://www.cnblogs.com/cqubityj/archive/2011/12/06/2278238.html
本文参考了另外2个网站的配置
http://www.brennan.id.au/index.html
http://vbird.dic.ksu.edu.tw/linux_server/0440ntp.php
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25027760/viewspace-755857/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25027760/viewspace-755857/