如何在信创麒麟V10 ARM64位机器上通过配置chronyd作为ntp服务器来同步系统时间
Contents
一 配置场景说明
某项目采用信创麒麟V10 ARM64位操作系统,服务器分别位于2个网络区域:一部分机器位于可以连接到互联网的区域,另外一部分服务器则无法访问到互联网区服务器。云厂商提供过来的机器系统时间又不对,和北京时间差8个小时。让PM去反馈给云厂商处理无果,无奈只能自己动手处理了。
在位于互联网区的一台机器上,通过设置从互联网同步校准时间,保证自身系统时间是准确的前提下,再启动运行一个ntp服务端,让那些无法访问互联网区的服务器作为client,从这个ntp server来同步时间,进而实现系统时间同步。
技术一点儿的讲:server端,先从互联网同步时间,确保时间正确之后,启动chronyd系统服务,监听在123端口;client端通过udp协议,从 server ip:123端口请求时间同步。
服务器的操作系统和版本信息都一致,只是系统时间不同而已「我在编写整理这篇文档时的北京时间是:2026年7月22日早上7点20分左右 」,具体信息如下:

[root@gxd-hlw-3 ~]# hostname -I
192.166.20.3 172.17.0.1
[root@gxd-hlw-3 ~]# uname -rm
4.19.90-89.11.v2401.ky10.aarch64 aarch64
[root@gxd-hlw-3 ~]# cat /etc/os-release
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Halberd)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Halberd)"
ANSI_COLOR="0;31"
[root@gxd-hlw-3 ~]# date
Wed Jul 22 07:20:11 CST 2026
[root@gxd-hlw-3 ~]#
[root@hqqf-35 ~]# hostname -I
10.193.120.35 172.17.0.1
[root@hqqf-35 ~]# uname -rm
4.19.90-89.11.v2401.ky10.aarch64 aarch64
[root@hqqf-35 ~]# cat /etc/os-release
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Halberd)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Halberd)"
ANSI_COLOR="0;31"
[root@hqqf-35 ~]# date
Tue Jul 21 23:19:59 CST 2026
[root@hqqf-35 ~]#
下文中,我会以192.166.20.3当做ntp服务器端,10.193.120.35作为ntp client端配置。
一 具体操作和配置步骤
1 ntp serve192.166.20.3查看chronyd服务是否启动
[root@gxd-hlw-3 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2026-07-09 06:50:53 CST; 1 weeks 5 days ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 734 (chronyd)
Tasks: 1
Memory: 3.2M
CGroup: /system.slice/chronyd.service
└─734 /usr/sbin/chronyd
Jul 16 10:54:16 gxd-hlw-3 chronyd[734]: Source 1.82.219.234 replaced with 113.141.164.39
Jul 16 13:29:03 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 16 16:38:11 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 16 20:22:23 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 17 11:18:55 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 17 13:54:13 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 1.82.219.234
Jul 19 02:41:29 gxd-hlw-3 chronyd[734]: Source 1.82.219.234 replaced with 113.141.164.39
Jul 19 05:34:03 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 20 03:41:42 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 20 08:17:36 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 1.82.219.234
[root@gxd-hlw-3 ~]#
服务启动正常,如果没有启动的话,则需要先启动。如果没有该服务,可以通过yum install chronyd*来执行安装。
2 ntp server端192.166.20.3修改chronyd配置文件
vi /etc/chrony.conf
在其配置文件里,加入允许客户端访问的IP地址范围限制,以及要把chronyd系统服务绑定在所有网卡上,而不能只是本机环路地址127.0.0.1。否则,ntp客户端发起同步时间请求时,无法通过ntp server 主机IP地址来请求。
修改的2个参数配置项如下:
allow 10.193.120.0/8
bindaddress 0.0.0.0
修改之后的文件内容如下:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool pool.ntp.org iburst
server ntp.ntsc.ac.cn iburst
server ntp1.aliyun.com iburst
#server cn.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 NTP client access from local network.
#allow 192.168.0.0/16
allow 10.193.120.0/8
bindaddress 0.0.0.0
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
#leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
3 ntp server端192.166.20.3重启chronyd服务,确保123端口正常监听
[root@gxd-hlw-3 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2026-07-09 06:50:53 CST; 1 weeks 5 days ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 734 (chronyd)
Tasks: 1
Memory: 3.2M
CGroup: /system.slice/chronyd.service
└─734 /usr/sbin/chronyd
Jul 16 10:54:16 gxd-hlw-3 chronyd[734]: Source 1.82.219.234 replaced with 113.141.164.39
Jul 16 13:29:03 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 16 16:38:11 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 16 20:22:23 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 17 11:18:55 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 17 13:54:13 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 1.82.219.234
Jul 19 02:41:29 gxd-hlw-3 chronyd[734]: Source 1.82.219.234 replaced with 113.141.164.39
Jul 19 05:34:03 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 113.141.164.38
Jul 20 03:41:42 gxd-hlw-3 chronyd[734]: Source 113.141.164.38 replaced with 113.141.164.39
Jul 20 08:17:36 gxd-hlw-3 chronyd[734]: Source 113.141.164.39 replaced with 1.82.219.234
[root@gxd-hlw-3 ~]# systemctl restart chronyd
[root@gxd-hlw-3 ~]#
[root@gxd-hlw-3 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2026-07-21 16:48:32 CST; 3s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 1434299 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Process: 1434303 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Main PID: 1434301 (chronyd)
Tasks: 1
Memory: 2.1M
CGroup: /system.slice/chronyd.service
└─1434301 /usr/sbin/chronyd
Jul 21 16:48:32 gxd-hlw-3 systemd[1]: Starting NTP client/server...
Jul 21 16:48:32 gxd-hlw-3 chronyd[1434301]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Jul 21 16:48:32 gxd-hlw-3 chronyd[1434301]: Frequency -12.151 +/- 0.063 ppm read from /var/lib/chrony/drift
Jul 21 16:48:32 gxd-hlw-3 systemd[1]: Started NTP client/server.
[root@gxd-hlw-3 ~]#
[root@gxd-hlw-3 ~]# ss -unlp | grep 123
UNCONN 0 0 0.0.0.0:123 0.0.0.0:* users:(("chronyd",pid=1434301,fd=8))
[root@gxd-hlw-3 ~]#
4 ntp客户端10.193.120.35修改chronyd配置文件/etc/chronyd.conf
修改前:
[root@hqqf-35 ~]# hostname -I
10.193.120.35 172.17.0.1
[root@hqqf-35 ~]# date
Tue Jul 21 23:37:46 CST 2026
[root@hqqf-35 ~]# chronyc sources -v
210 Number of sources = 0
.-- 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
===============================================================================
[root@hqqf-35 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2026-06-22 09:58:13 CST; 4 weeks 1 days ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 661 (chronyd)
Tasks: 1
Memory: 2.6M
CGroup: /system.slice/chronyd.service
└─661 /usr/sbin/chronyd
[root@hqqf-35 ~]#
在配置文件/etc/chronyd.conf中,添加 server 192.166.20.3 iburst
修改后:
[root@hqqf-35 ~]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool pool.ntp.org iburst
server ntp.ntsc.ac.cn iburst
server ntp1.aliyun.com iburst
#server cn.pool.ntp.org iburst
#下面是新添加的配置项
server 192.166.20.3 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
# Get TAI-UTC offset and leap seconds from the system tz database.
#leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
[root@hqqf-35 ~]#
5 ntp客户端10.193.120.35重启chronyd服务,并确认可以同步时间源
[root@hqqf-35 ~]# systemctl restart chronyd
[root@hqqf-35 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2026-07-21 23:50:05 CST; 6s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 1621798 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Process: 1621802 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Main PID: 1621800 (chronyd)
Tasks: 2
Memory: 1.9M
CGroup: /system.slice/chronyd.service
└─1621800 /usr/sbin/chronyd
Jul 21 23:50:05 hqqf-35 systemd[1]: Starting NTP client/server...
Jul 21 23:50:05 hqqf-35 chronyd[1621800]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH>
Jul 21 23:50:05 hqqf-35 chronyd[1621800]: Frequency -6.273 +/- 0.176 ppm read from /var/lib/chrony/drift
Jul 21 23:50:05 hqqf-35 systemd[1]: Started NTP client/server.
[root@hqqf-35 ~]# 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
===============================================================================
^* 192.166.20.3 3 6 17 1 +19us[ +320us] +/- 25ms
[root@hqqf-35 ~]#
6 ntp客户端10.193.120.35开始手动同步时间
这一步非必须,其实只要在客户端里配置了ntp同步时间源,并且重启了chronyd服务之后,系统会自动同步时间。
[root@hqqf-35 ~]# ntpdate 192.166.20.3
22 Jul 07:51:20 ntpdate[4123508]: step time server 192.166.20.3 offset +28807.674521 sec
[root@hqqf-35 ~]# date
Wed Jul 22 07:51:24 CST 2026
[root@hqqf-35 ~]#
三 小结
这是一个比较简单的问题,系统因为网络问题,或者其它原因导致无法提供正确时间,势必会对运行在其上的应用系统带来一些问题。这里做一个简洁记录。
ntp服务端查查系统是否提供ntp时间服务,以及其运行的端口是否正常:
systemctl status chronyd
ss -nltp|grep 123
netstat -anp|grep 123
netstat -anp|grep udp
ntp客户端,查看是否可以连接到ntp server并执行时间同步,此时无法通过常规的telnet ntp_server_ip 123命令来验证。
chronyc resource -v
#或者
ntpdate -q NTP_server_ip
手工通过ntpdate命令来同步时间
ntpdate NTP_server_ip


