由于多臺服務(wù)器中只有服務(wù)器A能訪問互聯(lián)網(wǎng),故用該服務(wù)器搭建ntp時鐘同步服務(wù),自動同步網(wǎng)絡(luò)時間梭伐,其余的服務(wù)器皆作為客戶端,自動同步服務(wù)器A的時間仰担。
服務(wù)器A
-
確認是否安裝ntp
rpm -qa|grep ntp
-
若未安裝糊识,則安裝ntp
yum -y install ntp
-
修改ntp配置文件
vim /etc/ntp.conf # ** 新增配置 ** restrict 服務(wù)器A的ip mask 255.255.252.0 nomodify notrap server 127.127.1.0 fudge 127.127.1.0 stratum 10 # ** 將配置文件中的server注釋 ** #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
ntp.conf配置文件詳解: https://blog.csdn.net/qq_35663625/article/details/103064495
查看時間,并校驗
啟動ntp的服務(wù):service ntpd start 或者 systemctl start ntpd
-
設(shè)置ntp服務(wù)開機自啟動:systemctl enable ntpd
ntp服務(wù)器查看狀態(tài): https://blog.csdn.net/kingzdd/article/details/80106081
其他服務(wù)器
-
配置crontab摔蓝,使用命令:crontab -e赂苗, 然后添加:
*/1 * * * * /usr/sbin/ntpdate 服務(wù)器A的ip