ntp時間同步
阿新 • • 發佈:2020-12-28
技術標籤:ntp
ntp時間同步
時間同步的作用
- NTP (Network Time Protocol,網路時間協議)是用來使計算機時間同步的一種協議。它可以使計算機對其伺服器或時鐘源做同步化,它可以提供高精準度的時間校正(LAN上與標準間差小於1毫秒,WAN上幾十毫秒)。對於伺服器群集來說,這個是一個很重要的服務,因為群集需要保證每個伺服器的時間是保持一致的,這樣它們在執行同一個任務時才不會出現有的伺服器有滯後的現象,這樣群集的狀態才是健康的。
- NTP的工作模式:C/S模式
- NTP的協議及埠號:UDP協議123號埠
ntp時間同步的配置
伺服器配置
yum -y install ntpdate
yum -y install ntp
vim /etc/ntp.conf restrict default nomodify #第8行 restrict 192.168.17.0 mask 255.255.255.0 nomodify notrap #第17行 #server 0.centos.pool.ntp.org iburst #第21到第24行刪除,或註釋掉 #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst fudge 127.127.1.0 stratum 8 #新增內容 server 127.127.1.0 #新增內容
systemctl start ntpd
crontab -e
* * * * * /usr/sbin/ntpdate ntp.aliyun.com
客戶端配置
yum -y install ntpdate
ntpdate 192.168.17.10
crontab -e
* * * * * /usr/sbin/ntpdate 192.168.17.10
效果驗證