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

 

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

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

步骤

  • 所有节点停止并永久关闭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权限

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值