RHEL6 NTP服务器的配置及故障排除
2012-04-16 21:33
375 查看
环境:RHEL6.0
一、配置NTP服务器
1、安装NTP软件包
[root@client ~]# yum install ntp -y
2、NTP服务的配置
[root@server ~]# grep -v "^#" /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
server 192.168.0.254
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
[root@server ~]# cat /etc/ntp/step-tickers (当NTP服务启动时,会自动与该文件中的记录的上层NTP服务进行时间校对)
# List of servers used for initial synchronization.
192.168.0.254
[root@server ~]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
SYNC_HWCLOCK=yes
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
3、启动ntp服务
[root@server ~]# chkconfig ntpd on
[root@server ~]# service ntpd start
Starting ntpd: [ OK ]
4、ntp测试
[root@server ~]# ntpstat
synchronised to local net at stratum 11
time correct to within 950 ms
polling server every 64 s
[root@server ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
server .INIT. 16 u - 64 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 10 l 50 64 177 0.000 0.000 0.000
客户端同步时间:
1、windows
2、linux
[root@client ~]# date
Wed Apr 11 10:43:30 CST 2012
二、配置客户机的时间同步
1、手工执行 ntpdate <ntp server>来同步
2、crontab -e
0 23 * * * ntpdate 192.168.0.210 >> /var/log/ntpdate.log 2>&1
每天晚上11点进行时间同步
三、troubshooting
当用ntpdate -d 来查询时会发现导致 no server suitable for synchronization found 的错误的信息有以下2个:
错误1.Server dropped: Strata too high
在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。
在ntp客户端用ntpdate -d serverIP查看,发现有“Server dropped: strata too high”的错误,并且显示“stratum 16”。而正常情况下stratum这个值得范围是“0~15”。
这是因为NTP server还没有和其自身或者它的server同步上。
以下的定义是让NTP Server和其自身保持同步,如果在/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端。
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。
那么如何知道何时ntp server完成了和自身同步的过程呢?
在ntp server 上使用命令:
[root@client ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.0.210 LOCAL(0) 11 u 10 64 37 0.411 0.034 0.087
*LOCAL(0) .LOCL. 5 l 27 64 37 0.000 0.000 0.000
注意LOCAL的这个就是与自身同步的ntp server。
注意reach这个值,在启动ntp server服务后,这个值就从0开始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒*5=320秒的时间。
如果之后从ntp客户端同步ntp server还失败的话,用ntpdate –d来查询详细错误信息,再做判断。
错误2.Server dropped: no data
从客户端执行netdate –d时有错误信息如下:
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
192.168.0.210: Server dropped: no data
server 192.168.0.210, port 123
.....
11 Apr 11:03:49 ntpdate[2191]: no server suitable for synchronization found
出现这个问题的原因可能有2:
1。检查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定义中使用了notrust的话,会导致以上错误。
使用以下命令检查ntp的版本:
# ntpq -c version
下面是来自ntp官方网站的说明:
The behavior of notrust changed between versions 4.1 and 4.2.
In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
In 4.2 (and later) notrust means "Ignore all NTP packets that are not cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd
解决:
把notrust去掉。
2。检查ntp server的防火墙。可能是server的防火墙屏蔽了upd 123端口。
可以用命令
#service iptables stop
来关掉iptables服务后再尝试从ntp客户端的同步,如果成功,证明是防火墙的问题,需要更改iptables的设置。
本文出自 “梦想年华 @楚国小生” 博客,谢绝转载!
一、配置NTP服务器
1、安装NTP软件包
[root@client ~]# yum install ntp -y
2、NTP服务的配置
[root@server ~]# grep -v "^#" /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
server 192.168.0.254
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
[root@server ~]# cat /etc/ntp/step-tickers (当NTP服务启动时,会自动与该文件中的记录的上层NTP服务进行时间校对)
# List of servers used for initial synchronization.
192.168.0.254
[root@server ~]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
SYNC_HWCLOCK=yes
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
3、启动ntp服务
[root@server ~]# chkconfig ntpd on
[root@server ~]# service ntpd start
Starting ntpd: [ OK ]
4、ntp测试
[root@server ~]# ntpstat
synchronised to local net at stratum 11
time correct to within 950 ms
polling server every 64 s
[root@server ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
server .INIT. 16 u - 64 0 0.000 0.000 0.000
*LOCAL(0) .LOCL. 10 l 50 64 177 0.000 0.000 0.000
客户端同步时间:
1、windows
2、linux
[root@client ~]# date
Wed Apr 11 10:43:30 CST 2012
二、配置客户机的时间同步
1、手工执行 ntpdate <ntp server>来同步
2、crontab -e
0 23 * * * ntpdate 192.168.0.210 >> /var/log/ntpdate.log 2>&1
每天晚上11点进行时间同步
三、troubshooting
当用ntpdate -d 来查询时会发现导致 no server suitable for synchronization found 的错误的信息有以下2个:
错误1.Server dropped: Strata too high
在ntp客户端运行ntpdate serverIP,出现no server suitable for synchronization found的错误。
在ntp客户端用ntpdate -d serverIP查看,发现有“Server dropped: strata too high”的错误,并且显示“stratum 16”。而正常情况下stratum这个值得范围是“0~15”。
这是因为NTP server还没有和其自身或者它的server同步上。
以下的定义是让NTP Server和其自身保持同步,如果在/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端。
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。
那么如何知道何时ntp server完成了和自身同步的过程呢?
在ntp server 上使用命令:
[root@client ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.0.210 LOCAL(0) 11 u 10 64 37 0.411 0.034 0.087
*LOCAL(0) .LOCL. 5 l 27 64 37 0.000 0.000 0.000
注意LOCAL的这个就是与自身同步的ntp server。
注意reach这个值,在启动ntp server服务后,这个值就从0开始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒*5=320秒的时间。
如果之后从ntp客户端同步ntp server还失败的话,用ntpdate –d来查询详细错误信息,再做判断。
错误2.Server dropped: no data
从客户端执行netdate –d时有错误信息如下:
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
transmit(192.168.0.210)
192.168.0.210: Server dropped: no data
server 192.168.0.210, port 123
.....
11 Apr 11:03:49 ntpdate[2191]: no server suitable for synchronization found
出现这个问题的原因可能有2:
1。检查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定义中使用了notrust的话,会导致以上错误。
使用以下命令检查ntp的版本:
# ntpq -c version
下面是来自ntp官方网站的说明:
The behavior of notrust changed between versions 4.1 and 4.2.
In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
In 4.2 (and later) notrust means "Ignore all NTP packets that are not cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd
解决:
把notrust去掉。
2。检查ntp server的防火墙。可能是server的防火墙屏蔽了upd 123端口。
可以用命令
#service iptables stop
来关掉iptables服务后再尝试从ntp客户端的同步,如果成功,证明是防火墙的问题,需要更改iptables的设置。
本文出自 “梦想年华 @楚国小生” 博客,谢绝转载!
相关文章推荐
- VTP中VLAN配置信息不同步故障排除
- RHEL服务器故障排除精粹
- 对排除VLAN中Trunk配置故障一文的补充
- CentOS 6.3_ RSync实现文件备份同步配置排除故障
- 1周第2课 Linux 配置ip 网络故障排除 Centos7
- php 断点调试工具配置之故障排除
- 对 Azure Backup 的常见配置问题进行故障排除
- RHEL6启动原理和故障排除
- BIND主从服务器配置以及故障排除
- VTP中VLAN配置信息不同步故障排除
- 对 Azure Backup 的常见配置问题进行故障排除
- 对 Azure Backup 的常见配置问题进行故障排除
- 【服务器搭建环境配置】Linux上部署Nginx服务以及故障排除
- linux网络配置及故障排除(虚拟机)
- LFCS 系列第十三讲:如何配置并排除 GNU 引导加载程序(GRUB)故障
- RHEL 启动系统及故障排除
- RHEL5下DNS服务的配置与故障处理
- 如何配置 Virtual SAN 监控工具进行监控/故障排除
- 对 Azure Backup 的常见配置问题进行故障排除
- AIX 上的 ITDS 6.1 的配置和故障排除