Ambari 集羣時間同步配置教程

本文原始地址:https://sitoi.cn/posts/27560.htmlhtml

步驟

  • 在時間同步主節點建立 ntp.conf 文件
  • 在時間同步從節點上建立 ntp.conf 文件
  • 修改全部節點時區
  • 重啓主節點 ntpd 服務
  • 將全部從節點時間與主節點時間同步
  • 檢測時間是否同步
  • 重啓從節點 ntpd 服務

在時間同步主節點建立 ntp.conf 文件

選擇一臺設備當時間同步主節點,運行如下命令,編寫文件 ntp.confvim

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 文件

除主節點外的全部設備,運行如下命令,,編寫文件 ntp.confpost

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/Shanghaicode

timedatectl set-timezone Asia/Shanghai

重啓主節點 ntpd 服務

在主節點運行如下命令: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

重啓從節點 ntpd 服務

在每個從節點運行如下命令:

systemctl restart ntpd

Ambari 集羣時間同步成功

相關文章
相關標籤/搜索