CentOS8实现ntp同步

请注意自己的业务是否会因为时间更新有所影响,方法仅供参考。

一、错误再现

centos 8 执行 ntpdate 会出现以下错误

No match for argument: ntpdate Error: Unable to find a match: ntpdate

原因:在CentOS8.0中默认不再支持ntp软件包,时间同步将由chrony来实现

二、解决方法

1. 通过wlnmp方式

添加wlnmp的yum源

# rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm

安装ntp服务

# yum -y install wntp

时间同步

# ntpdate ntp1.aliyun.com

2. 通过同步目标服务器方式

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

# yum -y install chrony

启动并加入开机自启动(根据实际情况选择或不选)

# systemctl enable chronyd.service
# systemctl restart chronyd.service
# systemctl status chronyd.service

修改配置文件

扫描二维码关注公众号,回复: 12509952 查看本文章
vi /etc/chrony.conf

原配置

2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
3 pool 2.centos.pool.ntp.org iburst

修改

2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
3   pool 2.centos.pool.ntp.org iburst
    server 目标服务器IP iburst

保存退出,重启chronyd服务。

本文出现任何错误,请留言批评指正。

猜你喜欢

转载自blog.csdn.net/weixin_46623617/article/details/110523865