centos 7 時間同步使用的是chrony工具
1、檢測chrony包是否安裝
[root@martin ~]# rpm -qa|grep chrony
2、安裝chrony
[root@martin ~]# yum install chrony -y
3、啟動chrony並查看其狀態
[root@martin ~]# systemctl start chronyd
[root@martin ~]# systemctl status chronyd
4、查看系統時間
[root@martin ~]# timedatectl
Local time: Mon 2018-05-14 09:55:13 CST Universal time: Mon 2018-05-14 01:55:13 UTC RTC time: Mon 2018-05-14 01:55:14 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a
timedatectl status 顯示當前時間信息
set-time 設定當前時間
set-timezone 設定當前時區(Asia/Shanghai)
set-local-rtc 設定bios時間
5、設置亞洲時區
timedatectl set-timezone Asia/Shanghai
6、啟用NTP同步
timedatectl set-ntp yes
7、同步時間
[root@martin ~]# chronyc makestep
200 OK
8、查看時間同步的信息來源
[root@localhost ~]# chronyc sources 210 Number of sources = 4 MS Name/IP address Stratum Poll Reach LastRx Last sample ===============================================================================
^+ 119.79-161-57.customer.l> 2 6 77 34 -10ms[ -10ms] +/- 210ms ^+ makaki.miuku.net 2 6 77 34 -8951us[-8951us] +/- 210ms ^+ cn.ntp.faelix.net 2 6 77 35 -8692us[-8692us] +/- 111ms ^* ntp7.flashdance.cx 2 6 77 36 +40ms[ +13ms] +/- 188ms
9、Chrony的配置文件在/etc/chrony.conf
server ntp1.aliyun.com
server time1.aliyun.com