溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

各操作系統(tǒng)配置NTP

發(fā)布時間:2020-07-12 16:23:23 來源:網(wǎng)絡(luò) 閱讀:1088 作者:攻城獅一枚 欄目:建站服務(wù)器

 

 

一、    AIX服務(wù)器

?  編輯 /etc/ntp.conf 文件, 內(nèi)容如下:

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

#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主服務(wù)器是與自身的系統(tǒng)時鐘同步.

 

?  然后啟動xntpd服務(wù)

#startsrc -s xntpd

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

 

 

?  查看xntpd狀態(tài):

#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守護(hù)進(jìn)程

# startsrc -s xntpd

 

?  xntpd 狀態(tài)查詢 , 使用 #l***c -ls xntpd

剛啟動xntpd, sys peer 'insane', 表明xntpd還沒有完成同步, .

#l***c -ls xntpd

Peer: 192.168.1.1

 

?  NTP客戶端查詢NTP服務(wù)器  //可選

ntp客戶端使用 ntpdate 命令來確認(rèn)是否可用指定的 ntp 服務(wù)器進(jìn)行時間同步。

命令的結(jié)果會顯示客戶端與服務(wù)器的時間偏移。

#ntpdate -d 192.168.15.92

 

?  通過調(diào)用smitty,使 xntpd 在以后重啟服務(wù)器時能自動啟動。

 

# smit xntpd

 

選擇Start Using the xntpd Subsyste

 

選擇BOTH方式,表示立即啟動以及系統(tǒng)下次啟動的時候?qū)⒆詣訂?/font>

 

通過如下命令可以看到,其實xntpdtcpip服務(wù)組的一個子服務(wù)而已

 

#l***c -g tcpip

 

Subsystem Group PID Status

 

inetd tcpip 303118 active

 

snmpd tcpip 651356 active

 

xntpd tcpip 589898 active

 

……

 

同樣,/etc/rc.tcpip可以看到如下的內(nèi)容,表示該服務(wù)隨TCPIP服務(wù)組一起啟動

 

# Start up Network Time Protocol (NTP) daemon

 

start /usr/sbin/xntpd $src_running 

 

 

客戶端與服務(wù)器端的時間偏移量過大,因此即使啟動客戶端xntpd守護(hù)進(jìn)程也會導(dǎo)致客戶端無法與服務(wù)器端進(jìn)行時間同步,ntp進(jìn)程會自動關(guān)閉,需要先手動修改時間,再做ntp同步

 

以下正常輸出:

各操作系統(tǒng)配置NTP

各操作系統(tǒng)配置NTP

*號說明以該ip服務(wù)器同步

 

 

 

 

三、    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服務(wù)

#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

各操作系統(tǒng)配置NTP

 

備注:域模式下的windows無法使用NTP

 

 

 

 

?  FAQ

A1:如果執(zhí)行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服務(wù)

#Service ntpd restart

 

 

A2:如果執(zhí)行ntpq –p

read: A remote host refused an attempted connect operation

 

Q2:系統(tǒng)時間和ntp時間相差太大,需要手動調(diào)整

手動調(diào)整時間,再重啟ntp服務(wù)

 

 

 

 

 

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI