【Hadoop集群】四、时间同步

一、安装ntpd


yum install -y ntp ntpd

  

查看时区  要是cst
timedatectl 

修改时区
timedatectl set-timezone  Asia/Shanghai

查看状态
sudo systemctl status ntpd 启动 sudo systemctl start ntpd 开机自启 sudo systemctl is-enabled ntpd

    sudo systemctl enable ntpd

 

 同步到硬件时间

hwclock -w

   网络时间

sudo ntpdate 1.cn.pool.ntp.org


配置

     $ sudo vim /etc/ntp.conf

          第一处:修改成自己的网段

          #Hosts on local network are less restricted.

          restrict 192.168.74.0 mask 255.255.255.0 nomodify notrap

          第二处:由于是内网环境,就不需要这些服务配置,注释

          # Please consider joining the pool  (http://www.pool.ntp.org/join.html).

          # server 0.centos.pool.ntp.org

          # server 1.centos.pool.ntp.org

          # server 2.centos.pool.ntp.org

          第三处:ntp server提供的本地服务

          server 127.127.1.0                     #local clock

          fudge 127.127.1.0   stratum  10




 

sudo vim /etc/sysconfig/ntpd

 

SYNC_HWCLOCK=yes

 

  

其他节点,同步第一台

先测试能不能同步时间

从机同步时间
sudo ntpdate hadoop101

再添加命令

sudo crontab -e

*/1 * * * * /usr/sbin/ntpdate hadoop101

  

posted @ 2022-01-05 19:52  持枢  阅读(175)  评论(0)    收藏  举报