AIX中如何使用NTP协议

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.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

参数 -dSpecifies debug mode. Determines what results the ntpdate 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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值