5、 配置hdfs-site.xml
- <configuration>
- <property>
- <!—配置三台NameNode –>
- <name>dfs.nameservices</name>
- <value>ns1,ns2,ns3</value>
- </property>
- <property>
- <!—第一台NameNode的机器名和rpc端口,指定了NameNode和DataNode通讯用的端口号 –>
- <name>dfs.namenode.rpc-address.ns1</name>
- <value>bigdata-senior01.chybinmy.com:8020</value>
- </property>
- <property>
- <!—第一台NameNode的机器名和rpc端口,备用端口号 –>
- <name>dfs.namenode.serviceerpc-address.ns1</name>
- <value>bigdata-senior01.chybinmy.com:8022</value>
- </property>
- <property>
- <
!—第一台NameNode的http页面地址和端口号 –> - <name>dfs.namenode.http-address.ns1</name>
- <value>bigdata-senior01.chybinmy.com:50070</value>
- </property>
- <property>
- <!—第一台NameNode的https页面地址和端口号 –>
- <name>dfs.namenode.https-address.ns1</name>
- <value>bigdata-senior01.chybinmy.com:50470</value>
- </property>
-
- <property>
- <name>dfs.namenode.rpc-address.ns2</name>
- <value>bigdata-senior02.chybinmy.com:8020</value>
- </property>
- <property>
- <name>dfs.namenode.serviceerpc-address.ns2</name>
- <value>bigdata-senior02.chybinmy.com:8022</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.ns2</name>
- <value>bigdata-senior02.chybinmy.com:50070</value>
- </property>
- <property>
- <name>dfs.namenode.https-address.ns2</name>
- <value>bigdata-senior02.chybinmy.com:50470</value>
- </property>
-
-
- <property>
- <name>dfs.namenode.rpc-address.ns3</name>
- <value>bigdata-senior03.chybinmy.com:8020</value>
- </property>
- <property>
- <name>dfs.namenode.serviceerpc-address.ns3</name>
- <value>bigdata-senior03.chybinmy.com:8022</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.ns3</name>
- <value>bigdata-senior03.chybinmy.com:50070</value>
- </property>
- <property>
- <name>dfs.namenode.https-address.ns3</name>
- <value>bigdata-senior03.chybinmy.com:50470</value>
- </property>
-
- </configuration>
6、 配置core-site.xml
- <configuration>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/opt/modules/hadoopha/hadoop-2.5.0/data/tmp</value>
- </property>
- </configuration>
hadoop.tmp.dir设置hadoop临时目录地址,默认时,NameNode和DataNode的数据存在这个路径下。
7、 配置slaves文件
bigdata-senior01.chybinmy.com bigdata-senior02.chybinmy.com bigdata-senior03.chybinmy.com
8、 配置yarn-site.xml
- <configuration>
- <property>
- <name>yarn.nodemanager.aux-services</name>
- <value>mapreduce_shuffle</value>
- </property>
- <property>
- <name>yarn.resourcemanager.hostname</name>
- <value>bigdata-senior02.chybinmy.com</value>
- </property>
- <property>
- <name>yarn.log-aggregation-enable</name>
- <value>true</value>
- </property>
- <property>
- <name>yarn.log-aggregation.retain-seconds</name>
- <value>106800</value>
- </property>
- </configuration>
9、 分发到其他节点
分发之前先将share/doc目录删除,这个目录中是帮助文件,并且很大,可以删除。
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ scp -r /opt/modules/ /opt/modules/hadoopfederation bigdata-senior02.chybinmy.com:/opt/modules
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ scp -r /opt/modules/hadoopfederation bigdata-senior03.chybinmy.com:/opt/modules
10、 格式化NameNode
在第一台上进行NameNode格式化。
[hadoop@bigdata-senior01 hadoop-2.5.0]$ bin/hdfs namenode -format -clusterId hadoop-federation-clusterId这里一定要指定一个集群ID,使得多个NameNode的集群ID是一样的,因为这三个NameNode在同一个集群中,这里集群ID为hadoop-federation-clusterId。
在第二台NameNode上。
[hadoop@bigdata-senior02 hadoop-2.5.0]$ bin/hdfs namenode -format -clusterId hadoop-federation-clusterId在第二台NameNode上。
[hadoop@bigdata-senior03 hadoop-2.5.0]$ bin/hdfs namenode -format -clusterId hadoop-federation-clusterId11、 启动NameNode
在第一台、第二台、第三台机器上启动NameNode:
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start namenode
- [hadoop@bigdata-senior02 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start namenode
- [hadoop@bigdata-senior03 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start namenode
启动后,用jps命令查看是否已经启动成功。
查看HDFS Web页面,此时三个NameNode都是standby状态。
12、 启动DataNode
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start datanode
- [hadoop@bigdata-senior02 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start datanode
- [hadoop@bigdata-senior03 hadoop-2.5.0]$ sbin/hadoop-daemon.sh start datanode
启动后,用jps命令确认DataNode进程已经启动成功。
四十九、测试HDFS Federation
1、 修改core-site.xml
在bigdata-senior01机器上,修改core-site.xml文件,指定连接的NameNode是第一台NameNode。
[hadoop@bigdata-senior01 hadoop-2.5.0]$ vim etc/hadoop/core-site.xml
- <configuration>
- <property>
- <name>fs.defaultFS</name>
- <value>hdfs://bigdata-senior01.chybinmy.com:8020</value>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/opt/modules/hadoopfederation/hadoop-2.5.0/data/tmp</value>
- </property>
- </configuration>
2、 在bigdate-senior01上传一个文件到HDFS
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ bin/hdfs dfs -mkdir /tmp
- [hadoop@bigdata-senior01 hadoop-2.5.0]$ bin/hdfs dfs -put ~/shuffle_daily.sh /tmp/shuffle_daily.sh
3、 查看HDFS文件
可以看到,刚才的文件只上传到了bigdate-senior01机器上的NameNode上了,并没有上传到其他的NameNode上去。
这样,在HDFS的客户端,可以指定要上传到哪个NameNode上,从而来达到了划分NameNode的目的。
后记
这篇文章的操作步骤并不是工作中标准的操作流程,如果在成百上千的机器全部这样安装会被累死,希望读者可以通过文章中一步步地安装,从而初步了解到Hadoop的组成部分,协助过程等,这对于Hadoop的深入使用有很大的帮助。
本文详细介绍了Hadoop Federation的配置步骤,包括hdfs-site.xml、core-site.xml、slaves文件、yarn-site.xml的配置,以及NameNode和DataNode的启动与测试过程。通过在多台NameNode间分配集群ID,实现HDFS Federation,提升数据处理能力。
44万+

被折叠的 条评论
为什么被折叠?



