IBM AIX系统NTP配置方法

一、NTP服务介绍

xntp是关于网络时间协议的守护进程,它遵循了因特网时间服务器的通用标准。在启动 xntpd时, xntpd会读取/etc/ntp.conf配置文件来确定网络中系统时钟服务器,以NTP服务器的系统时间为标准,来调整本机的系统时间。

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

在AIX系统中使用NTP,必须预先安装了bos.net.tcp.client包。

在部署时间服务(NTP)之前,需要先检查各服务器的时区设置,统一设置为“BEIST-8”——北京时间东八区,避免出现时区混乱的情况。

二、NTP服务器端配置

1,确定需要作为NTP服务器的主机。

2,编辑/etc/ntp.conf文件。

在/etc/ntp.conf文件的末尾,注释掉“broadcastclient”这一行,添加一行“server 127.127.1.0”。此处的127.127.1.0 是一特殊的地址,表示NTP主服务器是与自身的系统时钟同步。


#broadcastclient

server 127.127.1.0

driftfile /etc/ntp.drift

tracefile /etc/ntp.trace


3,重新启动ntp进程。

stopsrc -s xntpd

startsrc -s xntpd

如果NTP服务器上存在数据库,必须使用"-x"的函数,防止始终反方向运行,命令如下:

startsrc -s xntpd -a "-x"

4,检查ntp进程是否正常启动。 # l***c -ls xntpd

显示结果如下,Sys peer为“no peer, system is insane”表示还未同步:


Program name: /usr/sbin/xntpd

Version: 3

Leap indicator: 11 (Leap indicator is insane.)

Sys peer: no peer, system is insane


过10分钟后再查询一次,如果状态变成以下所示,表示同步成功,检查双机的时间,可以发现时间差:


Program name: /usr/sbin/xntpd

Version: 3

Leap indicator: 00 (No leap second today.)

Sys peer: 127.127.1.0


三、NTP客户端配置

1,查询NTP客户端与服务器端的时间差。 命令:

ntpdate -d ip.address.of.server


ntpdate -d 9.125.40.146 …… ……

4 Jan 12:57:58 ntpdate[16842]: adjust time server 9.125.40.146 offset -0.000180


offset -0.000180代表了NTP client与NTP server之间的时间差,正数代表NTP server比NTP client快,负数代表NTP server比NTP client慢。

如果时间差超过1000秒,需要通过手动的方式,对NTP client进行时间调整,使NTP server和NTP client的时间差在1000秒之内。

2,编辑NTP client端的/etc/ntp.conf文件。

注释掉broadcastclient一行,添加“server 9.125.40.146”。“9.125.40.146”即为NTP server的IP地址。


#broadcastclient

server 9.125.40.146

driftfile /etc/ntp.drift

tracefile /etc/ntp.trace


其中的 server 9.125.40.146 表明,此客户端与IP地址为 9.185.43.189 的NTP服务器进行时间同步。

3,启动NTP进程。

#stopsrc -s xntpd

#startsrc -s xntpd

如果NTP服务器上存在数据库,必须使用"-x"的函数,防止始终反方向运行,命令如下:

startsrc -s xntpd -a "-x"

4,编辑NTP客户端的/etc/rc.tcpip文件。

命令 # vi /etc/rc.tcpip

将start /usr/sbin/xntpd "$src_running" 一行的注释取消掉,使NTP进程中系统启动时能够自动启动,如果使用数据库的话,需要添加 -x 参数。

5,检查NTP客户端是否与NTP服务器端同步。

命令 # l***c -ls xntpd


#l***c -ls xntpd

Program name: /usr/sbin/xntpd

Version: 3

Leap indicator: 11 (Leap indicator is insane.)

Sys peer: no peer, system is insane


#l***c -ls xntpd

Program name: /usr/sbin/xntpd

Version: 3

Leap indicator: 00 (No leap second today.)

Sys peer: 9.125.40.146


四、NTP服务器端的时间更改

若NTP server进行时间修改的范围不超过1000秒,可以直接在NTP server上通过date命令进行修改。但在操作过程中,为了确保NTP client时钟不受到影响,建议先停止NTP client的ntpd进程。

1,停止NTP client的ntpd进程。 NTP client执行:

stopsrc -s xntpd

2,停止NTP server的ntpd进程。 NTP server执行:

stopsrc -s xntpd

3,NTP server通过date命令修改时间。

smitty date

4,启动NTP server的ntpd进程,并检查ntpd进程启动完成 NTP server:

startsrc -s xntpd

 # l***c -ls xntpd

5,启动NTP clinet的ntpd进程,并检查ntpd进程启动完成 NTP client:

startsrc -s xntpd -a "-x"

 # l***c -ls xntpd

五、NTP客户端查询NTP服务器

在ntp客户端使用ntpdate命令来确认是否可用指定的ntp服务器进行时间同步。命令的结果会显示客户端与服务器的时间偏移。
#ntpdate -d 10.118.0.3
13 Jun 11:20:01 ntpdate[36094]: adjust time server 10.118.0.3 offset -0.000993 sec

上面例子中的两台服务器时间差了0.000993秒,即0.993 毫秒,这是可以接受的正常偏差。若时间间隔大于1000秒,最好先使用smitty date进行调整。这种方法在AIX4.3上和AIX5L上均可以实现。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章