Linux時間同步

                  ####時間同步####

1.服務端
yum install chrony -y   ##安裝服務

vim /etc/chrony.conf    ##主配置文件
21 # Allow NTP client access from local network.
22 allow 172.25.0.0/24  ##允許誰去同步我的時間
27 # Serve time even if not synchronized to any NTP server.
28 local stratum 10 ##不去同步任何人的時間,時間同步服務器級別

systemctl restart chronyd
systemctl stop firewalld

2.客戶端
vim /etc/chrony.conf
  3 server 0.rhel.pool.ntp.orgiburst
  4 server 1.rhel.pool.ntp.orgiburst====> server ntpserverip iburst
  5 server 2.rhel.pool.ntp.org iburst====>
  6 server 3.rhel.pool.ntp.orgiburst

systemctl restart chronyd

測試:
[root@localhost ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = localclock.
 / .- Source state '*' = current synced,'+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time maybe in error, '~' = time too variable.
||                                                .- xxxx [ yyyy ] +/- zzzz
||                                               /   xxxx = adjusted offset,
||         Log2(Polling interval) -.             |    yyyy = measured offset,
||                                 \            |    zzzz = estimated error.
||                                  |           |                        
MS Name/IP address         Stratum PollReach LastRx Last sample
===============================================================================
^* 172.25.0.11                  10   6  377    41   +170us[ +201us] +/-  191us



####5.timedatectl命令####
timedatectl     status          ##顯示當前時間信息
            set-time        ##設定當前時間
            set-timezone        ##設定當前時區
            set-local-rtc 0|1   ##設定是否使用utc時間
           
 

wKioL1jCjyODJK8HAARt3guTdNU243.png-wh_50

wKiom1jCjyXScgBjAASlxYmgp3A753.png-wh_50

wKioL1jCjyeCHaDmAAQ_bH3e_FY184.png-wh_50


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