【轉】Linux配置NTP時間同步服務器


分布式程序通常需要運行在一個統一的時間環境里。

轉自:http://blog.csdn.net/mengfanzhundsc/article/details/62046562

安裝NTP:
yum install ntp

配置時間源
vi /etc/ntp.conf
server 210.72.145.44
server ntp.api.bz
server 2.centos.pool.ntp.org

配置對客戶端(172.16.0.0/24的網段機器)提供NTP服務
# vi /etc/ntp.conf
restrict 172.16.0.0 mask 255.255.255.0 nomodify notrap


配置NTP Server的層數提供本地服務
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 2

設置開機時自動運行時間服務
chkconfig ntpd on

啟動或停止時間服務
# service ntpd start
# service ntpd stop
# service ntpd restart

驗證ntp服務已經運行
pgrep ntpd

更新本服務器的時間
ntpdate -u 210.72.145.44

配置iptable規則允許客戶端訪問本機NTP Sever
vi /etc/sysconfig/iptables
增加一行(NTP Server使用UDP 123端口)
-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

重啟iptables
service iptables restart


免責聲明!

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



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