当前位置:   article > 正文

Linux 时间同步 ntp 服务_yum install ntp

yum install ntp

一、所有服务器安装时间同步程序

yum install ntp ntpdate -y
  • 1

二、选择一个主服务器同步外网时间,修改配置
编辑文件 /etc/ntp.conf,该服务器的IP地址例如为 192.168.1.64
注释原有的 ntp server 配置,然后添加新的,如下:

# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp3.aliyun.com iburst
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

如下内容,取消掉 restrict 前面的注释,保证 192.168.1.0 为本机所属网段一致

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
  • 1
  • 2

三、其他服务配置
编辑文件 /etc/ntp.conf
注释原有的 ntp server 配置,然后添加新的,如下:

# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 192.168.1.64 prefer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

四、所有服务器重启 ntp 服务

service ntpd restart
systemctl disable chronyd.service
systemctl enable ntpd.service
  • 1
  • 2
  • 3

五、在除主服务器之外的其他服务器进行测试
输入 ntpq -p 出现以下结果:

[root@server3 soft]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 192.168.1.64     203.107.6.88     3 u   43   64    0    0.000    0.000   0.000
  • 1
  • 2
  • 3
  • 4

说明时间已经同步。


(END)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/305199?site
推荐阅读
相关标签
  

闽ICP备14008679号