[问题描述] 使用 Anolis OS 8.4 龙芯版 4.19.190-3.an8.loongarch64 环境在测试系统服务 ntp 功能时报错,无 ntp 安装包,Error: Unable to find a match: ntp 【测试环境】 [内核] 内核: [root@localhost ~]# uname -r 4.19.190-3.an8.loongarch64 # cat /etc/os-release NAME="Anolis OS" VERSION="8.4" ID="anolis" ID_LIKE="rhel fedora centos" VERSION_ID="8.4" PLATFORM_ID="platform:an8" PRETTY_NAME="Anolis OS 8.4" ANSI_COLOR="0;31" HOME_URL="https://openanolis.cn/" # lscpu Architecture: loongarch64 Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 CPU family: Loongson-64bit Model name: Loongson-3A5000LL BogoMIPS: 4600.00 L1d cache: 64K L1i cache: 64K L2 cache: 256K L3 cache: 16384K NUMA node0 CPU(s): 0-3 Flags: cpucfg lam ual fpu lsx lasx complex crypto lvz lbt_x86 lbt_arm lbt_mips # free -h total used free shared buff/cache available Mem: 15Gi 1.1Gi 12Gi 21Mi 1.7Gi 12Gi Swap: 7.9Gi 0B 7.9Gi [问题复现] [root@localhost ~]# ifconfig enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 30.240.156.103 netmask 255.255.248.0 broadcast 30.240.159.255 inet6 fe80::223:9eff:fe25:9234 prefixlen 64 scopeid 0x20<link> ether 00:23:9e:25:92:34 txqueuelen 1000 (Ethernet) RX packets 315411 bytes 329958882 (314.6 MiB) RX errors 0 dropped 5 overruns 0 frame 0 TX packets 338455 bytes 32682450 (31.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 45 base 0x4000 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 140 bytes 30411 (29.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 140 bytes 30411 (29.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:ed:f0:af txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 执行: 查询是否已有 ntp 服务 [root@localhost ~]# ntpstat bash: ntpstat: command not found... Failed to search for file: basearch not set 查询是否已安装 ntp [root@localhost ~]# rpm -qa | grep ntp python3-ntplib-0.3.3-10.el8.noarch fontpackages-filesystem-1.44-22.el8.noarch [root@localhost ~]# [root@localhost ~]# 下载 ntp [root@localhost ~]# yum install ntp Last metadata expiration check: 0:54:34 ago on Fri 24 Dec 2021 12:59:19 PM CST. No match for argument: ntp Error: Unable to find a match: ntp
ntp服务应该是chrony包提供的,麻烦试一下
[root@localhost ~]# yum install chrony Last metadata expiration check: 2:22:11 ago on Fri 07 Jan 2022 08:51:44 AM CST. Package chrony-3.5-2.an8.loongarch64 is already installed. Dependencies resolved. Nothing to do. Complete! [root@localhost ~]# service ntpd status Redirecting to /bin/systemctl status ntpd.service Unit ntpd.service could not be found. [root@localhost ~]# chrony 包已安装,但 ntp服务及配置文件都不存在 参考wiki:https://www.cnblogs.com/kerrycode/p/4744804.html
(In reply to xugangjian from comment #2) > [root@localhost ~]# yum install chrony > Last metadata expiration check: 2:22:11 ago on Fri 07 Jan 2022 08:51:44 AM > CST. > Package chrony-3.5-2.an8.loongarch64 is already installed. > Dependencies resolved. > Nothing to do. > Complete! > > [root@localhost ~]# service ntpd status > Redirecting to /bin/systemctl status ntpd.service > Unit ntpd.service could not be found. > [root@localhost ~]# > > > chrony 包已安装,但 ntp服务及配置文件都不存在 > 参考wiki:https://www.cnblogs.com/kerrycode/p/4744804.html chrony不应该是用chrony的配置文件吗? [root@localhost ~]# rpm -ql chrony | grep systemd /usr/lib/systemd/ntp-units.d/50-chronyd.list /usr/lib/systemd/system/chrony-dnssrv@.service /usr/lib/systemd/system/chrony-dnssrv@.timer /usr/lib/systemd/system/chrony-wait.service /usr/lib/systemd/system/chronyd.service
1. chronyd 服务正常运行 2. 设置时间测试过程 vim /etc/chrony.conf 添加同步时间的服务器IP 和 允许指定IP的虚拟机进行时间同步 # 类似: # Specify directory for log files. # server 11.159.85.196 iburst # 添加同步时间的服务器IP # allow 192.168.122.187/24 # 允许指定IP的虚拟机进行时间同步 [root@localhost test]# date -s 18:00:00 [root@localhost test]# systemctl restart chronyd.service [root@localhost test]# [root@localhost test]# systemctl status chronyd.service ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled) Active: active (running) since Fri 2022-01-21 17:02:00 CST; 2s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 234410 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS) Process: 234406 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 234408 (chronyd) Tasks: 1 (limit: 102974) Memory: 2.9M CGroup: /system.slice/chronyd.service └─234408 /usr/sbin/chronyd Jan 21 17:02:00 localhost.localdomain systemd[1]: Starting NTP client/server... Jan 21 17:02:00 localhost.localdomain chronyd[234408]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SI> Jan 21 17:02:00 localhost.localdomain chronyd[234408]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift Jan 21 17:02:00 localhost.localdomain chronyd[234408]: Using right/UTC timezone to obtain leap second data Jan 21 17:02:00 localhost.localdomain systemd[1]: Started NTP client/server. [root@localhost test]# timedatectl Local time: Fri 2022-01-21 19:04:43 CST Universal time: Fri 2022-01-21 11:04:43 UTC RTC time: Fri 2022-01-21 11:04:43 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no [root@localhost ~]# [root@localhost ~]# date Fri Jan 21 19:06:56 CST 2022 [root@localhost ~]# 测试pass [root@localhost ~]# cat /etc/chrony.conf +38 # Use Alibaba NTP server # Public NTP # Alicloud NTP server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp.aliyun.com minpoll 4 maxpoll 10 iburst server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst server ntp1.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp2.aliyun.com minpoll 4 maxpoll 10 iburst server ntp2.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp3.aliyun.com minpoll 4 maxpoll 10 iburst server ntp3.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst server ntp4.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp5.aliyun.com minpoll 4 maxpoll 10 iburst server ntp5.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp6.aliyun.com minpoll 4 maxpoll 10 iburst server ntp6.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp7.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp8.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp9.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst # CORP server 10.206.123.1 minpoll 4 maxpoll 6 iburst server 10.206.132.45 minpoll 4 maxpoll 6 iburst server 10.137.1.29 minpoll 4 maxpoll 6 iburst server 10.137.1.30 minpoll 4 maxpoll 6 iburst server 10.137.17.43 minpoll 4 maxpoll 6 iburst server 10.137.11.124 minpoll 4 maxpoll 6 iburst server 10.105.148.143 minpoll 4 maxpoll 6 iburst server 10.137.31.241 minpoll 4 maxpoll 6 iburst server 10.182.214.79 minpoll 4 maxpoll 6 iburst server 10.182.214.74 minpoll 4 maxpoll 6 iburst #Anycast server 10.101.0.88 minpoll 4 maxpoll 6 iburst server 10.195.29.88 minpoll 4 maxpoll 6 iburst server 10.143.22.88 minpoll 4 maxpoll 6 iburst server 10.137.100.88 minpoll 4 maxpoll 6 iburst server 203.107.6.88 minpoll 4 maxpoll 6 iburst #CLOUD server 10.143.0.44 minpoll 4 maxpoll 6 iburst server 10.143.33.49 minpoll 4 maxpoll 6 iburst server 10.137.36.29 minpoll 4 maxpoll 6 iburst server 10.137.36.30 minpoll 4 maxpoll 6 iburst server 10.137.32.5 minpoll 4 maxpoll 6 iburst server 10.137.32.105 minpoll 4 maxpoll 6 iburst server 10.137.38.29 minpoll 4 maxpoll 6 iburst server 10.137.38.30 minpoll 4 maxpoll 6 iburst server 10.137.50.63 minpoll 4 maxpoll 6 iburst server 10.137.50.196 minpoll 4 maxpoll 6 iburst server 100.107.21.193 minpoll 4 maxpoll 6 iburst server 100.107.21.195 minpoll 4 maxpoll 6 iburst #PUBLIC server 110.75.186.247 minpoll 4 maxpoll 6 iburst server 120.25.108.11 minpoll 4 maxpoll 6 iburst server 182.92.12.11 minpoll 4 maxpoll 6 iburst server 120.25.115.19 minpoll 4 maxpoll 6 iburst server 120.25.115.20 minpoll 4 maxpoll 6 iburst #ALIPAY server 10.225.209.13 minpoll 4 maxpoll 6 iburst server 10.228.209.23 minpoll 4 maxpoll 6 iburst server 10.211.209.12 minpoll 4 maxpoll 6 iburst server 172.20.130.23 minpoll 4 maxpoll 6 iburst server 10.227.209.17 minpoll 4 maxpoll 6 iburst server 10.137.109.132 minpoll 4 maxpoll 6 iburst server 10.137.109.133 minpoll 4 maxpoll 6 iburst server 10.137.97.186 minpoll 4 maxpoll 6 iburst server 10.137.97.187 minpoll 4 maxpoll 6 iburst server 10.137.108.148 minpoll 4 maxpoll 6 iburst server 10.137.108.149 minpoll 4 maxpoll 6 iburst server 10.190.254.49 minpoll 4 maxpoll 6 iburst server 10.190.254.129 minpoll 4 maxpoll 6 iburst server 10.137.102.33 minpoll 4 maxpoll 6 iburst server 10.213.134.111 minpoll 4 maxpoll 6 iburst server 10.137.111.92 minpoll 4 maxpoll 6 iburst server 10.137.111.65 minpoll 4 maxpoll 6 iburst server 10.52.116.141 minpoll 4 maxpoll 6 iburst #SQA server 10.210.208.8 minpoll 4 maxpoll 6 iburst server 10.104.71.5 minpoll 4 maxpoll 6 iburst server 10.137.59.14 minpoll 4 maxpoll 6 iburst server 10.137.59.19 minpoll 4 maxpoll 6 iburst server 100.88.14.3 minpoll 4 maxpoll 6 iburst server 100.88.14.4 minpoll 4 maxpoll 6 iburst server 100.82.58.3 minpoll 4 maxpoll 6 iburst server 100.82.58.4 minpoll 4 maxpoll 6 iburst # Ignore stratum in source selection. stratumweight 0.05 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Enable kernel RTC synchronization. rtcsync # In first three updates step the system clock instead of slew # if the adjustment is larger than 10 seconds. makestep 10 3 # Allow NTP client access from local network. #allow 192.168/16 # Listen for commands only on localhost. bindcmdaddress 127.0.0.1 bindcmdaddress ::1 # Disable logging of client accesses. noclientlog # Send a message to syslog if a clock adjustment is larger than 0.5 seconds. logchange 0.5 logdir /var/log/chrony #log measurements statistics tracking