[[email protected] ~]# timedatectl Local time: Sat 2017-10-07 10:55:22 CST Universal time: Sat 2017-10-07 02:55:22 UTC RTC time: Sat 2017-10-07 02:55:22 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no
NTP synchronized: yes RTC in local TZ: no DST active: n/a
[[email protected] ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* rhel1.rusky.com 10 7 377 22m -3603ns[ -19us] +/- 32us
[[email protected] ~]# 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
===============================================================================
^* rhel1.rusky.com 10 7 377 22m -3603ns[ -19us] +/- 32us
[[email protected] ~]#
客户端时间同步配置:
1.yum install chrony –y
2.修改配置文件
[[email protected] ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org iburst --注释这4行
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 192.168.100.1 iburst ---添加该行,表示到这台服务器去同步时间。
[[email protected] ~]# timedatectl Local time: Sat 2017-10-07 11:15:43 CST Universal time: Sat 2017-10-07 03:15:43 UTC RTC time: Sat 2017-10-07 03:02:26 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no
NTP synchronized: yes --为yes表示已同步 RTC in local TZ: no DST active: n/a
重启chronyd服务后,需要过几分钟才会自动完成同步。
如果需要手动,可使用下面的命令:
#ntpdate 192.168.100.1
============================
问题:????
[[email protected] ~]# date
Sun Oct 8 11:00:51 CST 2017
[[email protected] ~]# timedatectl Local time: Sat 2017-10-07 11:31:45 CST Universal time: Sat 2017-10-07 03:31:45 UTC RTC time: Sun 2017-10-08 03:01:57 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no
NTP synchronized: no RTC in local TZ: no DST active: n/a
如果把NTP enabled 修改为yes时,则手动修改时间失败。
如果为No时,则可以手动修改时间,这是什么原因呢???
[[email protected] ~]# timedatectl set-ntp yes
[[email protected] ~]# timedatectl set-time "2017-10-08 11:00:50"
Failed to set time: Automatic time synchronization is enabled
[[email protected] ~]# timedatectl set-ntp no
[[email protected] ~]# timedatectl set-time "2017-10-08 11:00:50"
[[email protected] ~]# date
Sun Oct 8 11:00:51 CST 2017