1. 程式人生 > 實用技巧 >CentOS 7時間同步(NTP)

CentOS 7時間同步(NTP)

begin 2020年7月5日10:55:03

NTP簡介(What)

網路時間協議(英語:Network Time Protocol,縮寫:NTP)是在資料網路潛伏時間可變的計算機系統之間通過分組交換進行時鐘同步的一個網路協議,位於OSI模型的應用層。

明明說:時間同步協議

NTP的作用(Why)

NTP的作用是為了所有參與計算機的協調世界時(UTC)時間同步到幾毫秒的誤差內。

明明說:小時候家裡會報點的老鍾,跑了一段時間後就會慢幾分鐘,然後對著電視裡校準。類似地,現在所有的計算機、手機都會跟時鐘伺服器同步,給我們提供更準確的時間。

CentOS基於NTP的時間同步(How)

1、安裝ntp:

yum install ntp

2、修改/etc/ntp.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

# new(新增)
server ntp1.aliyun.com prefer
server ntp2.aliyun.com

# old(原有)
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

3、時間同步

手工發起同步:

ntpdate ntp1.aliyun.com

date檢視時間是否已經同步

啟動NTP服務:

service ntpd start

設定開機啟動:

chkconfig ntpd on

end 2020年7月5日11:33:50