+------------------+
| Author:啊国 |
+------------------+
时间同步服务器
1、服务端及客户端安装ntp软件
yum -y install ntp
2、配置服务端软件(将主配置文件中原来的主配置文件进行注释)
sed -i 's/server 0.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 1.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 2.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 3.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
然后自己追加的一条网络时间同步服务
echo "server 127.127.1.0 iburst" >>/etc/ntp.conf
最后进行启动
systemctl restart ntpd
3、配置客户端软件(同理,将原来的注释,自己追加)
sed -i 's/server 0.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 1.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 2.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
sed -i 's/server 3.centos.pool.ntp.org iburst/#server 0.centos.pool.ntp.org iburst/g' /etc/ntp.conf
echo "server 172.16.1.99
restrict 172.16.1.99 nomodify notrap noquery" >>/etc/ntp.conf
然后重新启动
systemctl restart ntpd
最后服务器可以使用ntpdate -u 172.16.1.99命令进行时间同步