ITPub博客

首页 > 大数据 > Hadoop > 好程序员大数据培训分享:Hadoop集群同步

好程序员大数据培训分享:Hadoop集群同步

原创 Hadoop 作者:好程序员 时间:2020-06-17 12:05:14 0 删除 编辑

   好程序员大数据培训分享:Hadoop 集群同步, 给大家带来的技术分享是——Hadoop 集群同步。

一、同步方式

  选择一个机器,作为时间服务器( 这里选择 hadoop01) ,所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。

二、所需工具

  时间同步服务器有两个:ntpd 和 ntpdatp 。虽然使用二者都能达到时间同步的目的,但是使用之前得弄清楚一个问题, ntpd 与 ntpdate 在更新时间时有什么区别。 ntpd 不仅仅是时间同步服务器,它还可通过客户端与标准时间服务器进行时间同步,而且是平滑同步,并非 ntpdate 立即同步,在生产环境中慎用 ntpdate ,也正如此两者不可同时运行。

三、具体操作步骤

  时间服务器配置

  (1) 检查 ntp 是否安装。 [root@hadoop01 Desktop]# rpm -qa|grep ntp 如果显示 ntp-4.2.6p5-1.el6.centos.x86_64 . fontpackages-filesystem-1.41-1.1.el6.noarch

  ntpdate-4.2.6p5-1.el6.centos.x86_64 则证明 ntp 已经安装,否则要先安装 ntp 服务。 [root@hadoop01 Desktop]# yum install -y ntp.

  (2) 修改 ntp 配置文件 [root@hadoop01 Desktop]# vi /etc/ntp.conf. 先配置客户端的授权,也就是给指定的机器 ( 客户端 ) 设置访问 NTP Server 的权限,这是通过 restrict 配置项实现的。将 #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 释放。改为 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap. 如果集群是在一个封闭的局域网内,可以屏蔽掉默认的 server 。

  将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. 将本机的本地时钟作为时间供给源,这样,即便它失去网络连接,它也可以继续为网络提供服务增加 server 127.127.1.0 fudge 127.127.1.0 stratum. 修改 /etc/sysconfig/ntpd 文件

  [root@hadoop01 Desktop]# vim /etc/sysconfig/ntpd 增加 SYNC_HWCLOCK=yes 之后重启 ntpd , [root@hadoop01 Desktop]# service ntpd restart ,设置 ntpd 开机默认启动 [root@hadoop01 Desktop]# chkconfig mtpd on 。完成以上操作以后,使用 date 命令查看系统时间与当前时间是否对应,如果还不对应,应该是时区的问题。修改时区 [root@hadoop01 Desktop]# tzselect 。根据提示选择正确的时区,然后将 cp /usr/share/zoneinfo/Asia/Shanghai 设置为到 /etc/localtime 的链接

  [root@hadoop01 Desktop]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

四、其他机器配置

  配置每十分钟与时间服务器同步一次

  需要在集群中其他的机器中都编写时间同步脚本,这里以hadoop02 为例, [root@hadoop02 Desktop]# crontab –e. */10 * * * * /usr/sbin/ntpdate hadoop01

  重启crond 服务。 [root@hadoop02 Desktop]# service crond restart 。如果需要,同样要修改时区,操作同上。

  到此,分享结束,欢迎大家一起探讨学习!


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69913864/viewspace-2698807/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-03-20

  • 博文量
    342
  • 访问量
    195021