1.服务器器信息
服务器IP | 类型 |
---|---|
192.168.235.180 | 主 |
192.168.235.181 | 从 |
192.168.235.182 | 从 |
2.安装ntp服务
所有机器安装ntp服务
centos7需要禁用chrony
systemctl stop chronyd
systemctl disable chronyd
安装ntp服务
yum install ntp ntpdate -y
systemctl status ntpd #有信新显示表示安装成功
3.主服务配置
vim /etc/ntp.conf
1.把如下四行代码注释掉
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
2.去掉注释,将地址改成网段地址
restrict 192.168.235.0 mask 255.255.255.0 nomodify notrap
添加以下内容
server 127.127.1.0
fudge 127.127.1.0 stratum 10
4.从服务器配置
vim /etc/ntp.conf
配置如下图:
5.启动所有节点
systemctl start ntpd.service
systemctl enable ntpd.service
6.判断时间同步是否成功
ntpstat
或者
ntpq -p
看到synchronised 表示从节点同步成功