免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 9594 | 回复: 11
打印 上一主题 下一主题

求助:两台linux利用ntp时间同步问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-10-20 21:14 |只看该作者 |倒序浏览
机器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




为何两台机器时间仍然无法一致?

论坛徽章:
0
2 [报告]
发表于 2010-10-21 10:02 |只看该作者
没人回答啊

论坛徽章:
1
操作系统版块每日发帖之星
日期:2015-07-11 22:20:00
3 [报告]
发表于 2010-10-21 10:54 |只看该作者
楼主重启两台服务器的ntpd,10分钟后继续看下面

1 请给两台机器 ntpq -p 信息,并注明哪台是哪台
2 请在两台机器上执行
ntpq
> ass
> rv (ass列出来的ID)
把结果贴出来。

  1. [root@dhcp-129-193 ~]# ntpq -p
  2.      remote           refid      st t when poll reach   delay   offset  jitter
  3. ==============================================================================
  4. clock1.redhat.c .INIT.          16 u    -   64    0    0.000    0.000   0.000
  5. [root@dhcp-129-193 ~]# ntpq
  6. ntpq> ass

  7. ind assID status  conf reach auth condition  last_event cnt
  8. ===========================================================
  9.   1 40755  8000   yes   yes  none    reject
  10. ntpq> rv 40755
  11. assID=40755 status=8000 unreach, conf, no events,
  12. srcadr=clock1.redhat.com, srcport=123, dstadr=10.66.129.193,
  13. dstport=123, leap=11, stratum=16, precision=-20, rootdelay=0.000,
  14. rootdispersion=0.000, refid=INIT, reach=000, unreach=1, hmode=3,
  15. pmode=0, hpoll=6, ppoll=10, flash=00 ok, keyid=0, ttl=0, offset=0.000,
  16. delay=0.000, dispersion=15937.500, jitter=0.000,
  17. reftime=00000000.00000000  Thu, Feb  7 2036 14:28:16.000,
  18. org=00000000.00000000  Thu, Feb  7 2036 14:28:16.000,
  19. rec=00000000.00000000  Thu, Feb  7 2036 14:28:16.000,
  20. xmt=d06a29d9.6c205e39  Thu, Oct 21 2010 10:54:17.422,
  21. filtdelay=     0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00,
  22. filtoffset=    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00,
  23. filtdisp=   16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0
  24. ntpq>

复制代码

论坛徽章:
0
4 [报告]
发表于 2010-10-21 11:27 |只看该作者
回复 3# cst05001
主机A(服务器)
  1. [root@idcaxl04 twist]# ntpq -p
  2. 127.0.0.1: timed out, nothing received
  3. ***Request timed out
  4. [root@idcaxl04 twist]# ntpq
  5. ntpq> ass
  6. 127.0.0.1: timed out, nothing received
  7. ***Request timed out
复制代码
机器B(以A作为服务器):
  1. [root@IDCAXL05 ~]# ntpq -p
  2.      remote           refid      st t when poll reach   delay   offset  jitter
  3. ==============================================================================
  4. *idcaxl04.asiapa LOCAL(0)        11 u   47   64   77    0.319  -35867.   2.526
  5. [root@IDCAXL05 ~]# ntpq
  6. ntpq> ass

  7. ind assID status  conf reach auth condition  last_event cnt
  8. ===========================================================
  9.   1 27764  9624   yes   yes  none  sys.peer   reachable  2
  10. ntpq> rv 27764
  11. assID=27764 status=9624 reach, conf, sel_sys.peer, 2 events, event_reach,
  12. srcadr=idcaxl04.asiapacific.hpqcorp.net, srcport=123,
  13. dstadr=16.173.244.201, dstport=123, leap=00, stratum=11, precision=-17,
  14. rootdelay=0.000, rootdispersion=11.017, refid=LOCAL(0), reach=177,
  15. unreach=0, hmode=3, pmode=4, hpoll=6, ppoll=6, flash=00 ok, keyid=0,
  16. ttl=0, offset=-35867.440, delay=0.319, dispersion=64.632, jitter=2.448,
  17. reftime=d06a3085.a89e44fa  Thu, Oct 21 2010  3:22:45.658,
  18. org=d06a308a.e60a30db  Thu, Oct 21 2010  3:22:50.898,
  19. rec=d06a30ae.c4a936c5  Thu, Oct 21 2010  3:23:26.768,
  20. xmt=d06a30ae.c4919ef9  Thu, Oct 21 2010  3:23:26.767,
  21. filtdelay=     0.33    0.38    0.32    0.35    0.34    0.35    0.33    0.00,
  22. filtoffset= -35869. -35868. -35867. -35866. -35865. -35864. -35863.    0.00,
  23. filtdisp=      0.01    0.97    1.93    2.87    3.83    4.82    5.78 16000.0
  24. ntpq>
复制代码

论坛徽章:
1
操作系统版块每日发帖之星
日期:2015-07-11 22:20:00
5 [报告]
发表于 2010-10-21 11:32 |只看该作者
回复 4# xph4444


    建议你检查下A机网络配置
  1. # iptables -L
  2. # getenforce
  3. # cat /etc/hosts
复制代码
给结果

论坛徽章:
0
6 [报告]
发表于 2010-10-21 11:46 |只看该作者
回复 5# cst05001
  1. [root@idcaxl04 tmp]# iptables -L
  2. Chain INPUT (policy ACCEPT)
  3. target     prot opt source               destination

  4. Chain FORWARD (policy ACCEPT)
  5. target     prot opt source               destination

  6. Chain OUTPUT (policy ACCEPT)
  7. target     prot opt source               destination
  8. OGFS_Level_0  all  --  anywhere             anywhere

  9. Chain OGFS_Level_0 (1 references)
  10. target     prot opt source               destination
  11. DROP       tcp  --  anywhere             anywhere           tcp dpt:1521 OWNER GID match 70001
  12. DROP       tcp  --  anywhere             anywhere           tcp dpt:1007 OWNER GID match 70001
  13. DROP       tcp  --  anywhere             anywhere           tcp dpt:1006 OWNER GID match 70001
  14. DROP       tcp  --  anywhere             anywhere           tcp dpt:2222 OWNER GID match 70001
  15. DROP       tcp  --  anywhere             anywhere           tcp dpt:3001 OWNER GID match 70001
  16. DROP       tcp  --  anywhere             anywhere           tcp dpt:3002 OWNER GID match 70001
  17. DROP       tcp  --  anywhere             anywhere           tcp dpt:3003 OWNER GID match 70001
  18. DROP       tcp  --  anywhere             anywhere           tcp dpt:2001 OWNER GID match 70001
  19. DROP       tcp  --  anywhere             anywhere           tcp dpt:2002 OWNER GID match 70001
  20. DROP       tcp  --  anywhere             anywhere           tcp dpt:cfinger OWNER GID match 70001
  21. DROP       tcp  --  anywhere             anywhere           tcp dpt:webcache OWNER GID match 70001
  22. DROP       tcp  --  anywhere             anywhere           tcp dpt:4040 OWNER GID match 70001
  23. DROP       tcp  --  anywhere             anywhere           tcp dpt:8085 OWNER GID match 70001
  24. [root@idcaxl04 tmp]# getenforce
  25. -bash: getenforce: command not found
  26. [root@idcaxl04 tmp]# cat /etc/hosts
  27. ## Begin Opsware Infrastructure Hostnames
  28. 16.173.244.103  theword   theword.idcaxl04.chn.hp.com
  29. 16.173.244.103  wordcache   wordcache.idcaxl04.chn.hp.com
  30. 16.173.244.103  mmopsw   mmopsw.idcaxl04.chn.hp.com
  31. 16.173.244.103  mmspin   mmspin.idcaxl04.chn.hp.com

  32. 16.173.244.103  spin   spin.idcaxl04.chn.hp.com
  33. 16.173.244.103  twist   twist.idcaxl04.chn.hp.com
  34. 16.173.244.103  buildmgr   buildmgr.idcaxl04.chn.hp.com
  35. 16.173.244.103  occ   occ.idcaxl04.chn.hp.com
  36. 16.173.244.103  way   way.idcaxl04.chn.hp.com

  37. 127.0.0.1               localhost.localdomain localhost

  38. #127.0.0.1      localhost.localdomain   IDCAXL04        localhost
  39. 16.157.128.106 ux14231
  40. 16.157.128.127 ux14229
  41. 127.0.0.1 localhost.localdomain localhost
  42. 16.173.244.103  idcaxl04 idcaxl04.chn.hp.com
  43. 16.173.244.103  truth.idcaxl04.chn.hp.com truth
复制代码

论坛徽章:
1
操作系统版块每日发帖之星
日期:2015-07-11 22:20:00
7 [报告]
发表于 2010-10-21 11:54 |只看该作者
  1. # [root@idcaxl04 twist]# ntpq -p
  2. # 127.0.0.1: timed out, nothing received
  3. # ***Request timed out
复制代码
从这里看,你A机根本就无法从本机获取时间,因此更无法为B机提供时间服务。B机目前我不能确定是否有问题,也许就没有。

目前当务之急是让A机能够通过ntp获取到本机的时间。
你在A机ping下 127.0.0.1能否ping通?请告诉我。
如果能ping通,你能确定下A机NTP起了没有?如果能ping通的情况下遇到你这个问题,通常是ntp压根就没提供服务或者没启动。
  1. # ps aux | grep ntp
复制代码
一下吧。

论坛徽章:
0
8 [报告]
发表于 2010-10-21 11:59 |只看该作者
回复 7# cst05001


   A机可以ping 通127.0.0.1
  另外,service netq status 显示的也是在运行的,重启什么的也都没问题
唯独:
  1. [root@idcaxl04 tmp]# ntpq -p
  2. 127.0.0.1: timed out, nothing received
  3. ***Request timed out
复制代码
另外
  1. [root@idcaxl04 tmp]# ps aux | grep ntp
  2. 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
  3. 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
  4. root      3956  0.0  0.1 151960 4452 ?       S    Oct14   2:15 /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
  5. root      3960  0.0  0.0 56180 2800 ?        S    Oct14   0:37 /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
  6. ntp       9683  0.0  0.0  2568 2560 ?        SL   03:04   0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
  7. root      9686  0.0  0.0  2780 2688 ?        S    03:04   0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
  8. root     11873  0.0  0.0  3684  676 pts/0    S    03:57   0:00 grep ntp
复制代码

论坛徽章:
1
操作系统版块每日发帖之星
日期:2015-07-11 22:20:00
9 [报告]
发表于 2010-10-21 12:00 |只看该作者
本帖最后由 cst05001 于 2010-10-21 12:02 编辑
  1. service netq status
复制代码
netq是什么东东??
  1. ps aux | grep ntp
  2. /etc/init.d/ntpd status
复制代码
直接贴输出吧

论坛徽章:
0
10 [报告]
发表于 2010-10-21 13:56 |只看该作者
回复 9# cst05001
  1. [root@idcaxl04 tmp]# ps aux | grep ntp
  2. 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
  3. 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
  4. root      3956  0.0  0.1 151960 4452 ?       S    Oct14   2:16 /opt/opsware/bin/python /opt/opsware/agentproxy/lib/main.pyc
  5. root      3960  0.0  0.0 56180 2800 ?        S    Oct14   0:37 /opt/opsware/bin/python2 /opt/opsware/agentproxy/lib2/main.pyc
  6. ntp       9683  0.0  0.0  2568 2560 ?        SL   03:04   0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
  7. root      9686  0.0  0.0  2780 2688 ?        S    03:04   0:00 ntpd -U ntp -p /var/run/ntpd.pid -g
  8. root     16768  0.0  0.0  3704  676 pts/0    S    05:53   0:00 grep ntp
  9. You have new mail in /var/spool/mail/root
  10. [root@idcaxl04 tmp]# /etc/init.d/ntpd status
  11. ntpd (pid 9686 9683) is running...
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP