####時間同步####
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
測試:
[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時間
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL3MTN2UzN4IzNy81ctQzXw12dtMzXtdXLwgHMwUzXodXLn5GcuMDNyUlTkRVdnNDdSFUQIhzSKR0T5p2QqFDTvl2S39CXygzLcVEOvwFMw00LcJDMzZWe39CXvwVbvNmLvR3YxUjL0M3Lc9CX6MHc0RHaiojIsJye.png)