各操作系统配置NTP
admin
2023-03-24 09:01:16
0

 

 

一、    AIX服务器端

?  编辑 /etc/ntp.conf 文件, 内容如下:

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

#broadcastclient

server 210.72.145.44 prefer

server 218.21.130.42

server 127.127.1.0

driftfile /etc/ntp.drift

tracefile /etc/ntp.trace

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

请注意文件中的 server 127.127.1.0 这一行, 此处的127.127.1.0 是一特殊的地址,表示NTP主服务器是与自身的系统时钟同步.

 

?  然后启动xntpd服务

#startsrc -s xntpd

0513-059 The xntpd Subsystem has been started. Subsystem PID is 7274732.

 

 

?  查看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  //初始化未完成

 Sys stratum:     16   //初始化未完成

 Sys precision:   -17

 Debug/Tracing:   DISABLED

 Root distance:   0.000000

 Root dispersion: 0.000000

 Reference ID:    no refid, system is insane  //初始化未完成

 Reference time:  no reftime, system is insane //初始化未完成

 Broadcast delay: 0.003906 (sec)

 Auth delay:      0.000122 (sec)

 System flags:    bclient pll monitor filegen 

 System uptime:   40 (sec)

 Clock stability: 0.000000 (sec)

 Clock frequency: 0.000000 (sec)

 Peer: 127.127.1.0

      flags: (configured)(refclock)

      stratum:  3, version: 3

      our mode: client, his mode: server

 Peer: 218.21.130.42

      flags: (configured)

      stratum: 16, version: 3

      our mode: client, his mode: unspecified

 Peer: 210.72.145.44

      flags: (configured)(preferred)

      stratum: 16, version: 3

      our mode: client, his mode: unspecified

Subsystem         Group            PID          Status

 xntpd            tcpip            7274732      active

等待 6 - 10 分钟后, sys peer 就不再是 'insane' .

二、    AIX客户端

?  /etc/ntp.conf中添加

server 192.168.15.92

driftfile /etc/ntp.drift

tracefile /etc/ntp.trace

 

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

# startsrc -s xntpd

 

?  xntpd 状态查询 , 使用 #l***c -ls xntpd

刚启动xntpd, sys peer 'insane', 表明xntpd还没有完成同步, .

#l***c -ls xntpd

Peer: 192.168.1.1

 

?  NTP客户端查询NTP服务器  //可选

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

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

#ntpdate -d 192.168.15.92

 

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

 

# smit xntpd

 

选择Start Using the xntpd Subsyste

 

选择BOTH方式,表示立即启动以及系统下次启动的时候将自动启动

 

通过如下命令可以看到,其实xntpdtcpip服务组的一个子服务而已

 

#l***c -g tcpip

 

Subsystem Group PID Status

 

inetd tcpip 303118 active

 

snmpd tcpip 651356 active

 

xntpd tcpip 589898 active

 

……

 

同样,/etc/rc.tcpip可以看到如下的内容,表示该服务随TCPIP服务组一起启动

 

# Start up Network Time Protocol (NTP) daemon

 

start /usr/sbin/xntpd $src_running 

 

 

客户端与服务器端的时间偏移量过大,因此即使启动客户端xntpd守护进程也会导致客户端无法与服务器端进行时间同步,ntp进程会自动关闭,需要先手动修改时间,再做ntp同步

 

以下正常输出:

各操作系统配置NTP

各操作系统配置NTP

*号说明以该ip服务器同步

 

 

 

 

三、    Linux配置ntp客户端

?  配置ntp.conf

#vi /etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift

keys /etc/ntp/keys

server 192.168.15.92 prefer

 

?  重启ntp服务

#service ntpd restart

 

?  查看ntp

# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

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

 LOCAL(0)        .LOCL.          10 l   17   64   17    0.000    0.000   0.001

*192.168.15.92   LOCAL(0)         4 u   29   64   17    0.397   -2.224   0.786

 

*号说明以该IPNTP时间同步

 

 

四、    Windows客户端配置NTP

各操作系统配置NTP

 

备注:域模式下的windows无法使用NTP

 

 

 

 

?  FAQ

A1:如果执行ntpq –p

Temporary failure in name resolution

 

Q1:是hosts文件没有127.0.0.1记录

   hosts文件里添加127.0.0.1

127.0.0.1       localhost.localdomain localhost

再重启ntp服务

#Service ntpd restart

 

 

A2:如果执行ntpq –p

read: A remote host refused an attempted connect operation

 

Q2:系统时间和ntp时间相差太大,需要手动调整

手动调整时间,再重启ntp服务

 

 

 

 

 

相关内容

热门资讯

特朗普下令不打了,美国的“余粮... 可以说戛然而止,快得让很多人都无法适应。前两周,每一天美国都要打击伊朗一通。就在7月24日白宫会议前...
穆杰塔巴最新表态:支持黎真主党 △伊朗最高领袖穆杰塔巴·哈梅内伊(资料图)当地时间7月26日晚,伊朗最高领袖穆杰塔巴·哈梅内伊对黎巴...
美军瘫痪一艘驶向伊朗的油轮,特... 美国总统特朗普虽下令暂停打击伊朗,但美军仍在执行对霍尔木兹海峡的封锁任务。针对美军瘫痪一艘驶向伊朗油...
“小牌大耍”的底气到底是哪里来... 澎湃首席评论员 李平这两天,“艺人李权哲乘高铁占座事件”在网上引发热议,该艺人参加的活动主办方曾发布...
越南籍船舶南海遇险沉没,中方已... 据凤凰卫视报道,一艘越南船舶7月24日夜间在越南庆和以东220海里附近遇险沉没,船上共62名越南籍人...
李权哲占座、蒙面、装死:娱乐圈... 你买了一张高铁一等座的票,找到自己的位置,18A。有人坐着。你拿出手机看了眼购票记录——没错,18A...
杭州景区咖啡店闯入1条幼蛇,仅... 夏天气温高、湿度大,蛇类活动进入高峰期,千万别被“小蛇无害”的刻板印象骗了!有些幼蛇看着迷你可爱,实...
AI开源公开信签署企业增至50... IT之家 7 月 26 日消息,英伟达、微软、IBM、Meta 等 25 家美国科技企业本周(7 月...
南阳快手短视频代运营企业的服务... 在短视频平台快速发展的背景下,企业通过快手等渠道进行内容运营已成为常见的市场动作。对于希望借助短视频...
普通人该如何跟上科技发展的步伐 这个被称作科技的词汇, 听起来既有宏大之感, 又颇为遥远, 好似仅仅归属于在实验室里专心致志钻研的科...