centos 7 搭建ntp 服務器

restrict 192.168.1.0 netmask 255.255.255.0 nomodify notrap

第一步 安裝ntp

yum install ntp

第二步,查找最近的時間同步服務器

http://www.pool.ntp.org/zone/asia

第三部編輯 /etc/ntp.conf

server  127.127.1.0  iburst   # local clock 當外部時間服務器不可用的時候,使用本機時間作爲時間服務的標準
fudge 127.127.1.0 stratum 10 #這個值不能太高0-15,太高會報錯


第四步

添加允許訪問的ip 段

restrict 192.168.1.0 netmask 255.255.255.0 nomodify notrap


第五步 配置防火牆

firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload



第六步 啓動ntp 服務

systemctl enable ntpd  開機啓動

systemctl start ntpd

sytemctl status ntpd


第七步 驗證服務

ntpq -p



date -R



第八步

同步遠程時間服務

ntpdate -q  0.ro.pool.ntp.org  1.ro.pool.ntp.org


第九步 在客戶端機器同步時間

ntpdate -d -b 192.168.85.20



可能遇到的問題

1 centos stratum 0, precision 0, leap 00, trust 000 no server suitable for synchronization found

這個問題是由於防火牆擋住了ntp 端口,使用上買你的firewall-cmd 命令解決


2 stratum  too high 的問題

在/etc/ntp.conf 中 修改 stratum 的值


NTP開機無法啓動的解決方法

這個問題往往是由於npt 服務的123 端口被其他服務佔用引起,這個佔用服務一般是chronyd

禁用這個服務即可

systemctl disable chronyd




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章