時間同步服務器操作方法


時間同步服務器操作方法

方法一:NTP時間同步
NTP基於UDP報文進行傳輸,使用的UDP端口號為123
一、服務端:
假設ip是192.168.100.100
1、安裝ntp
外網:sudo apt install ntp (內網拷貝離線包安裝)
2、修改配置文件:vim /etc/ntp.conf
注釋默認的時間同步源
#pool 127.0.0.1 iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst
增加以下2行
server 127.127.1.0
fudge 127.127.1.0 stratum 8
修改后,保存退出
3、啟動服務並設置服務開機自啟
systemctl start ntp && systemctl enable ntp
4、查看偵聽端口
netstat -tunlp | grep ntp 或者ss -ntulp | grep ntp 一般是在123端口
timedatectl 查看當前機器時間
ip a 查看服務端ip
二、客戶端
客戶端需要安裝ntpdate的包,輸入 ntpdate serverip(服務端配置ntp的ip地址)去同步時間
結果顯示類似: 18 Aug 16:04:24 ntpdate[30646]: step time server 10.20.xx.xx offset 47606319.594686 sec
PS:
1、如果上述操作不成功,可以 ntpdate -d 192.168.100.100 查看報錯詳情,然后再去ntpdate 服務端ip 同步時間
2、ntp客戶端用ntpdate -d serverip查看,發現有192.168.100.100: Server dropped: strata too high
的錯誤,這是因為ntp server還沒有和其自身或者它的server同步上。可以用ntptrace 和ntpd -s -d 命令,再去ntpdate serverip即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM