二、HDFS(HA)软硬件配置
1.硬件
NameNode 机器,Active 、Standby 应该具有相同的硬件
2.软件
(1)core-site.xml
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>master,slave1,slave2,pcmk104,pcmk108</value>
</property>
(2)hdfs-site.xml
1. dfs.nameservices注意与core-site.xml中的fs.defaultFS中的value保持一致
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
</property>
2. dfs.ha.namenodes.mycluster每个namenode在名称服务中的唯一标识
<property>
<name>dfs.ha.namenodes.mycluster</name>
<value>nn1,nn2</value>
</property>
3.两个结点的rpc地址
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>master:54310</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>pcmk104:54310</value>
</property>
4. servicerpc地址
<property>
<name>dfs.namenode.servicerpc-address.mycluster.nn1</name>
<value>master:53310</value>
</property>
<property>
<name>dfs.namenode.servicerpc-address.mycluster.nn2</name>
<value>pcmk104:53310</value>
</property>
5.http通信地址
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>master:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>pcmk104:50070</value>
</property>
6.我们采用3个journalnode节点存储元数据,这是他们的IP与端口
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://master:8485;pcmk104:8485;slave1:8485/mycluster</value>
</property>
7. journaldata的存储路径
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/home/Hadoop/journaldata/</value>
</property>
8.该类用来判断哪个namenode处于生效状态
<property>
<name>dfs.client.failover.proxy.provider.mycluster</name> <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
9.打开自动切换namenode的功能
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
10. 运行脚本实现安全机制
<property>
<name>dfs.ha.fencing.methods</name>
<value>shell(/bin/true)</value>
</property>