时间同步

1.服务端和客户端均下载ntp软件

yum install -y 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.66
restrict 172.16.1.66 nomodify notrap noquery" >>/etc/ntp.conf
systemctl restart ntpd

4.个服务器之间可以用命令进行时间的同步

ntpdate  -u 172.16.1.61(根据自己服务端的ip)  

你可能感兴趣的:(时间同步)