您的位置:首页 > 运维架构 > Linux

NTP服务器配置(centos)

2011-01-10 11:31 302 查看
NTP服务器配置

1,检查是否安装
[root@zxclinux ~]# rpm -q ntp
ntp-4.2.2p1-7.el5
2.编辑配置文件/etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
[align=left]限制其他计算机查询。修改[/align]
restrict 127.0.0.1
开放本机内部接口,用于反馈
restrict 192.168.1.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.启动服务(最好关掉iptable,使用udp123端口)
Service ntpd start
chkconfig --levels 3 ntpd on
chconfig --list ntpd
ntpd 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关
设置开机启动。
4.测试
修改网络时间date MMDDhhmmYYYY.ss
ntpq –p检查NTP服务器同步状态
[root@zxclinux ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
61.129.66.79 216.218.192.202 2 u 21 64 3 36.800 75527.0 25.918
www.chinaepg.ne 158.43.128.66 3 u 20 64 3 57.995 75497.6 46.614
211.166.12.46 218.75.4.130 3 u 17 64 3 52.094 75534.2 56.985
LOCAL(0) .LOCL. 10 l 17 64 3 0.000 0.000 0.008
检查本地NTP服务器是否通过NTP校验
ntptrace 158.43.128.66
ntp1.pipex.net: stratum 2, offset -0.000026, synch distance 0.020605
ntp0.nl.uu.net: stratum 1, offset 0.000001, synch distance 0.000410, refid 'PPS'
如果stratum小于16.那么正常

vi /etc/ntp/step-tickers
加入一行

pool.ntp.org

这样每次ntpd启动时,会自动连接该国际标准时间服务器;

几个命令

#/usr/sbin/ntpdate -u 210.72.145.44 校对时间

#/usr/sbin/ntpdate -q 210.72.145.44 查询不更新

#hwclock --systohc 将机器硬件时钟同步为系统时钟
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息