NTP server deployment and client automatic synchronization

1. Usage scenario: At least one server can access the external network, and other servers cannot access the external network.
NTP server deployment and client automatic synchronization

2. Server installation

yum -y install ntp ntpdate
ntpdate 0.asia.pool.ntp.org
hwclock --systohc       
systemctl enable ntpd         
systemctl start ntpd

配置ntp文件 vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict ::1
允许内网其他机器同步时间
restrict 192.168.206.0 mask 255.255.255.0 nomodify notr
定义使用的上游 ntp服务器,将原来的注释
server 0.asia.pool.ntp.org
定义使用的上游 ntp服务器,将原来的注释
restrict 0.asia.pool.ntp.org nomodify notrap noquery
定义使用的上游 ntp服务器,将原来的注释
server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

ntpq -p display node list
NTP server deployment and client automatic synchronization

3. Client deployment
Copy the server /usr/sbin/ntpdate file to the client /usr/sbin/ directory

Write the synchronization file vim /usr/local/sbin/ntpdate.sh

ntpdate -u 172.16.90.37
hwclock --systohc

crontab -e write timing tasks

          • /usr/local/sbin/ntpdate.sh >> /tmp/ntp.log

Guess you like

Origin blog.51cto.com/14033037/2545133