一、运行环境
树莓派4B安装的CentOS 7.9
二、配置步骤
1、检查ntp服务是否已经安装
rpm -q ntp
2、安装ntp服务
yum -y install ntp
3、查看服务状态
systemctl status ntpd
4、Master节点ntp服务配置
vim /etc/ntp.conf
服务端
#允许特定网段能同步时间
restrict 192.168.3.0 mask 255.255.255.0 nomodify notrap
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
restrict 0.cn.pool.ntp.org nomodify notrap noquery
restrict 1.cn.pool.ntp.org nomodify notrap noquery
restrict 2.cn.pool.ntp.org nomodify notrap noquery
restrict 3.cn.pool.ntp.org nomodify notrap noquery
server 127.0.0.1 # local clock
Fudge 127.0.0.1 stratum 10
5、Slave节点ntp服务配置
vim /etc/ntp.conf
server 192.168.3.101
restrict 192.168.3.10 nomodify notrap noquery
server 127.0.0.1 # local clock
Fudge 127.0.0.1 stratum 10
6、重启服务
systemctl restart ntpd
重启服务器确认配置生效。