server 0.centos.pool.ntp.org iburst #默認(rèn)的上層時間服務(wù)器 server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst includefile /etc/ntp/crypto/pw keys /etc/ntp/keys
修改配置
cat /etc/ntp.conf driftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery #對默認(rèn)的client拒絕所有操作 restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 #允許本機(jī)的一切操作 restrict 192.168.1.0 mask 255.255.255.0 nomodify #允許局域網(wǎng)內(nèi)所有client連接到這臺服務(wù)器 restrict -6 ::1 同步時間.但是拒絕讓他們修改服務(wù)器上的時間 #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server ntp1.aliyun.com #同步公網(wǎng)的時間 server 127.127.1.0 #如果無法連接公網(wǎng),則使用自己本身的時間作為標(biāo)準(zhǔn)時間。 fudge 127.127.1.0 stratum 10 #設(shè)置stratum級別 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys
ignore:關(guān)閉所有的 NTP 聯(lián)機(jī)服務(wù)
nomodify:客戶端不能更改服務(wù)端的時間參數(shù),但是客戶端可以通過服務(wù)端進(jìn)行網(wǎng)絡(luò)校時
notrust:客戶端除非通過認(rèn)證,否則該客戶端來源將被視為不信任子網(wǎng)
noquery:不提供客戶端的時間查詢
客戶端的安裝同服務(wù)器,如上。
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
#server 0.centos.pool.ntp.org iburst #<==注釋默認(rèn)的上層時間服務(wù)器
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntpserver #<==添加自己的時間服務(wù)器
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
在服務(wù)器端啟動NTP服務(wù),命令如下:
/etc/init.d/ntpd start
添加開啟啟動:
chkconfig ntpd on
這樣就表示我們的 NTP 服務(wù)器已經(jīng)啟動了,不過要與上層 NTP 服務(wù)器聯(lián)機(jī)則還需要一些時間, 通常啟動 NTP 后約在 15 分鐘內(nèi)才會和上層 NTP 服務(wù)器順利連接上。 那要如何確認(rèn)我們的 NTP 服務(wù)器有順利的更新自己的時間呢?你可以使用底下幾個指令來查閱喔 (請自行等待數(shù)分鐘后再以下列指令查閱):
這個指令可以列出我們的 NTP 服務(wù)器有跟上層聯(lián)機(jī)否。由上述的輸出結(jié)果可以知道,時間有校正約 258 * 10^(-3) 秒,且每隔 512秒會主動去更新時間喔!
各個參數(shù)的含義:
事實(shí)上這個輸出的結(jié)果告訴我們,時間真的很準(zhǔn)了啦!因?yàn)椴町惗荚?0.001 秒以內(nèi), 可以符合我們的一般使用了。另外,你也可以檢查一下你的 BIOS 時間與 Linux 系統(tǒng)時間的差異, 就是 /var/lib/ntp/drift 這個檔案的內(nèi)容,就能了解到咱們的 Linux 系統(tǒng)時間與 BIOS 硬件時鐘到底差多久?單位為 10^(-6) 秒啦!
要讓你的 NTP Server/Client 真的能運(yùn)作,在上述的動作中得注意:
上述的 ntpstat 以及 ntpq -p 的輸出結(jié)果中,你的 NTP 服務(wù)器真的要能夠連結(jié)上層 NTP 才行! 否則你的客戶端將無法對你的 NTP 服務(wù)器進(jìn)行同步更新的!重要重要!
你的 NTP 服務(wù)器時間不可與上層差異太多。
服務(wù)器防火墻在 UDP port 123 有沒有開???要特別注意的呢!
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機(jī)的問題,請?jiān)L問西部數(shù)碼官網(wǎng):www.ps-sw.cn