Java大数据开发:Hadoop-集群时间同步
hadoop集群我们已经搭建好了,但是集群在执行任务的时候,必须要保持时间同步,所以,这一节,我们就要进行集群时间同步。
集群时间同步
注意:在root用户下执行
时间同步的方式:找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步,比如,每隔十分钟,同步一次时间。
一、时间服务器配置
1、检查ntp是否安装
[root@hadoop100 ~]# rpm -qa|grep ntpfontpackages-filesystem-1.41-1.1.el6.noarchntpdate-4.2.6p5-10.el6.centos.x86_64ntp-4.2.6p5-10.el6.centos.x86_64
2、修改ntp配置文件
[root@hadoop100 ~]# vi /etc/ntp.conf
(1)授权192.168.1.0-192.168.1.255网段上的所有机器可以从这台机器上查询和同步时间
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap修改为 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
(2)集群在局域网中,不使用其他互联网上的时间
server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 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
(3)当该节点丢失网络连接,依然可以采用本地时间作为时间服务器为集群中的其他节点提供时间同步,添加如下内容,保存退出
server 127.127.1.0fudge 127.127.1.0 stratum 10
3、修改/etc/sysconfig/ntpd 文件,保存退出
4、重新启动ntpd服务
[root@hadoop100 ~]# service ntpd status
[root@hadoop100 ~]# service ntpd restart关闭 ntpd:[失败]正在启动 ntpd:[确定]
5、设置ntpd服务开机启动
[root@hadoop100 ~]# chkconfig ntpd on
二、其他服务器配置
1、在其他机器配置10分钟与时间服务器同步一次
[root@hadoop101 ~]# crontab -e0 /10 ?
2、服务器执行以下命令,可以手动同步时间
[root@hadoop101 ~]# /usr/sbin/ntpdate hadoop10028 Mar 13:47:01 ntpdate[2419]: step time server 192.168.1.100 offset -1.711691 sec
3、相同的操作在需要做时间同步的机器上操作一次。
还没有评论,来说两句吧...