CentOS 7 - ntp服务器的配置

ntp服务器实现多台机器之间的时间同步
 
摘抄自:
 
环境简介
CentOS 7.3, 7.5
 
机器,服务端(192.168.0.101)客户端(192.168.0.102)
 
软件安装
所有机器执行以下安装指令:
            yum -y install ntp
 
 
服务器端(192.168.0.101)配置:
 
 
vim /etc/ntp.conf
    restrict 192.168.0.101 nomodify notrap nopeer noquery          //当前节点IP地址
    restrict 192.168.0.2 mask 255.255.255.0 nomodify notrap        //集群所在网段的网关(Gateway),子网掩码(Genmask)
# 在server部分添加以下部分,并注释掉server 0 ~ n
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10
 
 
客户端(192.168.0.102)配置
    vim /etc/ntp.conf
    restrict 192.168.0.102 nomodify notrap nopeer noquery          //当前节点IP地址
    restrict 192.168.0.2 mask 255.255.255.0 nomodify notrap      //集群所在网段的网关(Gateway),子网掩码(Genmask)
    # 在server部分添加如下语句,将server指向主节点。
    server 192.168.0.102
    fudge 192.168.0.102 stratum 10
 
 
配置Ntp服务
  1. service ntpd start
  2. chkconfig ntpd on
 
客户端同步时间
        ntpdate -u 192.168.0.101
    
 
补充说明:
        不同机器在安装系统时,可能存在时区选择不一致的问题,常见的如CST  EDT等,此时需要将时区选择一致
                统一设置为CST
                    sudo  mv /etc/localtime  /etc/localtime.bak
                    sudo  ln -s /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
 
 
 
 
posted @ 2020-12-19 21:45  dos_hello_world  阅读(179)  评论(0)    收藏  举报