Chinaunix
标题:
求助:两台linux利用ntp时间同步问题
[打印本页]
作者:
xph4444
时间:
2010-10-20 21:14
标题:
求助:两台linux利用ntp时间同步问题
机器A(16.173.244.103)的ntp.conf
restrict default nomodify notrap noquery
server 0.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
authenticate yes
keys /etc/ntp/keys
---------
机器B(16.173.244.201 )的ntp.conf
restrict default nomodify
restrict 127.0.0.1
server 16.173.244.103
restrict 16.173.244.103
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
keys /etc/ntp/keys
------------
在终端下输入:
[root@IDCAXL05 etc]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
idcaxl04.asiapa LOCAL(0) 11 u 60 64 1 0.360 -34911. 0.001
为何两台机器时间仍然无法一致?
作者:
xph4444
时间:
2010-10-21 10:02
没人回答啊
作者:
cst05001
时间:
2010-10-21 10:54
楼主重启两台服务器的ntpd,10分钟后继续看下面
1 请给两台机器 ntpq -p 信息,并注明哪台是哪台
2 请在两台机器上执行
ntpq
> ass
> rv (ass列出来的ID)
把结果贴出来。
例
[root@dhcp-129-193 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
clock1.redhat.c .INIT. 16 u - 64 0 0.000 0.000 0.000
[root@dhcp-129-193 ~]# ntpq
ntpq> ass
ind assID status conf reach auth condition last_event cnt
===========================================================
1 40755 8000 yes yes none reject
ntpq> rv 40755
assID=40755 status=8000 unreach, conf, no events,
srcadr=clock1.redhat.com, srcport=123, dstadr=10.66.129.193,
dstport=123, leap=11, stratum=16, precision=-20, rootdelay=0.000,
rootdispersion=0.000, refid=INIT, reach=000, unreach=1, hmode=3,
pmode=0, hpoll=6, ppoll=10, flash=00 ok, keyid=0, ttl=0, offset=0.000,
delay=0.000, dispersion=15937.500, jitter=0.000,
reftime=00000000.00000000 Thu, Feb 7 2036 14:28:16.000,
org=00000000.00000000 Thu, Feb 7 2036 14:28:16.000,
rec=00000000.00000000 Thu, Feb 7 2036 14:28:16.000,
xmt=d06a29d9.6c205e39 Thu, Oct 21 2010 10:54:17.422,
filtdelay= 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00,
filtoffset= 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00,
filtdisp= 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0
ntpq>
复制代码
作者:
xph4444
时间:
2010-10-21 11:27
回复
3#
cst05001
主机A(服务器)
[root@idcaxl04 twist]# ntpq -p
127.0.0.1: timed out, nothing received
***Request timed out
[root@idcaxl04 twist]# ntpq
ntpq> ass
127.0.0.1: timed out, nothing received
***Request timed out
复制代码
机器B(以A作为服务器):
[root@IDCAXL05 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*idcaxl04.asiapa LOCAL(0) 11 u 47 64 77 0.319 -35867. 2.526
[root@IDCAXL05 ~]# ntpq
ntpq> ass
ind assID status conf reach auth condition last_event cnt
===========================================================
1 27764 9624 yes yes none sys.peer reachable 2
ntpq> rv 27764
assID=27764 status=9624 reach, conf, sel_sys.peer, 2 events, event_reach,
srcadr=idcaxl04.asiapacific.hpqcorp.net, srcport=123,
dstadr=16.173.244.201, dstport=123, leap=00, stratum=11, precision=-17,
rootdelay=0.000, rootdispersion=11.017, refid=LOCAL(0), reach=177,
unreach=0, hmode=3, pmode=4, hpoll=6, ppoll=6, flash=00 ok, keyid=0,
ttl=0, offset=-35867.440, delay=0.319, dispersion=64.632, jitter=2.448,
reftime=d06a3085.a89e44fa Thu, Oct 21 2010 3:22:45.658,
org=d06a308a.e60a30db Thu, Oct 21 2010 3:22:50.898,
rec=d06a30ae.c4a936c5 Thu, Oct 21 2010 3:23:26.768,
xmt=d06a30ae.c4919ef9 Thu, Oct 21 2010 3:23:26.767,
filtdelay= 0.33 0.38 0.32 0.35 0.34 0.35 0.33 0.00,
filtoffset= -35869. -35868. -35867. -35866. -35865. -35864. -35863. 0.00,
filtdisp= 0.01 0.97 1.93 2.87 3.83 4.82 5.78 16000.0
ntpq>
复制代码
作者:
cst05001
时间:
2010-10-21 11:32
回复
4#
xph4444
建议你检查下A机网络配置
# iptables -L
# getenforce
# cat /etc/hosts
复制代码
给结果
作者:
xph4444
时间:
2010-10-21 11:46
回复
5#
cst05001
[root@idcaxl04 tmp]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
OGFS_Level_0 all -- anywhere anywhere
Chain OGFS_Level_0 (1 references)
target prot opt source destination
DROP tcp -- anywhere anywhere tcp dpt:1521 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:1007 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:1006 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:2222 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:3001 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:3002 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:3003 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:2001 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:2002 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:cfinger OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:webcache OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:4040 OWNER GID match 70001
DROP tcp -- anywhere anywhere tcp dpt:8085 OWNER GID match 70001
[root@idcaxl04 tmp]# getenforce
-bash: getenforce: command not found
[root@idcaxl04 tmp]# cat /etc/hosts
## Begin Opsware Infrastructure Hostnames
16.173.244.103 theword theword.idcaxl04.chn.hp.com
16.173.244.103 wordcache wordcache.idcaxl04.chn.hp.com
16.173.244.103 mmopsw mmopsw.idcaxl04.chn.hp.com
16.173.244.103 mmspin mmspin.idcaxl04.chn.hp.com
16.173.244.103 spin spin.idcaxl04.chn.hp.com
16.173.244.103 twist twist.idcaxl04.chn.hp.com
16.173.244.103 buildmgr buildmgr.idcaxl04.chn.hp.com
16.173.244.103 occ occ.idcaxl04.chn.hp.com
16.173.244.103 way way.idcaxl04.chn.hp.com
127.0.0.1 localhost.localdomain localhost
#127.0.0.1 localhost.localdomain IDCAXL04 localhost
16.157.128.106 ux14231
16.157.128.127 ux14229
127.0.0.1 localhost.localdomain localhost
16.173.244.103 idcaxl04 idcaxl04.chn.hp.com
16.173.244.103 truth.idcaxl04.chn.hp.com truth
复制代码
作者:
cst05001
时间:
2010-10-21 11:54
# [root@idcaxl04 twist]# ntpq -p
# 127.0.0.1: timed out, nothing received
# ***Request timed out
复制代码
从这里看,你A机根本就无法从本机获取时间,因此更无法为B机提供时间服务。B机目前我不能确定是否有问题,也许就没有。
目前当务之急是让A机能够通过ntp获取到本机的时间。
你在A机ping下 127.0.0.1能否ping通?请告诉我。
如果能ping通,你能确定下A机NTP起了没有?如果能ping通的情况下遇到你这个问题,通常是ntp压根就没提供服务或者没启动。
# ps aux | grep ntp
复制代码
一下吧。
作者:
xph4444
时间:
2010-10-21 11:59
回复
7#
cst05001
A机可以ping 通127.0.0.1
另外,service netq status 显示的也是在运行的,重启什么的也都没问题
唯独:
[root@idcaxl04 tmp]# ntpq -p
127.0.0.1: timed out, nothing received
***Request timed out
复制代码
另外
[root@idcaxl04 tmp]# ps aux | grep ntp
root 3940 0.0 0.0 2304 1100 ? S Oct14 0:00 /opt/opsware/bin/python /opt/opsware/agentproxy/bin/rotator.pyc agentproxy agentproxy.err /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
root 3949 0.0 0.0 2292 972 ? S Oct14 0:00 /opt/opsware/bin/python /opt/opsware/agentproxy/bin/rotator.pyc agentproxy execproxy.err /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
root 3956 0.0 0.1 151960 4452 ? S Oct14 2:15 /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
root 3960 0.0 0.0 56180 2800 ? S Oct14 0:37 /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
ntp 9683 0.0 0.0 2568 2560 ? SL 03:04 0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
root 9686 0.0 0.0 2780 2688 ? S 03:04 0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
root 11873 0.0 0.0 3684 676 pts/0 S 03:57 0:00 grep ntp
复制代码
作者:
cst05001
时间:
2010-10-21 12:00
本帖最后由 cst05001 于 2010-10-21 12:02 编辑
service netq status
复制代码
netq
是什么东东??
ps aux | grep ntp
/etc/init.d/ntpd status
复制代码
直接贴输出吧
作者:
xph4444
时间:
2010-10-21 13:56
回复
9#
cst05001
[root@idcaxl04 tmp]# ps aux | grep ntp
root 3940 0.0 0.0 2304 1100 ? S Oct14 0:00 /opt/opsware/bin/python /opt/opsware/agentproxy/bin/rotator.pyc agentproxy agentproxy.err /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
root 3949 0.0 0.0 2292 972 ? S Oct14 0:00 /opt/opsware/bin/python /opt/opsware/agentproxy/bin/rotator.pyc agentproxy execproxy.err /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
root 3956 0.0 0.1 151960 4452 ? S Oct14 2:16 /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
root 3960 0.0 0.0 56180 2800 ? S Oct14 0:37 /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
ntp 9683 0.0 0.0 2568 2560 ? SL 03:04 0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
root 9686 0.0 0.0 2780 2688 ? S 03:04 0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
root 16768 0.0 0.0 3704 676 pts/0 S 05:53 0:00 grep ntp
You have new mail in /var/spool/mail/root
[root@idcaxl04 tmp]# /etc/init.d/ntpd status
ntpd (pid 9686 9683) is running...
复制代码
作者:
cst05001
时间:
2010-10-21 14:25
回复
10#
xph4444
我现在no idea了。但是可以肯定一点,希望对你有用,从你A机报错提示,可以确定是A机ntpd无法通过ntp协议连接到本地的时间源。通常这个地方报错不会是ntp本身问题(除非你配置文件没给我最新的),而是这个socket连接或者哪个出现故障了。
大牛们发表下看法?
作者:
我还没醒
时间:
2010-10-22 10:10
看了cst05001的解决过程,收益不少。
ntp问题,我之前有一批机器升级微码后,无法更新本地时间,不知楼主的是什么情况。
同步时间,可以尝试ntpdate ntpserver && hwclok -w 试试(升级微码的是无发hwclock -w)。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2