同步多台主机时间 LINUX

由于多台服务器中只有服务器A能访问互联网,故用该服务器搭建ntp时钟同步服务,自动同步网络时间,其余的服务器皆作为客户端,自动同步服务器A的时间。


服务器A
  1. 确认是否安装ntp

    rpm -qa|grep ntp
    
  2. 若未安装,则安装ntp

    yum -y install ntp
    
  3. 修改ntp配置文件

    vim /etc/ntp.conf
    
    # ** 新增配置 **
    restrict 服务器A的ip mask 255.255.252.0 nomodify notrap
    server  127.127.1.0
    fudge   127.127.1.0 stratum 10
    
    # ** 将配置文件中的server注释 **
    #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
    

    ntp.conf配置文件详解: https://blog.csdn.net/qq_35663625/article/details/103064495

  4. 查看时间,并校验

  5. 启动ntp的服务:service ntpd start 或者 systemctl start ntpd

  6. 设置ntp服务开机自启动:systemctl enable ntpd

    ntp服务器查看状态: https://blog.csdn.net/kingzdd/article/details/80106081

其他服务器
  1. 配置crontab,使用命令:crontab -e, 然后添加:

    */1 * * * * /usr/sbin/ntpdate 服务器A的ip
    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容