




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、NTP server and client一、 NTP服務(wù)原理NTP協(xié)議是通過Server和Client的方式進行的,通訊的過程是:1、主機需要啟動這個NTP服務(wù)2、Client會向NTP Server發(fā)送出調(diào)校時間的message3、然后NTP Server會送出目前的標(biāo)準(zhǔn)時間給Client4、Client接收了來自Server的時間后,會據(jù)以調(diào)整自己的時間,以實現(xiàn)網(wǎng)絡(luò)校時。二、安裝NTP服務(wù)在安裝了Centos6、Centos7的系統(tǒng)上,先關(guān)閉防火墻Centos6:關(guān)閉: #service iptables stop 關(guān)閉:#chkconfig iptables off
2、0; Centos7:關(guān)閉:# systemctl stop firewalld 關(guān)閉:systemctl disable firewalld.service# yum -y install iptables-services 關(guān)閉:systemctl disable iptables.service 關(guān)閉:systemctl stop iptables.service NTP可以使用yum直接安裝# yum install -y ntp三、時區(qū)、時間/usr/share/zoneinfo/ 這個目錄下存放的是各個時區(qū)對應(yīng)的設(shè)定文件。/etc/l
3、ocaltime 本地系統(tǒng)時間設(shè)定文件。/etc/sysconfig/clock 本機時區(qū)設(shè)定文件。相關(guān)命令:date 修改和顯示日期和時間的命令。hwclock 將當(dāng)前系統(tǒng)時間寫入CMOS的命令,只有root用戶才可以使用。以系統(tǒng)時間為基準(zhǔn),修改硬件時間# hwclock systohc sys(系統(tǒng)時間)to(寫到)hc(Hard Clock)# hwclock -wntpd NTP服務(wù)的守護進程文件,需要先啟動它才能提供NTP服務(wù)。ntpdate
4、 客戶端時間同步四、 NTP配置說明NTP的配置文件/etc/ntp.conf默認(rèn)配置內(nèi)容為:# For more information about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not# pe
5、rmit the source to query or modify the service on this system.restrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrat
6、ive functions.restrict restrict -6 :1# Hosts on local network are less restricted.#restrict mask nomodify notrap# Use public servers from the project.# Please consider joining the pool (/join.html).server 0. ib
7、urstserver 1. iburstserver 2. iburstserver 3. iburst#broadcast 55 autokey # broadcast server#broadcastclient # broadcast client#broadcast autokey # multicast server#multicastclient # multicast client#manycastserv
8、er 54 # manycast server#manycastclient 54 autokey # manycast client# Enable public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography. keys /etc/ntp/keys# Specify the
9、key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statistics clockstats cryptostats loopstats peerstats1)、權(quán)限的設(shè)定主要以
10、restrict 這個參數(shù)來設(shè)定,主要的語法為:restrict IP地址 mask 子網(wǎng)掩碼 參數(shù)其中 IP 可以是IP地址,也可以是 default ,default 就是指所有的IP參數(shù)有以下幾個:ignore :關(guān)閉所有的 NTP 聯(lián)機服務(wù)nomodify:客戶端不能更改服務(wù)端的時間參數(shù),但是客戶端可以通過服務(wù)端進行網(wǎng)絡(luò)校時。notrust :客戶端除非通過認(rèn)證,否則該客戶端來源將被視為不信任子網(wǎng)noquery :不提供客戶端的時間查詢 2)、用server這個參數(shù)設(shè)定上級時間服務(wù)器,語法為:server IP地址或域名 preferIP地址或域名就是我們指定的上
11、級時間服務(wù)器,如果 Server 參數(shù)最后加上 prefer,表示我們的 NTP 服務(wù)器主要以該部主機時間進行校準(zhǔn)。3)、解決NTP服務(wù)器校準(zhǔn)時間時的傳送延遲使用driftfile參數(shù)設(shè)置:driftfile 文件名 在與上級時間服務(wù)器聯(lián)系時所花費的時間,記錄在driftfile參數(shù)后面的文件內(nèi)。注意: driftfile 后面接的文件需要使用完整的路徑文件名,不能是鏈接文件,并且文件的權(quán)限需要設(shè)定成 ntpd守護進程可以寫入。# vi /etc/ntp.conf#=權(quán)限控制=restrict default kod nomodify notrap nopeer noqu
12、ery 拒絕IPV4用戶restrict -6 default kod nomodify notrap nopeer noquery 拒絕IPV6用戶restrict 4 授權(quán)國家授時中心服務(wù)器訪問本地NTP restrict 授權(quán)訪問本地NTPrestrict restrict -6 :1restrict ma
13、sk nomodify 本地網(wǎng)段授權(quán)訪問restrict default nomodify notrap 允許所有ip,省去設(shè)置麻煩 #=源服務(wù)器=server 4 prefer 指定上級更新時間服務(wù)器,優(yōu)先使用這個地址server #=差異分析=driftfile /var/lib/ntp/driftkeys /etc/ntp/keys
14、完整的ntp.conf文件(以server為06為例)# For more information about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not# permit the source to query or modi
15、fy the service on this system.restrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict
16、 restrict -6 :1restrict mask nomodify restrict mask nomodifyrestrict mask nomodify restrict mask nomodify restrict mask nomodify restrict mask 255.255.255
17、.0 nomodify restrict mask nomodify restrict mask nomodify restrict mask nomodify restrict mask nomodify restrict mask nomodifyrestrict 4restrict 133.100.
18、11.8restrict default nomodify notrap# Hosts on local network are less restricted.#restrict mask nomodify notrap# Use public servers from the project.# Please consider joining the pool (/join.html).server 4 preferserver 133.100.
19、11.8server 0. iburstserver 1. iburstserver 2. iburstserver 3. iburst#broadcast 55 autokey# broadcast server#broadcastclient# broadcast client#broadcast autokey# multicast server#multicastclient
20、# multicast client#manycastserver 54# manycast server#manycastclient 54 autokey # manycast client# Enable public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography. dr
21、iftfile /var/lib/ntp/driftkeys /etc/ntp/keys# Specify the key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statist
22、ics clockstats cryptostats loopstats peerstats五、 啟動NTP# service ntpd start (針對Centos6系統(tǒng))#systemctl start ntpd.service (針對Centos7系統(tǒng))在ntp server上啟動ntp服務(wù)后,ntp server自身或者與其server的同步的需要一個時間段,這個過程可能是5分鐘,在這個時間之內(nèi)在客戶端運行ntpdate命令進行同步時會產(chǎn)生no server suitable for synchronization found的錯誤。# netst
23、at -tlunp | grep ntp 如果看到123端口,說明ntp服務(wù)成功啟動。# ntpstat 查看ntp服務(wù)器與上級服務(wù)器是否通訊為了使NTP服務(wù)可以在系統(tǒng)引導(dǎo)的時候自動啟動,執(zhí)行:# chkconfig ntpd on (針對Centos6系統(tǒng))# systemctl enable ntpd.service (針對Centos7系統(tǒng))那么如何知道何時ntp server完成了和自身同步的過程呢?在ntp server上使用命令:# watch ntpq p六、 客戶端驗證服
24、務(wù)端時間同步在客戶端使用ntpdate進行更新時間# ntpdate 06剛開始時間被改為2012-01-01,通過時間同步成功。七、 Windows操作系統(tǒng)時間同步對于Windows 操作系統(tǒng),自身已經(jīng)集成了自動對時功能,雙擊系統(tǒng)托盤下方的時間,彈出 日期時間屬性 對話框 .選擇 Internet時間選項卡. 在服務(wù)器地址欄輸入國家授時中心服務(wù)器的IP地址(06),然后點擊“確定”按鈕保存下來就行了。 可以勾選自動同步也可以手動按 立即更新 來同步時間。修
25、改注冊表,提高時間同步精度 由于系統(tǒng)默認(rèn)的時間同步間隔是7天,我們無法自由選擇,使得這個功能在靈活性方面大打折扣。其實,我們也可以通過修改注冊表來手動修改它的自動同步間隔以提高同步精度。 (1)在“開始”菜單“運行”項下輸入“Regedit”進入注冊表編輯器 (2)展開HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient 分支,并雙擊 SpecialPollInterval 鍵值,將對話框中的“基數(shù)欄”選擇到“十進制”上 (3)對話框中顯示的數(shù)字正是自動對時的間隔(以秒為單位),比如默認(rèn)的604800就是由7(天)×
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 企業(yè)社會責(zé)任與戰(zhàn)略考題及答案
- 學(xué)習(xí)使用敏捷工具管理項目進度試題及答案
- 2025借款抵押合同范本
- 2025年高級程序員考試模擬試題及答案
- 軟件工程中重要的建模技術(shù)試題及答案
- 2024年青海省地震局下屬事業(yè)單位真題
- 自行車行業(yè)市場競爭格局演變考核試卷
- 2024年重慶市沙坪壩區(qū)遴選公務(wù)員筆試真題
- 課堂默寫測試題及答案
- 公司戰(zhàn)略實施效果監(jiān)測試題及答案
- 【語文】第23課《“蛟龍”探?!氛n件 2024-2025學(xué)年統(tǒng)編版語文七年級下冊
- 大部分分校:地域文化形考任務(wù)一-國開(CQ)-國開期末復(fù)習(xí)資料
- 2024年江蘇省南通市中考地理試題(含答案)
- 跨文化商務(wù)交際智慧樹知到期末考試答案章節(jié)答案2024年西安工業(yè)大學(xué)
- 《地質(zhì)聚合物混凝土》PPT課件
- 怎樣做融資融券 (1)
- 陜西省市政工程消耗量定額(1)
- 上學(xué)期拓?fù)鋵W(xué)考試試卷及答案
- 輸送帶生產(chǎn)所參考的國際標(biāo)準(zhǔn)
- PPP跟蹤審計方案
- “珠江??漆t(yī)療聯(lián)盟”推進學(xué)科發(fā)展的實踐與創(chuàng)新PPT課件
評論
0/150
提交評論