日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

离线NTP服务器搭建(Linux)

發(fā)布時(shí)間:2023/12/20 linux 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 离线NTP服务器搭建(Linux) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

離線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

rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm rpm -ivh ntpdate-4.2.6p5-25.el7.centos.2.x86_64.rpm rpm -ivh ntp-4.2.6p5-25.el7.centos.2.x86_64.rpm

3. 設(shè)置服務(wù)器時(shí)間
查看當(dāng)前時(shí)區(qū)

timedatectl

如果不是預(yù)期的時(shí)區(qū),繼續(xù)執(zhí)行以下步驟
查看時(shí)區(qū)完整名稱

timedatectl list-timezones | grep Shanghai

設(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é)果

date

4. 修改/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 monitor

5. 停止ntpd時(shí)鐘服務(wù)

service ntpd stop

6. 設(shè)置不與網(wǎng)絡(luò)服務(wù)同步

timedatectl set-ntp no

7. 開啟ntp服務(wù)

service ntpd start

8. 查看ntp服務(wù)狀態(tài)

service ntpd status

9. 設(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 monitor

10. 連接NTP服務(wù)器同步時(shí)間

ntpdate 192.168.111.143

11. 開啟ntp服務(wù)

service ntpd start

12. 設(shè)置開機(jī)自啟動(dòng)

systemctl enable ntpd

13. 結(jié)果檢查

timedatectl

14. 查看客戶端的時(shí)間和時(shí)區(qū)是否和服務(wù)端保持一致,NTP 同步是否開啟

watch ntpq -p chkconfig --level 35 ntpd on

總結(jié)

以上是生活随笔為你收集整理的离线NTP服务器搭建(Linux)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。