目录

解决服务器时间回跳的问题

解决服务器时间回跳的问题

#需要多执行几次,检查local time和rtc time是否一致,如果不一致就有可能导致时间回跳
timedatectl status
#centos
yum install chrony
systemctl enable chronyd.service
vim /etc/chrony.conf
# 同步使用的端口
acquisitionport 1123

# 存储 Server 时间的本地目录
dumpdir /var/run/chrony

# Ignore stratum in source selection.
stratumweight 0.01

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# 闰秒配置,17h34m 消化 1s
leapsecmode slew
maxslewrate 1000
smoothtime 400 0.001 leaponly

# In first three updates step the system clock instead of slew
# if the adjustment is larger than 10 seconds.
# makestep 0.1 3

## Server config
# Allow NTP client access from local network.
allow 0.0.0.0/0

# Listen for commands only on localhost.
bindaddress 0.0.0.0
port 123
clientloglimit 1073741824
#ratelimit interval 1
#ratelimit burst 16
# Serve time even if not synchronized to any NTP server.
local stratum 5

## Command config
bindcmdaddress 127.0.0.1
bindcmdaddress /var/run/chrony/chronyd.sock
cmdallow all

## Real Time clock(RTC)
hwclockfile /etc/adjtime
rtcautotrim 10
rtcsync

keyfile /etc/chrony.keys

# Specify the key used as password for chronyc.
commandkey 1

# Generate command key if missing.
generatecommandkey

## Log
# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.1
log measurements statistics tracking
logdir /var/log/chrony

# Server 配置
#ip address is the stable clock source which customer provided
server ntp.aliyun.com iburst minpoll 4 maxpoll 6 prefer
#输出内容里的 IP 前边是*代表服务正常,?代表有问题
chronyc sources -v

https://i-blog.csdnimg.cn/blog_migrate/22322e176745ec757dfe0626ba7b24f8.png