AIX中如何使用NTP协议

来源:互联网 发布:ubuntu 重置系统命令 编辑:程序博客网 时间:2024/05/21 17:33

AIX中可以用启动xntpd守护进程的方法来实现应用环境中多台机器的系统时间的统一

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

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

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

-> Start Using the xntpd Subsystem

-> BOTH

 

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.189NTP服务器进行时间同步.

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

参数 -dSpecifies debug mode. Determines what results thentpdate command produces without actually doing them. The results appear on the screen. This flag uses unprivileged ports.

 

18 Mar 10:52:54 ntpdate[23578]: step time server 9.185.43.189 offset 86323.068272 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.402607 sec

 

#date

Wed Mar 19 11:06:54 BEIST 2003

完成上述操作后 ntp客户端与 ntp 服务器系统时钟完成同步,ntp客户端得到了新的系统时间。

 

 

 

查看同步的时间间隔(poll

# xntpdc -c peers

     remote           local      st poll reach  delay   offset    disp

=======================================================================

*202.103.194.85  202.103.194.150  4  128  377 0.00081  0.000143 0.00008

=======================================================================

原创粉丝点击