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上均可以實現。

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