- 安裝ntp
yum install ntp
- 編輯ntp配置文件
vim /etc/ntp.conf
- 配置網(wǎng)絡(luò)信息
restrict 192.168.179.21 nomodify notrap nopeer noquery //當(dāng)前節(jié)點IP地址
restrict 192.168.179.1 mask 255.255.255.0 nomodify notrap //集群所在網(wǎng)段的網(wǎng)關(guān)(Gateway)矾克,子網(wǎng)掩碼(Genmask)
- 設(shè)置主節(jié)點
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
- 設(shè)置從節(jié)點
server 192.168.179.21
Fudge 192.168.179.21 stratum 10
- 查看服務(wù)支行狀態(tài)
netstat -anptu | grep 123
- 啟動ntp服務(wù)
service ntpd start
- 查看ntp是否支行正常
ntpstat
- 查看ntp服務(wù)器與上層ntp的狀態(tài)
ntpq -p
- 查看ntpd進程的狀態(tài)
watch "ntpq -p"
- 設(shè)置開機啟動
chkconfig ntpd on
- 列出與上游服務(wù)器的連接
ntpq -p
- 查看防火墻商品是否打開
firewall-cmd --zone=public --query-port=123/tcp
- 開放端口
firewall-cmd --zone=public --add-port=123/tcp --permanent (permanent永久生效,沒有此參數(shù)重啟后失效)
- 刪除端口
firewall-cmd --zone=public --remove-port=123/tcp --permanent
- 在啟動服務(wù)前需要從服務(wù)器同步時間伙菜,同步命令
ntpdate ntp1.aliyun.com
附阿里云時間服務(wù)器列表
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com