centos7 时间同步服务部署

查看日期时间、时区及 NTP 状态

timedatectl

Centos7 默认使用 chrony 作为时间同步服务

#修改配置文件
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

# 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 10.0.0.0/8

# 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.service

其他内网客户端把同步服务器改为此服务器即可

参考命令


#校准时间服务器
chronyc tracking


#查看时间同步源
chronyc sources -v


#在客户端报告已访问到服务器
chronyc clients 

#查看 ntp server 是否在线
chronyc activity -v