CentOS8设置时间同步

概述

        随着大数据的飞速发展,服务器集群化,时间同步显得和外重要,不允许有任何差错。

        最近发现CentOS8 已经不在支持ntpd软件包,同时也无法通过官方软件仓库安装, CentOS8上使用Chrony配置NTP服务器,用于同步时间。 它有两个程序,chrony和chronyd, chronyd是守护进程 ,chrony是一个命令行界面程序,可以用来监控chronyd的性能,并修改各种操作参数。

软件包安装

系统自动已经安装,则不需安装

从仓库中直接安装

dnf install chrony -y

启动chrony

systemctl start chronyd.service && systemctl enable chronyd.service

查看是否启动成功

systemctl status chronyd.service

设置时间同步

设置时区 (这步很重要,把时区改成当地时区

timedatectl set-timezone "Asia/Shanghai"

编辑配置文件(使系统同步阿里云的时间)

vi /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 2.centos.pool.ntp.org iburst        注释掉
server ntp.aliyun.com iburst              新增行
server cn.ntp.org.cn iburst               新增行

重启服务

systemctl restart chronyd.service

时间同步

执行时间同步命令

[root@wang ~]# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- 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               
===============================================================================
^- 203.107.6.88                  2   6    37    13  -8096us[-8096us] +/-   24ms
^* 111.230.50.201                3   6    37    13    +17us[+4642us] +/-   61ms

验证时间

查看当前系统时间

date

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值