当前位置: 代码迷 >> 综合 >> Hadoop集群部署(三),集群时间同步
  详细解决方案

Hadoop集群部署(三),集群时间同步

热度:68   发布时间:2024-02-24 16:22:27.0

 

集群中的节点需要设置时间同步。这很自然,因为多节点协作,我们希望它们在时间上是同步的。

解决方案就很简单了,只保留一个节点作为时间服务器,其他两个节点从该节点得到时间。

步骤

  • 所有节点停止并永久关闭ntp服务,注意每个发行版的命令不同,这里基于centos6.8
    • su, 避免麻烦,直接进root
    • service ntpd stop
    • chkconfig ntpd off
  • 在其中一个节点配置ntp,这里配置101主机
    • vim /etc/ntp.conf
      • restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap,去掉注释
      • 注释掉时间服务器

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

  • 配置硬件时间与系统时间同步vim /etc/sysconfig/ntpd
    • SYNC_HWCLOCK=yes
  • 重启ntp
    • service ntpd restart
    • chkconfig ntpd on
  • 在其他主机上配置时间自动从101获取
    • su,理由同上,否则无效
    • 配置定期任务 crontab -e

*/1 * * * * /usr/sbin/ntpdate hadoop102

# 此处1指的是1分钟

  • 验证配置,可以手动修改其他主机的时间,等1分钟看是否更新
    • 时间修改,date -s "2017-9-11 11:11:11"
    • 时间查看 ,date
    • 不生效重启试试,注意需要su权限

 

  相关解决方案