1、简单介绍

在最新的Linux中,已经将ntpdate抛弃,转向了chrony,本篇就对这个新的chrony时间服务进行简单的演示操作

2、服务安装

2.1、安装服务

安装命令无脑install即可

apt install chrony

2.2、参数配置

安装完成之后,会有默认的时间服务器地址,但是由于你懂的,所以我们要更换一下,方法如下:
依次执行下面的命令即可

sed -i 's@server@#server@g' /etc/chrony.conf
echo -e "server ntpupdate.tencentyun.com iburst" >> /etc/chrony.conf

由于我的本身就是腾讯云的时间服务器,所以就不改了,配置如下:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# servers
server ntpupdate.tencentyun.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

# 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

3、开始同步

3.1、设置时区

timedatectl set-timezone Asia/Shanghai

3.2、开启ntp同步

timedatectl set-ntp yes

3.3、开始同步

先重启服务

systemctl restart chrony

然后同步

chronyc sources

过程:

root@l:/data/liu/git/zgj_toutiao# systemctl restart chrony
root@l:/data/liu/git/zgj_toutiao# chronyc sources
210 Number of sources = 5
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? 169.254.0.79                  2   6     1     2    -26us[  -26us] +/-   22ms
^? 169.254.0.80                  2   6     1     1  +1309ns[+1309ns] +/-   26ms
^? 169.254.0.81                  2   6     1     1   -103us[ -103us] +/-   28ms
^? 169.254.0.82                  2   6     1     1    +62us[  +62us] +/-   39ms
^? 169.254.0.83                  2   6     1     1   -356us[ -356us] +/-   37ms
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐