当前位置: 技术问答>linux和unix
ntp服务器配置问题
来源: 互联网 发布时间:2016-04-22
本文导语: 大家好,我现在在配置NTP服务器的过程中遇到的这样的问题,我觉得是NTP服务没有起来,请大家帮我分析一下. 1.配置/etc/ntp.conf,内容如下: restrict default nomodify notrap restrict 127.0.0.1 mask 255.0.0.0 ...
大家好,我现在在配置NTP服务器的过程中遇到的这样的问题,我觉得是NTP服务没有起来,请大家帮我分析一下.
1.配置/etc/ntp.conf,内容如下:
restrict default nomodify notrap
restrict 127.0.0.1 mask 255.0.0.0 #开放本机的任何访问
restrict 192.168.1.0 mask 255.255.255.0 nomodify
restrict 192.168.2.0 mask 255.255.255.0 nomodify
server 210.72.145.44 prefer
server 222.73.106.220 prefer
server 221.130.184.210 prefer
server 218.21.130.42
restrict 127.0.0.1
restrict 0.0.0.0 mask 0.0.0.0 nomodify #允许任何主机进行时间同步
server 127.127.1.0
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift (已存在)
broadcastdelay 0.008
keys /etc/ntp/keys(已存在)
2.# ntpdate 222.73.106.220 提示信息如下,表明该操作成功
Looking for host 222.73.106.220 and service ntp
host found : 222.73.106.220
Clock: old time 1970/01/01 - 00:07:44 GMT
Clock: new time 2008/06/04 - 08:07:59 GMT
4 Jun 08:07:59 ntpdate[45]: step time server 222.73.106.220 offset 1212566414.870733 sec
3。运行ntpd
#/bin/ntpd -c /etc/ntp.conf (已存在)
4。检查ntpd是否起来,
采用PS命令可以看到:
75 root 856 S /bin/ntpd -c /etc/ntp.conf
76 root 728 S /bin/ntpd -c /etc/ntp.conf
说明是起来了的。
采用netstat -an(对应UDP的State 为空是否表明是CLOSED?为什么?UDP的123端口已经开启了的啊???)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
udp 0 0 192.168.1.46:123 0.0.0.0:*
udp 0 0 192.168.2.46:123 0.0.0.0:*
udp 0 0 127.0.0.1:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
最后用# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
210.72.145.44 .ACTS. 1 u 62 16 377 64.540 11861.3 2375.66
222.73.106.220 2.0.244.117 3 u 69 1024 77 34.587 6672.13 4497.24
221.130.184.210 64.183.56.58 2 u 64 1024 77 134.977 6650.76 4501.00
218.21.130.42 204.152.184.72 2 u 70 1024 77 352.827 8002.26 3968.23
为什么remote前都是空格,没有“+”“*”?那说明没有与上层服务器连上,为什么会这样?
7。在客户机上运行:ntpdate 192.168.1.88(上面配置的服务器的IP)显示:
no server suitable for synchronization found等待了五分钟之后再次运行ntpdate 192.168.1.88仍然显示no server suitable for synchronization found.
为何会这样呢?是不是我配置的/etc/ntp.conf不对?
1.配置/etc/ntp.conf,内容如下:
restrict default nomodify notrap
restrict 127.0.0.1 mask 255.0.0.0 #开放本机的任何访问
restrict 192.168.1.0 mask 255.255.255.0 nomodify
restrict 192.168.2.0 mask 255.255.255.0 nomodify
server 210.72.145.44 prefer
server 222.73.106.220 prefer
server 221.130.184.210 prefer
server 218.21.130.42
restrict 127.0.0.1
restrict 0.0.0.0 mask 0.0.0.0 nomodify #允许任何主机进行时间同步
server 127.127.1.0
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift (已存在)
broadcastdelay 0.008
keys /etc/ntp/keys(已存在)
2.# ntpdate 222.73.106.220 提示信息如下,表明该操作成功
Looking for host 222.73.106.220 and service ntp
host found : 222.73.106.220
Clock: old time 1970/01/01 - 00:07:44 GMT
Clock: new time 2008/06/04 - 08:07:59 GMT
4 Jun 08:07:59 ntpdate[45]: step time server 222.73.106.220 offset 1212566414.870733 sec
3。运行ntpd
#/bin/ntpd -c /etc/ntp.conf (已存在)
4。检查ntpd是否起来,
采用PS命令可以看到:
75 root 856 S /bin/ntpd -c /etc/ntp.conf
76 root 728 S /bin/ntpd -c /etc/ntp.conf
说明是起来了的。
采用netstat -an(对应UDP的State 为空是否表明是CLOSED?为什么?UDP的123端口已经开启了的啊???)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
udp 0 0 192.168.1.46:123 0.0.0.0:*
udp 0 0 192.168.2.46:123 0.0.0.0:*
udp 0 0 127.0.0.1:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
最后用# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
210.72.145.44 .ACTS. 1 u 62 16 377 64.540 11861.3 2375.66
222.73.106.220 2.0.244.117 3 u 69 1024 77 34.587 6672.13 4497.24
221.130.184.210 64.183.56.58 2 u 64 1024 77 134.977 6650.76 4501.00
218.21.130.42 204.152.184.72 2 u 70 1024 77 352.827 8002.26 3968.23
为什么remote前都是空格,没有“+”“*”?那说明没有与上层服务器连上,为什么会这样?
7。在客户机上运行:ntpdate 192.168.1.88(上面配置的服务器的IP)显示:
no server suitable for synchronization found等待了五分钟之后再次运行ntpdate 192.168.1.88仍然显示no server suitable for synchronization found.
为何会这样呢?是不是我配置的/etc/ntp.conf不对?
|
ntp服务是用udp的,udp不监听的,所以stats没listen,tcp才监听的,
|
默认情况下,我们配置的NTP服务器不会去时间源那里同步时间,所以必须修改/etc/ntp/step-tickers文件,加入我们的时间源,这样每次通过/etc/init.d/ntpd 来启动服务的时候就会自动更新时间了
#vi /etc/ntp/step-tickers
210.72.145.44
222.73.106.220
......
得保证上面的ip,你的机子能ping通
然后重启下ntp服务,
#vi /etc/ntp/step-tickers
210.72.145.44
222.73.106.220
......
得保证上面的ip,你的机子能ping通
然后重启下ntp服务,