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 集群时间同步成功

相关文章
相关标签/搜索