Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1163689
  • 博文数量: 146
  • 博客积分: 6619
  • 博客等级: 准将
  • 技术积分: 1621
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-29 14:06
文章分类

全部博文(146)

文章存档

2020年(1)

2019年(4)

2018年(3)

2017年(5)

2015年(5)

2014年(7)

2013年(5)

2012年(11)

2011年(15)

2010年(13)

2009年(14)

2008年(63)

分类:

2008-04-16 15:46:02

上一篇“在AIX中使用NTP服务”已经讲的很全面,这篇文章仅作为补充。
 
xntpd是关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准。在启动 xntpd 时, xntpd 会读取 /etc/ntp.conf 配置文件来确定网络中系统时钟服务器,以 ntp 服务器的系统时间为标准,来调整本机的系统时间。

可以用 ntpq 命令来显示 xntpd 进程的内部变量。使用 ntp 时应注意,xntpd 服务器和 xntpd 客户端的时钟不能相差超过1000秒。若有大于1000秒的偏移,在客户端启动 xntpd 守护进程前,用 data 命令或 ntpdate 命令调整本机的系统时间,使偏移量在1000秒之内。然后启动 xntpd.

1. 构造一个NTP环境的基本步骤:

1.1 设置NTP 服务器(以192.168.5.2为例), 其它NTP客户服务器以此服务器的时间为准,与其进行时间同步.
1.1.1 编辑 /etc/ntp.conf 文件, 内容如下:
----------------------------
#broadcastclient
server 127.127.1.0
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
----------------------------
请注意文件中的 server 127.127.1.0 这一行, 此处的127.127.1.0 是一特殊的地址,表示NTP主服务器是与自身的系统时钟同步.

1.1.2 编辑好 /etc/ntp.conf后, 启动xntpd守护进程
# startsrc -s xntpd
也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.
# smitty xntpd

1.1.3 xntpd 状态查询 , 使用 #lssrc -ls xntpd
刚启动xntpd时, sys peer 为 'insane', 表明xntpd还没有完成同步, .
#lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 11 (Leap indicator is insane.) Sys peer: ------no peer, system is insane ...

等待 6 - 10 分钟后, sys peer 就不再是 'insane' 了.
#lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 00 (No leap second today.) Sys peer: ------127.127.1.0 ...

1.2. NTP客户端的设置
1.2.1 编辑 NTP 客户端上的 /etc/ntp.conf文件, 内容如下:
----------------------------
#broadcastclient
server 192.168.5.2
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
----------------------------
其中的 server 192.168.5.2 表明, 此客户端与IP地址为 192.168.5.2 的NTP服务器进行时间同步.

1.2.2 在NTP客户端启动xntpd守护进程
# startsrc -s xntpd
也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.
# smitty xntpd

1.2.3 查询xntpd的状态
当 system peer 不为 'insane' 时, 表明客户端已与服务器端成功地进行了同步.
# lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 00 (No leap second today.) Sys peer: ------192.168.5.2 ...

1.3. NTP客户端查询NTP服务器
ntp客户端使用 ntpdate 命令来确认是否可用指定的 ntp 服务器进行时间同步。
命令的结果会显示客户端与服务器的时间偏移。
#ntpdate -d 192.168.5.2
...
18 Jan 15:49:57 ntpdate[98462]: adjust time server 192.168.5.2 offset -0.000868
2 sec

若时间间隔大于1000秒,使用ntpdate 进行手工调整, 如:
#date
Thu Jan 18 15:52:00 BEIST 2007

#ntpdate 192.168.5.2
18 Jan 15:49:57 ntpdate[23832]: step time server 9.185.43.189 offset 23.40260
7 sec

#date
Thu Jan 18 15:52:00 BEIST 2007
完成上述操作后 ntp 客户端与 ntp 服务器系统时钟完成同步,ntp 客户端得到了新的系统时间。

查看同步的时间间隔(poll)
# xntpdc -c peers
    remote          local      st poll reach  delay  offset    disp
=======================================================================
*192.168.5.2    192.168.7.1      4  64  377 0.00230 -0.000426 0.00026
 
在AIX中可以用两种方法来实现应用环境中多台机器的系统时间的统一。一个是启动xntpd 守护进程, 另一个是启动timed进程.
为了保证时间的一致性,在同一台机器上只启动xntpd 或 timed. (在AIX中这两个进程,缺省是不启动。每个AIX系统使用自己的系统时间。)
xntpd
是一个关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准。在启动 xntpd 时, xntpd 会读取 /etc/ntp.conf 配置文件来确定网络中系统时钟服务器,以 ntp 服务器的系统时间为标准,来调整本机的系统时间。
可以用 ntpq 命令来显示 xntpd 进程的内部变量。使用 ntp 时应注意,xntpd 服务器和 xntpd 客户端的时钟不能相差超过1000秒。若有大于1000秒的偏移,在客户端启动 xntpd 守护进程前,用 data 命令或 ntpdate 命令调整本机的系统时间,使偏移量在1000秒之内。 然后启动 xntpd.
timed
是一个时钟服务进程。 在一个局域网内可有多个 timed 服务器,但只有一个 timed 主服务器,其余的是 timed 副服务器。当 timed 主服务器功能失效时,其中一个 timed 副服务器可自动变为主服务器。 网络时间可以以 timed 主服务器的系统时间为标准,也可以以所有运行 timed 的主、辅服务器的系统时钟的平均值为准,来调整所有运行 timed 进程的机器的系统时钟。timed 客户机的系统时间与局域网上运行着的 timed 主服务器的系统时间同步,使整个网络运行环境有一个统一的时钟。

1. 构造一个NTP环境的基本步骤(假设NTP不是运行在SP上):
1.1 设置NTP 服务器 (MASTER) , 其它NTP客户服务器以此服务器的时间为准,与其进行时间同步.
1.1.1 编辑 /etc/ntp.conf 文件, 内容如下:
----------------------------
#broadcastclient
server 127.127.1.0
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
----------------------------
请注意文件中的 server 127.127.1.0 这一行, 此处的127.127.1.0 是一特殊的地址,表示NTP主服务器是与自身的系统时钟同步.
1.1.2 编辑好 /etc/ntp.conf后, 启动xntpd守护进程
# startsrc -s xntpd
也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.
# smitty xntpd

1.1.3 xntpd 状态查询 , 使用 #lssrc -ls xntpd
刚启动xntpd时, sys peer 为 'insane', 表明xntpd还没有完成同步, .
#lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 11 (Leap indicator is insane.)
Sys peer: ------no peer, system is insane
...

等待 6 - 10 分钟后, sys peer 就不再是 'insane' 了.
#lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 00 (No leap second today.)
Sys peer: ------127.127.1.0
...
1.2. NTP客户端的设置
1.2.1 编辑 NTP 客户端上的 /etc/ntp.conf文件, 内容如下:
----------------------------
#broadcastclient
server 9.185.43.189
driftfile /etc/ntp.drift
tracefile /etc/ntp.trace
----------------------------
其中的 server 9.185.43.189 表明, 此客户端与IP地址为 9.185.43.189 的NTP服务器进行时间同步.
1.2.2 在NTP客户端启动xntpd守护进程
# startsrc -s xntpd
也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.
# smitty xntpd
1.2.3 查询xntpd的状态
当 system peer 不为 'insane' 时, 表明客户端已与服务器端成功地进行了同步.
# lssrc -ls xntpd
Program name: --/usr/sbin/xntpd
Version: -------3
Leap indicator: 00 (No leap second today.)
Sys peer: ------9.185.43.189
...
1.3. NTP客户端查询NTP服务器
ntp客户端使用 ntpdate 命令来确认是否可用指定的 ntp 服务器进行时间同步。
命令的结果会显示客户端与服务器的时间偏移。
#ntpdate -d 9.185.43.189
...
18 Mar 10:52:54 ntpdate[23578]: step time server 9.185.43.189 offset 86323.06827
2 sec
若时间间隔大于1000秒,使用ntpdate 进行调整, 如:
#date
Tue Mar 18 11:06:29 BEIST 2003
#ntpdate 9.185.43.189
19 Mar 11:06:51 ntpdate[23832]: step time server 9.185.43.189 offset 86403.40260
7 sec
#date
Wed Mar 19 11:06:54 BEIST 2003
完成上述操作后 ntp 客户端与 ntp 服务器系统时钟完成同步,ntp 客户端得到了新的系统时间。

2. 使用timed的基本设置步骤如下
2.1. 启动timed服务器
a. 在局域网内,以timed 主服务器的系统时钟为标准,来完成时钟的同步。
# startsrc -s timed -a " -M -c "
b. 在局域网内,以所有运行 timed 的主、辅服务器的系统时间平均值为标准,来完成时钟的同步。
# startsrc -s timed -a " -M “
2.2. 启动timed 客户端, 使其按照标准网络时间来调整自己的系统时钟。
# startsrc -s timed
2.3. 将timed的启动语句加到 /etc/rc.tcpip 中,以便重新启动机器后,timed可自动启动。
参考资料: timed , xntpd command
阅读(2815) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~