CentOS7安裝配置時間服務器Chrony詳解


開放 NTP 客戶端訪問

修改 /etc/chrony.conf 文件,添加配置如下:

# Allow NTP client access from local network.
allow 172.25/16

重啟 chronyd

修改完配置文件后,重新啟動時間服務器。

# systemctl restart chronyd
# systemctl enable chronyd

設置防火牆

開放 NTP 協議的 123 端口。

可參考 CentOS 7.2 防火牆配置。

# firewall-cmd --permanent --add-port=123/udp
# firewall-cmd --reload

客戶端測試

編輯 /etc/chrony.conf 文件,根據實際環境修改或添加以下的關鍵行:

server ntp_server iburst

使用主機名或者 IP 地址代替上文中的 ntp_server 服務器,重啟 chronyd 服務:

# systemctl restart chronyd
# systemctl enable chronyd

使用 chronyc sources -v 命令測試 NTP 服務器:

[root@foundation3 ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.25.254.250               10   6    17     9  -5574ns[  -24us] +/-  216us

看到 * 符號就代表客戶端已經正常與時間服務器進行時間同步。

附上:CentOS6安裝配置Chrony

# yum install -y chrony  #安裝軟件
# rpm -ql chrony         #查看安裝的文件

# vim /etc/chrony.conf       #修改配置文件
server ntp_server iburst     #添加此行

# /etc/init.d/chronyd start  #啟動服務
# chkconfig chronyd on       #設置開機啟動

# chronyc sources -v         #查看同步狀態

# chkconfig --help  #獲取命令幫助
# chkconfig --list  #查看所有服務開機啟動狀態
# chkconfig --list chronyd   #查看具體服務是否開機啟動

# getenforce    #查看selinux設置
# setenforce 0  #臨時修改
# vim /etc/selinux/config    #修改配置文件,永久生效
SELINUX=permissive


免責聲明!

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



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