前提:安装hadoop前需要机器间免密码登录(用aitp账号),本部分配置可参考
在 hadoop1 上执行:
将 hadoop-3.2.1.tar.gz 上传到/home/aitp/software 目录下, 并解压
编辑 /home/aitp/software/hadoop-3.2.1/etc/hadoop/core-site.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>fs.defaultFS</name>
- <value>hdfs://mycluster</value>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/data/hadoop/tmpdir</value>
- </property>
- <property>
- <name>ha.zookeeper.quorum</name>
- <value>hadoop1:2181,hadoop2:2181,hadoop3:2181</value>
- </property>
- </configuration>
编辑:/home/aitp/software/hadoop-3.2.1/etc/hadoop/hdfs-site.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <!-- hdfs HA configuration-->
- <!-- all default configuration can be found at https://hadoop.apache.org/docs/stable|<can be a version liek r3.2.1></can>/hadoop-project-dist/hadoop-hdfs//hdfs-default.xml -->
- <property>
- <name>dfs.ha.automatic-failover.enabled</name>
- <value>true</value>
- </property>
- <!-- dfs.nameservices 这里需要与core-site.xml 中fs.defaultFS 的名称一致-->
- <property>
- <name>dfs.nameservices</name>
- <value>mycluster</value>
- </property>
- <!-- 定义集群中 namenode 列表,这里定义了三个namenode,分别是nn1,nn2,nn3-->
- <property>
- <name>dfs.ha.namenodes.mycluster</name>
- <value>nn1,nn2,nn3</value>
- </property>
- <!-- namenode nn1的具体定义,这里要和 dfs.ha.namenodes.mycluster 定义的列表对应 -->
- <property>
- <name>dfs.namenode.rpc-address.mycluster.nn1</name>
- <value>hadoop1:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.mycluster.nn2</name>
- <value>hadoop2:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.mycluster.nn3</name>
- <value>hadoop3:8020</value>
- </property>
- <!-- namenode nn1的具体定义,这里要和 dfs.ha.namenodes.mycluster 定义的列表对应 -->
- <property>
- <name>dfs.namenode.http-address.mycluster.nn1</name>
- <value>hadoop1:9870</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.mycluster.nn2</name>
- <value>hadoop2:9870</value>
- </property>
- <property>
- <name>