本文原始地址:https://sitoi.cn/posts/27560.htmlhtml
ntp.conf
文件ntp.conf
文件ntpd
服務ntpd
服務選擇一臺設備當時間同步主節點,運行如下命令,編寫文件 ntp.conf
vim
sudo vim /etc/ntp.conf
寫入以下內容:bash
driftfile /var/lib/ntp/drift restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 restrict ::1 # restrict 網段 mask 子網掩碼 restrict 192.168.1.0 mask 255.255.255.0 # 修改這行 server 127.127.1.0 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys disable monitor
除主節點外的全部設備,運行如下命令,,編寫文件 ntp.conf
post
sudo vim /etc/ntp.conf
寫入以下內容:rest
driftfile /var/lib/ntp/drift restrict default nomodify notrap nopeer noquery restrict 127.0.0.1 restrict ::1 # server 從節點 IP 地址 server 192.168.1.152 # 根據從節點實際 IP 地址修改 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys disable monitor
在每個
節點上運行如下命令將全部節點的時區修改成 Asia/Shanghai
code
timedatectl set-timezone Asia/Shanghai
在主節點運行如下命令:server
systemctl restart ntpd
在每臺從節點機器上運行以下命令:htm
其中:192.168.1.151 表示主節點 IP 地址get
ntpdate 192.168.1.151
檢測每臺設備時間是否一致,運行以下命令:同步
$ date Thu Apr 18 16:50:07 CST 2019
在每個從節點運行如下命令:
systemctl restart ntpd
Ambari 集羣時間同步成功