本文主要針對服務器在內網,沒法與外界取得鏈接的場景配置NTP服務,須要有一臺機器能與外網取得聯繫,其餘服務與該外網服務鏈接html
NTP服務器【Network Time Protocol(NTP)】是用來使計算機時間同步化的一種協議,它能夠使計算機對其服務器或時鐘源(如石英鐘,GPS等等)作同步化,它能夠提供高精準度的時間校訂(LAN上與標準間差小於1毫秒,WAN上幾十毫秒),且可介由加密確認的方式來防止惡毒的協議攻擊。時間按NTP服務器的等級傳播。按照離外部UTC源的遠近把全部服務器納入不一樣的Stratum(層)中。
時鐘服務器爲樹狀結構,頂層是由國家(國際)受權時中心提供,逐層向下擴展
(1)NTP軟件包安裝:yum install ntp
若是網絡不通,須要經過代理或下載rpm文件包進行安裝
(2)配置文件路徑:/etc/ntp.conf
(3)內網服務設置
1.內網NTP服務:centos
Use public servers from the pool.ntp.org project. Please consider joining the pool (http://www.pool.ntp.org/join.html). 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
經過鏈接能夠PING通的時鐘服務獲取時鐘信息,查看是否能夠連通服務器
service ntpd stop 0.centos.pool.ntp.org service ntpd start
2.內網其餘服務:
須要NTP服務容許指定網段訪問網絡
restrict 127.0.0.1 restrict ::1 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
主要配置與NTP服務關聯tcp
Please consider joining the pool (http://www.pool.ntp.org/join.html). server 192.168.1.93 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
(4)查看端口監聽:netstat -anptu|grep 123,判斷NTP服務是否啓動ide
tcp 0 0 0.0.0.0:9123 0.0.0.0:* LISTEN 16350/haproxy udp 0 0 192.168.1.93:123 0.0.0.0:* 1359/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 1359/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 1359/ntpd udp6 0 0 fe80::f816:3eff:fee:123 :::* 1359/ntpd udp6 0 0 ::1:123 :::* 1359/ntpd udp6 0 0 :::123 :::* 1359/ntpd
(5)啓動:加密
service ntpd start(stop,restart同理)
(6)設置開機啓動:spa
chkconfig ntpd on
(7)幾分鐘後指令ntpstat顯示與NTP服務鏈接信息3d