Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6843976
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: AIX

2013-06-20 14:51:51


################                       AIX                       ######################

/etc/ntp.conf

时间同步:

# broadcastclient

 

server 139.125.8.21 prefer

server 139.125.8.22 prefer

#server 127.127.1.0        

 

#fudge 127.127.1.0 stratum 4

 

#broadcast 224.0.1.1   

 

driftfile /etc/ntp.drift

tracefile /etc/ntp.trace

logfile  /etc/ntp.log

 

1.1.1      NTP 服务器的配置

(1)    root用户登录

(2)    编辑 /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主服务器是与自身的系统时钟同步。

 

(3)    编辑好 /etc/ntp.conf, 启动xntpd守护进程

# startsrc -s xntpd

也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.

# smitty xntpd

(4)    修改/etc/rc.tcpip

start /usr/sbin/xntpd "$src_running"这句话的注释去掉,表示在系统启动时,自动启动xntpd守护进程

也可以采用smitty xntpd->start Using the Xntpd Subsystemà选择both

这条命令的作用其实也就是修改/etc/rc.tcpip, start /usr/sbin/xntpd "$src_running"这句话的注释去掉,同时,马上启动xntpd子系统。

(5)    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 的状态将改变。

#lssrc -ls xntpd

Program name: --/usr/sbin/xntpd

Version: -------3

Leap indicator: 00 (No leap second today.)

Sys peer: ------127.127.1.0

...

Sys peer的输出变为Sys peer: ------127.127.1.0,表示xntpd的同步完成,这时就可以进行客户端的设置了

1.1.2      NTP客户端的设置

(1)    root用户登录

(2)    编辑 NTP 客户端上的 /etc/ntp.conf文件, 内容如下:

----------------------------

#broadcastclient

server 10.10.10.10

driftfile /etc/ntp.drift       //采用默认值

tracefile /etc/ntp.trace   //采用默认值

----------------------------

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

(3)    NTP客户端启动xntpd守护进程

# startsrc -s xntpd

也可通过调用smitty , 使 xntpd 在以后重启服务器时能自动启动.

# smitty xntpd

 lssrc -s xntpd检查xntpd子系统是否正常启动,active为正常。

(4)    修改/etc/rc.tcpip

start /usr/sbin/xntpd "$src_running"这句话的注释去掉,表示在系统启动时,自动启动xntpd守护进程

也可以采用smitty xntpd->start Using the Xntpd Subsystemà选择both

这条命令的作用其实也就是修改/etc/rc.tcpip, start /usr/sbin/xntpd "$src_running"这句话的注释去掉,同时,马上启动xntpd子系统。

(5)    查询xntpd的状态

用命令lssrc -ls xntpd检查xntpd的状态,当刚开始启动时,输出如下:

Program name: --/usr/sbin/xntpd

      Version: -------3

      Leap indicator: 11 (Leap indicator is insane.)

      Sys peer: ------no peer, system is insane

其中Sys peer的输出为no peer,system is insane表示xntpd还没有完成同步

等待6-10分钟,Sys peer的输出变为Sys peer: ------crm(NTP服务器小型机的IP地址或者主机名),表示xntpd的同步完成,这时就可以进行客户端的设置。

1.1.3      NTP客户端查询NTP服务器

ntp客户端使用 ntpdate 命令来确认是否可用指定的 ntp 服务器进行时间同步。

命令的结果会显示客户端与服务器的时间偏移。

#ntpdate -d 10.10.10.10

...

18 Mar 10:52:54 ntpdate[23578]: step time server 10.10.10.10 offset 86323.06827

2 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 10.10.10.10 offset 86403.40260

7 sec

#date

Wed Mar 19 11:06:54 BEIST 2003

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






###############################   LINUX  #####################################


Suse Linux 配置

Suse服务端配置

1.启动ntp服务

# /usr/sbin/xntpd start

4 Mar 16:02:43 ntpdate[13721]: no server suitable for synchronization found

启动ntp服务

# service ntp start

# chkconfig ntp on

/etc/rc.d/ntp stop/start 关闭/启动ntp服务

/etc/init.d/ntp stop/start关闭/启动ntp服务

2.查看ntp服务运行状况(ntp服务开启的情况下,才可以使用下面命令)

# ntpq -p

remote refid st t when poll reach delay offset disp

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

LOCAL(1) LOCAL(1) 10 l 9 64 1 0.00 0.000 15885.0

Suse客户端

1、以root用户登录NTP客户端服务器如192.168.1.10

2、执行以下命令,使NTP客户端向NTP服务器进行一次时间同步。

# ntpdate 192.168.1.1 (使用这条命令,则就不能启动ntp服务,

否则冲突错误:the NTP socket is in use, exiting

即:开启ntp服务,不能与cron配合使用)

系统显示如下信息,表示时间同步成功。

20 Jul 10:40:49 ntpdate[30829]: step time server 192.168.1.1 offset -0.013005 sec

Offset 表示时间差值,单位秒

3、执行如下命令。

# crontab e

4、在打开的文件中按“Insert”键,使文件处于编辑状态,输入如下内容。

### ntp server ###

0,15,30,45 * * * * nohup /usr/sbin/ntpdate 192.168.1.1 >> /ntp/ntp_data.log

注:红字部分为日志文件(需要手动创建),可根据需要进行调整。

5、按“Esc”键退出编辑状态,输入“:wq”,保存退出。

6、执行以下命令重新启动cron

# rccron restart  # service cron restart

注意事项:

1.在配置客户端时,一定要注意与服务端的网络权限是否已经开通;

2.作为时间服务器的主机时间不要随意修改。因为修改后会影响所有主机的时间,

如果必须修改请与各业务人员确认后再作修改。切记!!

故障处理:

一、ntpdate[23803]: the NTP socket is in use, exiting错误

1 手动进行时间同步报错重现,报错提示NTP正在使用

# /usr/sbin/ntpdate 10.1.251.21

26 Sep 11:51:16 ntpdate[23803]: the NTP socket is in use, exiting

2、手动同步失败后,打算开启ntp服务进行同步,配置文件修改及匹配测试NTP时间服务器相关文件后,执行以下命令:

# vi /etc/ntp.conf // 加入下面几行

server 10.1.251.21

server 10.1.251.22

#server 127.127.1.0 # local clock (LCL)

#fudge 127.127.1.0 stratum 10 # LCL is unsynchronized

# service ntp restart // 重启ntp服务

Shutting down network time protocol daemon (NTPD) done

Starting network time protocol daemon (NTPD) done

3、查看服务运行情况,如下,服务已启动

# ntpq –p //由以下输出可知,ntp时钟源指向本地,没有读取配置文件,配置失败

remote refid st t when poll reach delay offset jitter

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

LOCAL(0) LOCAL(0) 10 l 17 64 1 0.000 0.000 0.001

4、生产NTP服务器时钟源指向测试NTP服务器,测试成功

# ntpdate 10.248.3.201

20 Oct 10:51:46 ntpdate[22798]: adjust time server 10.248.3.201 offset -0.046745 sec

5、将双机的另外一个ip加到集团的bits设备上后,做如下操作

# service ntp restart 同步成功

Shutting down network time protocol daemon (NTPD) done

Try to get initial date and time via NTP from 10.1.251.21 10.1.251.22done

Starting network time protocol daemon (NTPD) done

# ntpq 服务启动且读取配置文件中指定的NTP时钟源,配置成功

remote refid st t when poll reach delay offset jitter

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

*10.1.251.21 .SLK. 1 u 33 64 17 1.694 -0.011 0.025

10.1.251.22 .INIT. 16 u - 64 0 0.000 0.000 4000.00

二、8387]: no server suitable for synchronization found错误

遇到过这种情况:

Suse-Linux 为服务器端

Hp-Unix为客户端

客户端重启服务或ntpdate同步时总是提示下面错误:因为时间误差较大,以为是时间误差问题,修改在一天内时,同步成功,后经查看服务器端没有ntp.drift文件,经建立后,不管时间误差多大,都能同步成功,说明主要还是没有ntp.drift文件的问题。

# ntpdate 10.248.3.167

14 Sep 13:55:49 ntpdate[8387]: no server suitable for synchronization found

 

源文档 <http://blog.itpub.net/post/37743/507635>

 

SUSE LINUX 11G 配置时间同步配置

 

 

/etc/ntp.conf 配置文件内容:

##

## Undisciplined Local Clock. This is a fake driver intended for backup

## and when no outside source of synchronized time is available.

server 10.244.151.116 minpoll 10 prefer

server 10.244.151.117 minpoll 10

#server 127.127.1.0             # local clock (LCL)

#fudge  127.127.1.0 stratum 10  # LCL is unsynchronized

 

##

## Add external Servers using

## # rcntp addserver

##

 

##

## Miscellaneous stuff

##

 

driftfile /var/lib/ntp/drift/ntp.drift # path for drift file

 

logfile   /var/log/ntp          # alternate log file

# logconfig =syncstatus + sysevents

# logconfig =all

 

# statsdir /tmp/                # directory for statistics files

# filegen peerstats  file peerstats  type day enable

# filegen loopstats  file loopstats  type day enable

# filegen clockstats file clockstats type day enable

 

#

# Authentication stuff

#

keys /etc/ntp.keys              # path for keys file

trustedkey 1                    # define trusted keys

requestkey 1                    # key (7) for accessing server variables

# controlkey 15                 # key (6) for accessing server variables

 

 

----------------------------------------------------------------------

DGBOSS-WEB1:~ # ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

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

*10.244.151.116  172.18.1.11      4 u   92 1024  377    4.877   -0.131   0.122

+10.244.151.117  172.18.1.11      4 u   68 1024  377    4.818    1.535   0.025



阅读(1567) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~