1、修改配置文件
在core-site.xml配置文件中加入1
2
3
4
5
6
7
8<property>
<name>ha.zookeeper.quorum</name>
<value>hostname:2181,hostname:2181,hostname:2181</value>
</property>
<property>
<name>ha.zookeeper.session-timeout.ms</name>
<value>20000</value>
</property>
修改hdfs-site.xml配置文件1
2
3
4
5
6
7
8
9
10<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value> sshfence
shell(/bin/true)
</value>
</property>
将更改后的配置文件scp到各节点
2、格式化zkfc1
./bin/hdfs zkfc -formatZK
3、重启standby namenode节点(直到safemode变成off)1
2./sbin/hadoop-daemon.sh stop namenode
./sbin/hadoop-daemon.sh start namenode
4、关闭active namenode1
./sbin/hadoop-daemon.sh stop namenode
5、启动standby namenode节点上的zkfc1
./sbin/hadoop-daemon.sh start zkfc
6、 启动原active namenode(启动之后变成standby)
1 | ./sbin/hadoop-daemon.sh start namenode |
7、最后启动原active namenode节点zkfc