小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

linux ntp時(shí)間同步

 海漩渦 2014-11-10

轉(zhuǎn)自:http://www.cnblogs.com/liuyou/archive/2012/07/29/2614341.html

linux ntp時(shí)間同步

一、搭建時(shí)間同步服務(wù)器
1、編譯安裝ntp server
rpm -qa | grep ntp
若沒(méi)有找到,則說(shuō)明沒(méi)有安裝ntp包,從光盤(pán)上找到ntp包,使用
rpm -Uvh ntp***.rpm
進(jìn)行安裝
2、修改ntp.conf配置文件
vi /etc/ntp.conf
①、第一種配置:允許任何IP的客戶機(jī)都可以進(jìn)行時(shí)間同步
將“restrict default nomodify notrap noquery”這行修改成:
restrict default nomodify notrap
配置文件示例:/etc/ntp.conf
②、第二種配置:只允許192.168.211.***網(wǎng)段的客戶機(jī)進(jìn)行時(shí)間同步
在restrict default nomodify notrap noquery(表示默認(rèn)拒絕所有IP的時(shí)間同步)之后增加一行:
restrict 192.168.211.0 mask 255.255.255.0 nomodify notrap
3、啟動(dòng)ntp服務(wù)
service ntpd start
開(kāi)機(jī)啟動(dòng)服務(wù)
chkconfig ntpd on
4、ntpd啟動(dòng)后,客戶機(jī)要等幾分鐘再與其進(jìn)行時(shí)間同步,否則會(huì)提示“no server suitable for synchronization found”錯(cuò)誤。


二、配置時(shí)間同步客戶機(jī)

手工執(zhí)行 ntpdate <ntp server> 來(lái)同步
或者利用crontab來(lái)執(zhí)行
crontab -e
0 21 * * * ntpdate 192.168.211.22 >> /root/ntpdate.log 2>&1
每天晚上9點(diǎn)進(jìn)行同步
附:
當(dāng)用ntpdate -d 來(lái)查詢時(shí)會(huì)發(fā)現(xiàn)導(dǎo)致 no server suitable for synchronization found 的錯(cuò)誤的信息有以下2個(gè):
錯(cuò)誤1.Server dropped: Strata too high
在ntp客戶端運(yùn)行ntpdate serverIP,出現(xiàn)no server suitable for synchronization found的錯(cuò)誤。
在ntp客戶端用ntpdate –d serverIP查看,發(fā)現(xiàn)有“Server dropped: strata too high”的錯(cuò)誤,并且顯示“stratum 16”。而正常情況下stratum這個(gè)值得范圍是“0~15”。
這是因?yàn)镹TP server還沒(méi)有和其自身或者它的server同步上。
以下的定義是讓NTP Server和其自身保持同步,如果在/ntp.conf中定義的server都不可用時(shí),將使用local時(shí)間作為ntp服務(wù)提供給ntp客戶端。
server 127.127.1.0
fudge 127.127.1.0 stratum 8

在ntp server上重新啟動(dòng)ntp服務(wù)后,ntp server自身或者與其server的同步的需要一個(gè)時(shí)間段,這個(gè)過(guò)程可能是5分鐘,在這個(gè)時(shí)間之內(nèi)在客戶端運(yùn)行ntpdate命令時(shí)會(huì)產(chǎn)生no server suitable for synchronization found的錯(cuò)誤。
那么如何知道何時(shí)ntp server完成了和自身同步的過(guò)程呢?
在ntp server上使用命令:
# watch ntpq -p
出現(xiàn)畫(huà)面:
Every 2.0s: ntpq -p                                                                                                             Thu Jul 10 02:28:32 2008
     remote           refid      st t when poll reach   delay   offset jitter
==============================================================================
192.168.30.22   LOCAL(0)         8 u   22   64    1    2.113 179133.   0.001
LOCAL(0)        LOCAL(0)        10 l   21   64    1    0.000   0.000  0.001
注意LOCAL的這個(gè)就是與自身同步的ntp server。
注意reach這個(gè)值,在啟動(dòng)ntp server服務(wù)后,這個(gè)值就從0開(kāi)始不斷增加,當(dāng)增加到17的時(shí)候,從0到17是5次的變更,每一次是poll的值的秒數(shù),是64秒*5=320秒的時(shí)間。
如果之后從ntp客戶端同步ntp server還失敗的話,用ntpdate –d來(lái)查詢?cè)敿?xì)錯(cuò)誤信息,再做判斷。
錯(cuò)誤2.Server dropped: no data
從客戶端執(zhí)行netdate –d時(shí)有錯(cuò)誤信息如下:
transmit(192.168.30.22) transmit(192.168.30.22)
transmit(192.168.30.22)
transmit(192.168.30.22)
transmit(192.168.30.22)
192.168.30.22: Server dropped: no data
server 192.168.30.22, port 123
.....
28 Jul 17:42:24 ntpdate[14148]: no server suitable for synchronization found出現(xiàn)這個(gè)問(wèn)題的原因可能有2:
1。檢查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定義中使用了notrust的話,會(huì)導(dǎo)致以上錯(cuò)誤。
使用以下命令檢查ntp的版本:
# ntpq -c version
下面是來(lái)自ntp官方網(wǎng)站的說(shuō)明:
The behavior of notrust changed between versions 4.1 and 4.2.
In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
In 4.2 (and later) notrust means "Ignore all NTP packets that are not cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd
解決:
把notrust去掉。
2。檢查ntp server的防火墻??赡苁莝erver的防火墻屏蔽了upd 123端口。
可以用命令
#service iptables stop

來(lái)關(guān)掉iptables服務(wù)后再嘗試從ntp客戶端的同步,如果成功,證明是防火墻的問(wèn)題,需要更改iptables的設(shè)置。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多