[原]CentOS 7 chrony 笔记

~]# timedatectl  status
      Local time: Sun 2018-08-26 21:01:15 CST        ==> 本地系统实际时间,设置时间timedatectl set-time 15:58:30
                                                                           设置日期timedatectl set-time 20151120
                                                                           设置时间日期timedatectl set-time '16:10:40 2015-11-20'
      Universal time: Sun 2018-08-26 13:01:15 UTC    ==> 世界统一时间
      RTC time: Sun 2018-08-26 13:01:15              ==> 硬件时钟的时间
      Time zone: Asia/Shanghai (CST, +0800)          ==> 当前时区,查看可用时区timedatectl list-timezones
                                                                   设置当前时区timedatectl set-timezone "Asia/Shanghai"
                                                                   设置世界统一时区timedatectl set-timezone UTC
      NTP enabled: yes                               ==> 开启自动同步时间服务器功能,timedatectl set-ntp true 或 timedatectl set-ntp false
      NTP synchronized: yes                          ==> 与时间服务器的同步状态,若是显示yes,则同步成功
      RTC in local TZ: no                            ==> 将时区设置为本地时区,timedatectl set-local-rtc 1
                                                         硬件时钟设置为协调世界时(UTC)timedatectl set-local-rtc 0
      DST active: n/a



[root@network ~]# 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               
===============================================================================
^? controller                    9   6    37    47   +123us[ +123us] +/-   25ms           ==>若是前面是有个?代表时间服务器不可达 

若是一直显示为? 表示网络没有设置正确,须要设置配置文件中的网络
server : 10.50.10.10
client : 10.50.10.20
编辑 /etc/chrony.conf

【client】linux

# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 10.50.10.0/16服务器

【server】网络

# Allow NTP client access from local network.
#allow 192.168.0.0/16
allow 10.50.10.20/24spa

再从新检查是否能够同步code

[root@network ~]# 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               
===============================================================================
^* controller                    9   6   177    46    +19us[  -65us] +/-   36ms         ==>若是前面是有个*代表时间服务器可同步








经常使用的命令:
启动chronyd进程
systemctl start chronyd.service
强制单次进行时间同步  
chronyd -q 'server <时间服务器域名> iburst'
或者
ntpdate <ntp_server_name>
## 查看 ntp服务器是否能够正常同步
ntpdate -d <ntp_server_name>
## 查看 ntp_servers 状态
chronyc sources -v
## 查看 ntp_sync 状态
chronyc sourcestats -v
## 查看 ntp_servers 是否在线
chronyc activity -v
## 查看 ntp 详细信息
chronyc tracking -v







当执行ntpdate -d <ntp_server_name>出现 NTP. Server dropped: strata too high  
可能缘由是时间服务器stratum 值太高  调低就能够了  好比server为 8   client为9  则正常
当执行ntpdate -d <ntp_server_name>出现Server dropped: no data  
可能缘由能够使用journalctl -xe 来查看,多是selinux没有关闭 能够在/etc/selinux/conf中disable
相关文章
相关标签/搜索