hadoop集群中配置ntp时间同步服务器

  1. 在搭建hadoop集群的时候,往往由于集群中机器的时间不一致造成一些错误,比如System times on machines may be out of sync. Check system time and time zones.
  2. 我们需要解决的就是配置一个ntp来同步时间
  3. 时间同步的方式:找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步,比如每隔十分钟同步一次等等
  4. 时间服务器配置(必须root用户):
    1.   检查ntp服务是否安装
      [root@hadoop102 桌面]# rpm -qa|grep ntp
      ntp-4.2.6p5-10.el6.centos.x86_64
      fontpackages-filesystem-1.41-1.1.el6.noarch
      ntpdate-4.2.6p5-10.el6.centos.x86_64

       

    2. 修改ntp配置文件:
      [root@hadoop102 桌面]# vi /etc/ntp.conf
      修改内容如下
      a) 修改 1
      #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 为
      restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
      b) 修改 2
      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 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
      c) 添加 3
      server 127.127.1.0
      fudge 127.127.1.0 stratum 10

       

    3. 修改/etc/sysconfig/ntpd 文件
      [root@hadoop102 桌面]# vim /etc/sysconfig/ntpd
      增加内容如下
      SYNC_HWCLOCK=yes

       

    4. 重启ntpd服务
      [root@hadoop102 桌面]# service ntpd status
      ntpd 已停
      [root@hadoop102 桌面]# service ntpd start
      正在启动 ntpd: [确定]
      执行:
      [root@hadoop102 桌面]# chkconfig ntpd on
    5. 其他机器配置(必须 root 用户) :
      1.   在其他机器配置 10 分钟与时间服务器同步一次
        [root@hadoop103 hadoop-2.7.2]# crontab -e
        编写脚本
        */10 * * * * /usr/sbin/ntpdate hadoop102

         

      2. 修改任意机器时间
        [root@hadoop103 hadoop]# date -s "2017-9-11 11:11:11"

         

      3. 十分钟后查看机器是否与时间服务器同步
        [root@hadoop103 hadoop]# date

         

转载于:https://www.cnblogs.com/tianliuyang/p/9657602.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值