当前位置: 代码网 > 服务器>服务器>Linux > CentOS Stream release 9使用chrony服务同步时间的操作方法

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

2024年06月01日 Linux 我要评论
1、安装chrony命令centos9里是预安装的,没有安装的话执行以下命令:yum install -y chrony说明:centos9 时间同步要使用chrony命令,ntp命令不能使用了2、查

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服务同步时间内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com