运维开发网

DevOps-chrony服务

运维开发网 https://www.qedev.com 2020-09-14 12:21 出处:51CTO 作者:779699413
chrony服务

DevOps-chrony服务

1、介绍

Chrony是一个开源的自由软件,在RHEL 7操作系统,已经是默认服务,默认配置文件在 /etc/chrony.conf 它能保持系统时间与时间服务器(NTP)同步,让时间始终保持同步。相对NTP时间同步软件,速度更快、配置和依赖都更简单。

chronyd:是守护进程,主要用于调整内核中运行的系统时间和时间服务器同步。它确定计算机增减时间的比率,并对此进行调整补偿。

chronyc:提供一个用户界面,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可以在一台不同的远程计算机上工作。

端口号:ntp(123udp端口)和chrony(323udp端口)

2、安装

# yum install -y chrony 
# systemctl start  chronyd
# systemctl enable chronyd
# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-09-13 20:33:29 CST; 6min ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 41130 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 41126 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/chronyd.service
           └─41128 /usr/sbin/chronyd

Sep 13 20:33:29 localhost.localdomain systemd[1]: Starting NTP client/server...
Sep 13 20:33:29 localhost.localdomain chronyd[41128]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Sep 13 20:33:29 localhost.localdomain chronyd[41128]: Frequency 21.709 +/- 72.376 ppm read from /var/lib/chrony/drift
Sep 13 20:33:29 localhost.localdomain systemd[1]: Permission denied while opening PID file or unsafe symlink chain: /var/run/chrony/chronyd.pid
Sep 13 20:33:29 localhost.localdomain systemd[1]: Started NTP client/server.
Sep 13 20:33:34 localhost.localdomain chronyd[41128]: Selected source 120.25.115.20
Sep 13 20:34:41 localhost.localdomain chronyd[41128]: Selected source 203.107.6.88
Sep 13 20:35:47 localhost.localdomain chronyd[41128]: Selected source 120.25.115.20

3、配置

# vim /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.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
#同步的ntp服务器
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
server ntp5.aliyun.com iburst
server ntp6.aliyun.com iburst
server ntp7.aliyun.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

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

# Allow NTP client access from local network.
#allow 192.168.0.0/16
#允许同步的网段
allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

# systemctl restart  chronyd
# chronyc sources -v
210 Number of sources = 2

  .-- 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               
===============================================================================
^* 120.25.115.20                 2   6   377    12  +1411us[+1671us] +/-   17ms
^- 203.107.6.88                  2   6   377    11  -7999us[-7999us] +/-   36ms

4、优化

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号