集群部署规划建议:
1.NameNode和SecondaryNameNode不要安装在同一台服务器
2.ResourceManager也很消耗内存,不要和NameNode、SecondaryNameNode配置在同一台机器上。
根据我们的实际情况,我们配置如下
|
hadoop100 |
hadoop101 |
hadoop102 | |
|
HDFS |
NameNode DataNode |
DataNode |
SecondaryNameNode DataNode |
|
YARN |
NodeManager |
ResourceManager NodeManager |
NodeManager |
(六)修改配置文件
这里一共有5个文件要配置:分别是core-site.xml,hdfs-site.xml,yarn-site.xml,mapred-site.xml,workers。 五个配置文件都存放在$HADOOP_HOME/etc/hadoop这个路径下。
(1)core-site.xml核心配置文件
当前要操作的文件是:/opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml我们使用编辑器,将它的文件内容修改如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- 指定NameNode的地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop100:8020</value>
</property>
<!-- 指定hadoop数据的存储目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/module/hadoop-3.1.3/data</value>
</property>
<!-- 配置HDFS网页登录使用的静态用户为root-->
<property>
<name>hadoop.http.staticuser.user</name>
<value>root</value>
</property>
</configuration>
(2)HDFS配置文件
接下来配置第二个文件,/opt/module/hadoop-3.1.3/etc/hadoop/hdfs-site.xml
将它的文件内容修改如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- nn web端访问地址-->
<property>
<name>dfs.namenode.http-address</name>
<value>hadoop100:9870</value>
</property>
<!-- 2nn web端访问地址-->
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>hadoop102:9868</value>
</property>
</configuration>
(3)YARN配置文件
配置/opt/module/hadoop-3.1.3/etc/hadoop/yarn-site.xml,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- 指定MR走shuffle -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!-- 指定ResourceManager的地址-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop101</value>
</property>
<!-- 环境变量继承 -->
<property>
<name>yarn.nodemanager.env-whitelist</name>
<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>
</property>
</configuration>
(4)MapReduce配置文件
配置/opt/module/hadoop-3.1.3/etc/hadoop/mapred-site.xml,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- 指定MapReduce程序运行在Yarn上 -->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
(5)配置workers
要修改的文件是:/opt/module/hadoop-3.1.3/etc/hadoop/workers,在该文件中增加如下内容:
hadoop100
hadoop101
hadoop102
注意:该文件中添加的内容结尾不允许有空格,文件中不允许有空行。

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



