服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - CentOS Stream release 9使用chrony服务同步时间的操作方法

CentOS Stream release 9使用chrony服务同步时间的操作方法

2024-04-16 12:14运维那些事~ Centos

这篇文章主要介绍了CentOS Stream release 9 使用chrony服务同步时间,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

1、安装chrony命令

Centos9里是预安装的,没有安装的话执行以下命令:

yum install -y chrony

说明:Centos9 时间同步要使用chrony命令,ntp命令不能使用了

2、查看chrony状态

#启用chronyd服务
systemctl enable chronyd
#重启chronyd服务
systemctl restart chronyd
#查看chronyd服务状态
systemctl status chronyd

3、修改配置文件,将第三行注释后添加如下内容

vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
pool ntp1.aliyun.com iburst
pool ntp2.aliyun.com iburst
pool ntp3.aliyun.com iburst
pool ntp4.aliyun.com iburst
pool ntp5.aliyun.com iburst
pool ntp6.aliyun.com iburst

4、重启chronyd服务

systemctl restart chronyd

5、查看同步情况

通过命令进行查看是否同步,出现^*即表示有可同步的源

chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^- 120.25.115.20                 2   6   255    83  -4786us[-7195us] +/-   89ms
^* 203.107.6.88                  2   6   367    26  -3585us[-5936us] +/-   97ms

System clock synchronized: yes 表示同步成功

timedatectl 
               Local time: 一 2024-04-15 10:28:28 CST
           Universal time: 一 2024-04-15 02:28:28 UTC
                 RTC time: 一 2024-04-15 02:28:29
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes  # 表示同步成功
              NTP service: active
          RTC in local TZ: no

6、设置时区

如果时区不对,需要执行以下命令,修改时区
执行如下命令修改时区:

timedatectl set-timezone Asia/Shanghai 

到此这篇关于CentOS Stream release 9 使用chrony服务同步时间的文章就介绍到这了,更多相关CentOS chrony服务同步时间内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/ljx1528/article/details/137771141

延伸 · 阅读

精彩推荐