黑猴子的家:自动故障转移HDFS-HA

1、规划集群

hadoop102hadoop103hadoop104
NameNodeNameNode""
JournalNodeJournalNodeJournalNode
DataNodeDataNodeDataNode
ZKZKZK

2、关闭所有HDFS服务

[yinggu@hadoop102 hadoop-2.7.2]$ sbin/stop-dfs.sh

3、增加配置参数

core-site.xml

<!-- 自动故障转移HA zookeeper -->
<property>
    <name>ha.zookeeper.quorum</name>
    <value>hadoop102:2181,hadoop103:2181,hadoop104:2181</value>
</property>

hdfs-site.xml

<!-- 自动故障转移HA zookeeper ,复活 -->
<property>
    <name>dfs.ha.automatic-failover.enabled</name>
    <value>true</value>
</property>

分发hadoop

[yinggu@hadoop102 HA]$ scp -r hadoop-2.7.2/  yinggu@hadoop103:/opt/module/HA/
[yinggu@hadoop102 HA]$ scp -r hadoop-2.7.2/  yinggu@hadoop104:/opt/module/HA/

4、zookeeper

(1)分别启动hadoop[102-104] 节点上的zookeeper

[yinggu@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh start
[yinggu@hadoop103 zookeeper-3.4.10]$ bin/zkServer.sh start
[yinggu@hadoop104 zookeeper-3.4.10]$ bin/zkServer.sh start

(2)分别查看zookeeper的运行状态

hadoop102

[yinggu@hadoop102 zookeeper-3.4.10]$ bin/zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower

hadoop103

[yinggu@hadoop103 zookeeper-3.4.10]$ bin/zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader

hadoop104

[yinggu@hadoop104 zookeeper-3.4.10]$ bin/zkServer.sh status
JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower

5、初始化zookeeper中的HA状态

[yinggu@hadoop102 hadoop-2.7.2]$ bin/hdfs zkfc -formatZK
尖叫提示:只需要在第一次部署时初始化

6、启动HDFS

方式一

[yinggu@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh
注意:如果没有使用start-dfs.sh命令启动服务,每个服务需要单独启动

方式二

[yinggu@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode
[yinggu@hadoop103 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start namenode
[yinggu@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemons.sh start datanode
[yinggu@hadoop103 hadoop-2.7.2]$ sbin/hadoop-daemons.sh start datanode
[yinggu@hadoop104 hadoop-2.7.2]$ sbin/hadoop-daemons.sh start datanode
[yinggu@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start journalnode
[yinggu@hadoop103 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start journalnode
[yinggu@hadoop104 hadoop-2.7.2]$ sbin/hadoop-daemon.sh start journalnode
[yinggu@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemin.sh start zkfc
[yinggu@hadoop103 hadoop-2.7.2]$ sbin/hadoop-daemin.sh start zkfc

7、测试

[yinggu@hadoop102 hadoop-2.7.2]$ sbin/hadoop-daemon.sh stop namenode
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值