chrony配置的和相關命令


動態查看時間的命令

watch -n 1 "date +%T"

ntp命令

查看時間同步源:

$ chronyc sources -v

查看時間同步源狀態:

$ chronyc sourcestats -v

設置硬件時間

硬件時間默認為UTC:

$ timedatectl set-local-rtc 1

啟用NTP時間同步:

$ timedatectl set-ntp yes

校准時間服務器:

$ chronyc tracking

timedatectl set-time "YYYY-MM-DD HH:MM:SS" //設置時間和日期

 

 

chrony.conf配置文件內容介紹

$ cat /etc/chrony.conf

# 使用pool.ntp.org項目中的公共服務器。以server開,理論上你想添加多少時間服務器都可以。
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

# 根據實際時間計算出服務器增減時間的比率,然后記錄到一個文件中,在系統重啟后為系統做出最佳時間補償調整。
driftfile /var/lib/chrony/drift

# chronyd根據需求減慢或加速時間調整,
# 在某些情況下系統時鍾可能漂移過快,導致時間調整用時過長。
# 該指令強制chronyd調整時期,大於某個閥值時步進調整系統時鍾。
# 只有在因chronyd啟動時間超過指定的限制時(可使用負值來禁用限制)沒有更多時鍾更新時才生效。
makestep 1.0 3

# 將啟用一個內核模式,在該模式中,系統時間每11分鍾會拷貝到實時時鍾(RTC)。
rtcsync

# Enable hardware timestamping on all interfaces that support it.
# 通過使用hwtimestamp指令啟用硬件時間戳
#hwtimestamp eth0
#hwtimestamp eth1
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# 指定一台主機、子網,或者網絡以允許或拒絕NTP連接到扮演時鍾服務器的機器
#allow 192.168.0.0/16
#deny 192.168/16

#即使自己未能通過網絡時間服務器同步到時間,也允許將本地時間作為標准時間授時給其它客戶端(內網環境下一定要注釋此項); # Serve time even if not synchronized to a time source. local stratum 10 # 指定包含NTP驗證密鑰的文件。 #keyfile /etc/chrony.keys # 指定日志文件的目錄,經過我多次測試在centos7上,實際上這個目錄是空的,不知道為啥,請各位大神留言交流一下。 logdir /var/log/chrony # Select which information is logged. #log measurements statistics tracking


免責聲明!

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



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