AIX 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

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可自动启动。

相关文档
最新文档