Chinaunix

标题: NTP服务 [打印本页]

作者: liyaweihesmz    时间: 2013-05-09 11:10
标题: NTP服务


    RHEL6.3上NTP服务如何配置???
作者: wupenhu    时间: 2013-05-09 11:15
这个问题怎么没人来回答呢/
作者: liyaweihesmz    时间: 2013-05-09 13:13
回复 2# wupenhu


    我配置了好多次都没成功。查找了好多资料,配置都挺简单,我做了就是没结果。
作者: chenyx    时间: 2013-05-09 20:20
直接安装,启动ntp服务就可以了.默认带的ntp-server的默认配置就可以用
作者: liyaweihesmz    时间: 2013-05-10 09:17
回复 4# chenyx


    NTP服务就是用来将系统时间与网络时间同步。客户机的时间不会与服务器的时间同步吧??
作者: chenyx    时间: 2013-05-10 09:22
客户机可以通过ntpdate命令与服务器同步时间
作者: sirense    时间: 2013-05-10 09:23
说不定是防火墙上相应端口没打开
作者: wenhq    时间: 2013-05-10 11:32
配置不成功的看日志,日志里告诉你什么问题。然后针对解决。
作者: liyaweihesmz    时间: 2013-05-10 13:37
回复 6# chenyx


    我执行这个命令报错了啊,提示如下信息:
[root@wyh ~]# ntpdate 192.168.174.153
10 May 13:35:05 ntpdate[21420]: no server suitable for synchronization found
  我在网上查资料说等5分钟执行就可以了,但是我一直有这个错误提示。
作者: liyaweihesmz    时间: 2013-05-10 13:40
回复 7# sirense


   我一般是将防火墙关闭的。后来,我试着开启防火墙,然后添加了NTP服务器的端口123.所以端口是打开了。
作者: liyaweihesmz    时间: 2013-05-10 13:43
回复 8# wenhq
我查看日志信息中有如下信息。最后一行的提示信息我不清楚是杂回事了。
  1. May 10 13:36:48 wyh ntpd[21449]: ntpd 4.2.4p8@1.1612-o Thu Jan 10 15:17:24 UTC 2013 (1)
  2. May 10 13:36:48 wyh ntpd[21450]: precision = 0.291 usec
  3. May 10 13:36:48 wyh ntpd[21450]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
  4. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled
  5. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #1 wildcard, ::#123 Disabled
  6. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #2 lo, ::1#123 Enabled
  7. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #3 eth0, fe80::20c:29ff:fed3:9350#123 Enabled
  8. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #4 lo, 127.0.0.1#123 Enabled
  9. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #5 eth0, 192.168.174.141#123 Enabled
  10. May 10 13:36:48 wyh ntpd[21450]: Listening on interface #6 virbr0, 192.168.122.1#123 Enabled
  11. May 10 13:36:48 wyh ntpd[21450]: Listening on routing socket on fd #23 for interface updates
  12. May 10 13:36:48 wyh ntpd[21450]: kernel time sync status 2040
  13. May 10 13:36:48 wyh ntpd[21450]: frequency initialized 0.000 PPM from /var/lib/ntp/drift
  14. May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 0.rhel.pool.ntp.org
  15. May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 1.rhel.pool.ntp.org
  16. May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 2.rhel.pool.ntp.org
  17. May 10 13:36:55 wyh ntpd[21450]: ntpd exiting on signal 15
  18. May 10 13:36:55 wyh ntpd_initres[21452]: parent died before we finished, exiting
  19. May 10 13:40:01 wyh CROND[21513]: (root) CMD (/usr/lib/sa/sa1 1 1)
复制代码
我想问下楼主,Linux下使用哪种调试工具最好查看日志信息了。
作者: wenhq    时间: 2013-05-10 13:44
ping 192.168.174.153
通么?
作者: wenhq    时间: 2013-05-10 13:44
另外你看192.168.174.153 这个机器的ntp配置允许你同步么?
作者: wenhq    时间: 2013-05-10 13:46
你的ntp配置文件有问题。

May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 0.rhel.pool.ntp.org
May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 1.rhel.pool.ntp.org
May 10 13:36:50 wyh ntpd_initres[21452]: host name not found: 2.rhel.pool.ntp.org
May 10 13:36:55 wyh ntpd[21450]: ntpd exiting on signal 15
May 10 13:36:55 wyh ntpd_initres[21452]: parent died before we finished, exiting

最后一行只是crontab的一条日志。没别的了。
作者: chenyx    时间: 2013-05-10 16:32
域名解析出问题了吧.你在ntp服务器测试下dns解析吧
作者: liyaweihesmz    时间: 2013-05-13 09:16
回复 13# wenhq


    能ping通。
    我配置了restrict 192.168.174.0 mask 255.255.255.0 nomodify notrap这条信息是允许192.168.174.153 这个机器的ntp配置同步吧。
    要是还需其他配置,我就不清楚了。
作者: wenhq    时间: 2013-05-13 09:26
贴一下你的ntp的配置文件。
作者: liyaweihesmz    时间: 2013-05-13 09:38
  1. # For more information about this file, see the man pages
  2. # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

  3. driftfile /var/lib/ntp/drift

  4. # Permit time synchronization with our time source, but do not
  5. # permit the source to query or modify the service on this system.
  6. restrict default kod nomodify notrap nopeer noquery
  7. #restrict -6 default kod nomodify notrap nopeer noquery

  8. # Permit all access over the loopback interface.  This could
  9. # be tightened as well, but to do so would effect some of
  10. # the administrative functions.
  11. restrict 127.0.0.1
  12. restrict -6 ::1

  13. # Hosts on local network are less restricted.
  14. restrict 192.168.174.0 mask 255.255.255.0 nomodify notrap

  15. # Use public servers from the pool.ntp.org project.
  16. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  17. server 0.rhel.pool.ntp.org iburst
  18. server 1.rhel.pool.ntp.org iburst
  19. server 2.rhel.pool.ntp.org iburst

  20. #broadcast 192.168.1.255 autokey        # broadcast server
  21. #broadcastclient                        # broadcast client
  22. #broadcast 224.0.1.1 autokey            # multicast server
  23. #multicastclient 224.0.1.1              # multicast client
  24. #manycastserver 239.255.254.254         # manycast server
  25. #manycastclient 239.255.254.254 autokey # manycast client

  26. # Undisciplined Local Clock. This is a fake driver intended for backup
  27. # and when no outside source of synchronized time is available.
  28. server 192.168.174.153
  29. fudge   127.127.1.0 stratum 10

  30. # Enable public key cryptography.
  31. #crypto

  32. includefile /etc/ntp/crypto/pw

  33. # Key file containing the keys and key identifiers used when operating
  34. # with symmetric key cryptography.
  35. keys /etc/ntp/keys
  36. # Specify the key identifiers which are trusted.
  37. #trustedkey 4 8 42

  38. # Specify the key identifier to use with the ntpdc utility.
  39. #requestkey 8

  40. # Specify the key identifier to use with the ntpq utility.
  41. #controlkey 8

  42. # Enable writing of statistics records.
  43. #statistics clockstats cryptostats loopstats peerstats

复制代码
回复 17# wenhq


   
作者: wenhq    时间: 2013-05-13 09:49
server 192.168.174.153 ##改成你本地的ntpserver IP
这个IP 是你内网的 ntp server 192.168.174.153?
#############################
server 0.rhel.pool.ntp.org iburst

server 1.rhel.pool.ntp.org iburst

server 2.rhel.pool.ntp.org iburst

注释掉这3行。
作者: liyaweihesmz    时间: 2013-05-13 12:41
回复 19# wenhq


    我在虚拟机上实验了,我在IP地址为192.168.174.153的主机上实验作为服务器,所以我就填这个地址啊。
作者: wenhq    时间: 2013-05-13 12:44
回复 20# liyaweihesmz


    恩,注释掉那3行,重启一下ntp 服务试试。
作者: liyaweihesmz    时间: 2013-05-14 10:02
回复 21# wenhq


    还是同样的错误。
   ntpdate 192.168.174.153
   14 May 09:53:17 ntpdate[23062]: no server suitable for synchronization found

   NTP服务器中messages日志信息如下:
  1. May 14 09:56:30 localhost ntpd[31468]: ntpd exiting on signal 15
  2. May 14 09:56:30 localhost ntpd[31540]: ntpd 4.2.4p8@1.1612-o Thu Jan 10 15:17:24 UTC 2013 (1)
  3. May 14 09:56:30 localhost ntpd[31541]: precision = 0.430 usec
  4. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled
  5. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #1 wildcard, ::#123 Disabled
  6. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #2 lo, ::1#123 Enabled
  7. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #3 eth0, fe80::20c:29ff:fe6f:4d56#123 Enabled
  8. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #4 lo, 127.0.0.1#123 Enabled
  9. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #5 eth0, 192.168.174.157#123 Enabled
  10. May 14 09:56:30 localhost ntpd[31541]: Listening on interface #6 virbr0, 192.168.122.1#123 Enabled
  11. May 14 09:56:30 localhost ntpd[31541]: Listening on routing socket on fd #23 for interface updates
  12. May 14 09:56:30 localhost ntpd[31541]: kernel time sync status 2040
  13. May 14 09:56:30 localhost ntpd[31541]: frequency initialized 23.467 PPM from /var/lib/ntp/drift
复制代码

作者: wenhq    时间: 2013-05-15 19:13
回复 10# liyaweihesmz
是UDP 123 不是TCP 你设置的没问题?

   
作者: wenhq    时间: 2013-05-15 20:04
ntpdate -d yourlocalntpserver

ntptrace yourlocalntpserver


and tcpdump -i eth0 and udp and port 123 抓包看下。
作者: sirense    时间: 2013-05-21 13:11
NTP服务器能不能连到 自身/etc/ntp.conf 里 server 行配置的服务器IP?
作者: liyaweihesmz    时间: 2013-05-21 13:33
回复 25# sirense


    不可以。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2