本文原始地址: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 集群时间同步成功