在hdfs伪分布式基础上搭建HA,伪分布式搭建参考上篇。
首先明确一下集群中各个节点的职责:
node1:NN1, ZKFC,JNN
node2:NN2,DN,ZK,ZKFC,JNN
node3:NN2,DN,ZK,JNN
node4:,DN,ZK
一、两个nn节点免秘钥
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
二、修改hdfs.xml
增加:
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
</property>
<property>
<name>dfs.ha.namenodes.mycluster</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>node1:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>node2:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>node1:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>node2:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://node1:8485;node2:8485;node3:8485/mycluster</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/var/sxt/hadoop/ha/jn</value>
</property>
<property>
<name>dfs.client.failover.proxy.provider.mycluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>sshfence</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/root/.ssh/id_dsa</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
三、配置core-site.xml
hadoop.tmp.dir的配置要变更:/var/sxt/hadoop-2.6/ha
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>node07:2181,node08:2181,node09:2181</value>
</property>
四、分发 hdfs.xml 和core.xml 给其他节点
五、安装zookeeper集群:
六、逐步启动集群
node1,node2.node3节点启动 JN 集群
hadoop-daemon.sh start journalnode
随意找一个nn节点格式化:
hdfs namenode -format
启动该节点:
hadoop-daemon.sh start namenode
另一nn节点同步:
hdfs namenode -bootstrapStandby
(同步成功,会发现同步另一个nn节点的clusterID 不是秘钥分发,而是同步过来的)
hdfs zkfc -formatZK
最后启动hdfs集群;
start-dfs.sh
网友评论