天天看点

Linux从入门到放弃 时间同步服务器安装服务端配置客户端配置启动测试

安装

所有机器安装

yum install -y ntp*
           

服务端配置

vim /etc/ntp.conf
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap	# 添加172.16.1.0网段 255.255.255.0掩码
# Use public servers from the pool.ntp.org project.
# 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 127.127.1.0										# 添加 本地时间
fudge 127.127.1.0 stratum 10							# 添加
           

客户端配置

# Use public servers from the pool.ntp.org project.
# 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 4.centos.pool.ntp.org iburst
server 172.16.1.61										# 添加 NTP服务器ip地址

           

启动

systemctl start ntpd
systemctl enable ntpd
           

测试

ntpq -p
           

继续阅读