免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5620 | 回复: 8

ntp调试成功 [复制链接]

论坛徽章:
0
发表于 2004-11-07 09:43 |显示全部楼层
1、配置文件
[09:28 AM][root@hp01]cat /etc/rc.config.d/netdaemons
export NTPDATE_SERVER="us.pool.ntp.org at.pool.ntp.org au.pool.ntp.org"
export XNTPD=1

2、启动文件
[09:30 AM][root@hp01][/sbin/rc2.d]ll | grep ntp
lrwxr-xr-x   1 root       root            18 Oct 30 14:25 S660xntpd ->; /sbin/init.d/xntpd

3、测试过程
[09:27 AM][root@hp01][/etc/rc.config.d]/sbin/init.d/xntpd stop
xntpd stopped
[09:32 AM][root@hp01][/etc/rc.config.d]date 101010102003      
date: do you really want to run time backwards?[yes/no]yes
Fri Oct 10 10:10:00 EAT 2003
[10:10 AM][root@hp01][/etc/rc.config.d]/sbin/init.d/xntpd start
7 Nov 09:32:42 ntpdate[3477]: step time server 63.164.62.249 offset 34039349.100517 sec
[09:32 AM][root@hp01][/etc/rc.config.d]date
Sun Nov  7 09:33:04 EAT 2004

论坛徽章:
0
发表于 2004-11-07 16:15 |显示全部楼层

ntp调试成功

谢谢。
希望每个人都能把自己的实践经验拿出来跟大家分享。

论坛徽章:
0
发表于 2004-11-07 16:20 |显示全部楼层

ntp调试成功

请问该主机必须要连通INTERNET吗?us.pool.ntp.org at.pool.ntp.org au.pool.ntp.org是不是时钟校准的站点啊?

论坛徽章:
0
发表于 2004-11-07 22:43 |显示全部楼层

ntp调试成功

1、当然是在网络上对时间了,不出去怎么对?
2、其他机器可以此服务器为准进行调整,可以用rdate命令就可以了:
sun01#rdate  hp01

论坛徽章:
0
发表于 2004-11-08 02:25 |显示全部楼层

ntp调试成功

this is only for HP-UX. For other Unix and Linux, the procedure will be a little bit different. Thanks!

论坛徽章:
0
发表于 2004-11-08 21:11 |显示全部楼层

ntp调试成功

这也给原创阿!8-(

论坛徽章:
0
发表于 2004-11-10 05:40 |显示全部楼层

ntp调试成功

http://www.shanghainese.net/discuz/viewthread.php?tid=1027


电脑的时间放置不理的话过不久就会出现误差。
这个误差会反映在email送信时刻的time stamp上,会反映在你的论坛帖子发表时刻上。至少我遇到过这个问题。
网络上有ntp(network time protocol)服务器,提供当前的时刻。我们可以将本地的时刻与ntp服务器的时刻进行同步。

目的如下:
1,启动时用ntpdate进行时刻修正。
2,启动中,通过ntpd进行时刻校正的同时,将各个客户端电脑的时刻也进行同期校正。
3,如果不能找到ntp服务器,那么就使用local time,同时同步客户

全世界约有100多个ntp服务器,从下面地址找一个离你最近的
http://www.eecis.udel.edu/~mills/ntp/clock1a.html
我选择了两个
clock.nc.fukuoka-u.ac.jp 133.100.9.2
clock.tl.fukuoka-u.ac.jp 133.100.11.8

步骤:

FreeBSD中有两个标准的ntp程序,其一为ntpdate.

ntpdate通过从ntp服务器获取时刻,调整本地时刻。
# ntpdate clock.nc.fukuoka-u.ac.jp
9 Oct 18:12:23 ntpdate: step time server 133.100.9.2 offset -19.112674

大约有19秒钟的误差

自动设定
# grep ntpdate /etc/defaults/rc.conf >;>;/etc/rc.conf
# vi /etc/rc.conf
ntpdate_enable="YES" # Run ntpdate to sync time on boot (or NO).
ntpdate_program="ntpdate" # path to ntpdate, if you want a different one.
ntpdate_flags="clock.nc.fukuoka-u.ac.jp" # Flags to ntpdate (if enabled).

重新启动以后就运行了,当然设定没有完,不必急着启动

FreeBSD的另一个标准ntp程序,ntp

ntp程序使的获取ntp时刻的同时,向其他pc提供时刻。

添加文件ntp.conf:
用来作为标准时刻的ntp服务器我选择了两个
clock.nc.fukuoka-u.ac.jp 133.100.9.2
clock.tl.fukuoka-u.ac.jp 133.100.11.8
同时指定复数个服务器也没有问题,系统会自动选择一个可以信赖的。
这里,为避免多余的DNS数据包传递,我们直接指定IP地址。
server行 server 127.127.1.0 为参考本地时刻时用的地址。然后用fudge指定阶层编号为5,降低其优先度。
接着用restrict对每一个IP地址指定相应的规则。
最后,指定波长校正用的drift文档保存地址。关于这个命令行,具体的含义不太清楚。不过如果没有的话,时间校正起来就会比较慢
# vi /etc/ntp.conf
server 133.100.9.2 #clock.nc.fukuoka-u.ac.jp
server 133.100.11.8 #clock.tl.fukuoka-u.ac.jp
server 127.127.1.0
fudge 127.127.0.1 stratum 5
restrict default ignore
restrict 127.0.0.0 mask 255.0.0.0
restrict 192.168.1.0 mask 255.255.255.0 noquery nopeer notrust
restrict 133.100.9.2 noquery
restrict 133.100.11.8 noquery
driftfile /etc/ntpd.drift

启动测试
# ntpd -p /var/run/ntpd.pid
# tail /var/log/messages
Oct 9 16:46:56 chiwawa ntpd[89409]: ntpd 4.1.0-a Thu Apr 3 08:26:24 GMT 2003 (1)
Oct 9 16:46:56 chiwawa ntpd[89409]: kernel time discipline status 2040
......
Oct 9 16:50:10 chiwawa ntpd[89409]: time set -0.189546 s
看到类似的结果就可以了

运行测试
ntpd的运行用ntpq命令
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*clock.nc.fukuok .GPS. 1 u 43 64 37 19.067 -6.884 10.339
+clock.tl.fukuok .GPS. 1 u 36 64 35 19.670 -3.259 2.341
LOCAL(0) LOCAL(0) 5 l 45 64 37 0.000 0.000 0.001

启动后到时刻校正完成需要一点时间。*是第一候补,+是第二。
本地时刻校正完成以后就可以为其他PC提供时刻校正服务了。

自动启动的设定
完成以上设定,确认运行无误以后:
# grep ntpd /etc/defaults/rc.conf >;>;/etc/rc.conf
# vi /etc/rc.conf
xntpd_enable="YES" # Run ntpd Network Time Protocol (or NO).
xntpd_program="ntpd" # path to ntpd, if you want a different one.
xntpd_flags="-p /var/run/ntpd.pid" # Flags to ntpd (if enabled).

往rc.conf追加上面3行内容,并修改。



客户端PC设定:

UNIX OS
# vi /etc/ntp.conf
server [local ntp server IP] prefer
driftfile /etc/ntpd.drift
或者追加下面内容到crontab,这样,每过一个小时0分的时候就自动更新。
# vi /etc/crontab
0 * * * * root ntpdate [ntp server IP] >;/dev/null 2>;&1
当然,你的主机其实也是一个客户机,这些内容也可以用上。


Windows
精工的网站上有下载软件,不过是日语的
http://www.seiko-p.co.jp/systems/down/time.html
windows2000自带了sntp机能,请自己研究吧。

论坛徽章:
0
发表于 2004-12-06 20:26 |显示全部楼层

ntp调试成功

我们单位现在做系统对时遇到一个这样的问题。要用windows操作系统的pc机作对时系统的time server,HP-UX的服务器作client。该如何配置?
以前我们hp-ux的服务器作time server,需与他对时的NT服务器上安装的Atomtime软件进行对时。反过来我就配不了了。

论坛徽章:
0
发表于 2005-04-02 18:59 |显示全部楼层

ntp调试成功

  1. enhand# ntpdate time.nist.gov
  2. 2 Apr 19:05:17 ntpdate[92236]: step time server 192.43.244.18 offset -764.002619 sec
复制代码


还是没有解决??
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP