hadoop环境搭建之分布式的建立6

一、说在前面

今天为分布式集群创建了一个时间管理器,用于同步三台机器的时间。

二、配置方法

==============时间服务器的创建(Hbase等对时间戳有要求的才会需要)===============

先关掉三台虚拟机的ntpd
sudo systemctl stop ntpd
sudo systemctl disable ntpd
检查
sudo systemctl status ntpd
sudo systemctl is-enabled ntpd


解除一行注释
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

增加4行注释
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

增加两行配置
server 127.127.1.0
fudge 127.127.1.0 stratum 10


sudo vim /etc/sysconfig/ntpd
硬件和系统时间保持一致
SYNC_HWCLOCK=yes

只在102做
启动ntpd,打开开机自启动,检查状态
sudo systemctl start ntpd
sudo systemctl enable ntpd
检查
sudo systemctl is-enabled ntpd
sudo systemctl status ntpd

为hadoop103 104设置命令,令其每隔一段时间(工作实际中设置的是10或者是5分钟,为了方便测试我先设置成1分钟)和102同步时间
sudo crontab -e    进入文件
*/1 * * * * /usr/sbin/ntpdate hadoop102
检验,随便设置一个时间,然后看1分钟后是否和102同步
sudo date -s "2018-08-08 08:08:08"
原文地址:https://www.cnblogs.com/suanai/p/14236128.html