离线NTP服务器搭建(Linux)
離線NTP服務(wù)器搭建(Linux)
如果沒能幫你解決問題,請(qǐng)?jiān)谙路搅粞?/p>
實(shí)例:
服務(wù)端-192.168.111.143
客戶端-192.168.111.170
1. 獲取rpm包
解壓操作系統(tǒng)的鏡像文件,獲取rpm包
.\CentOS-7.4-x86_64-DVD-1708\Packages
2. 安裝rpm
3. 設(shè)置服務(wù)器時(shí)間
查看當(dāng)前時(shí)區(qū)
如果不是預(yù)期的時(shí)區(qū),繼續(xù)執(zhí)行以下步驟
查看時(shí)區(qū)完整名稱
設(shè)置服務(wù)器的時(shí)區(qū)為香港時(shí)區(qū)
timedatectl set-timezone Asia/Hong_Kong手動(dòng)配置當(dāng)前時(shí)間
timedatectl set-time "2019-07-17 14:45:10"寫入硬件時(shí)鐘
hwclock --hctosys重啟
reboot查看配置結(jié)果
date4. 修改/etc/ntp.conf文件
服務(wù)端:
rm -rf /etc/ntp.conf vi /etc/ntp.conf將以下內(nèi)容寫進(jìn)文件
#系統(tǒng)時(shí)間與BIOS事件的偏差記錄 driftfile /var/lib/ntp/drift #允許任何主機(jī)進(jìn)行時(shí)間同步 restrict default ignore #確保服務(wù)器本身有足夠權(quán)限 restrict 127.0.0.1 restrict ::1 #授權(quán)192.168.0.0網(wǎng)段上的所有機(jī)器可以從這臺(tái)機(jī)器上查詢和同步時(shí)間. restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap server 192.168.111.143 iburst #當(dāng)外部時(shí)間不可用時(shí),使用本地時(shí)間. server 127.127.1.0 fudge 127.127.1.0 stratum 10 interface ignore wildcard interface listen 192.168.111.143 interface listen 127.0.0.1 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys disable monitor5. 停止ntpd時(shí)鐘服務(wù)
service ntpd stop6. 設(shè)置不與網(wǎng)絡(luò)服務(wù)同步
timedatectl set-ntp no7. 開啟ntp服務(wù)
service ntpd start8. 查看ntp服務(wù)狀態(tài)
service ntpd status9. 設(shè)置開機(jī)自啟動(dòng)
systemctl enable ntpd客戶端:
rm -rf /etc/ntp.conf vi /etc/ntp.conf driftfile /var/lib/ntp/drift restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 restrict ::1 server 192.168.111.143 iburst restrict 192.168.111.143 nomodify notrap noquery server 127.127.1.0 fudge 127.127.1.0 stratum 10 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys disable monitor10. 連接NTP服務(wù)器同步時(shí)間
ntpdate 192.168.111.14311. 開啟ntp服務(wù)
service ntpd start12. 設(shè)置開機(jī)自啟動(dòng)
systemctl enable ntpd13. 結(jié)果檢查
timedatectl14. 查看客戶端的時(shí)間和時(shí)區(qū)是否和服務(wù)端保持一致,NTP 同步是否開啟
watch ntpq -p chkconfig --level 35 ntpd on總結(jié)
以上是生活随笔為你收集整理的离线NTP服务器搭建(Linux)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: W3C验证工具
- 下一篇: 金山快盘 linux,WPS移动版5.5