当前位置: 首页 > news >正文

十二、伪分布式配置

一、 Hadoop 环境变量文件(hadoop - env.sh)

该文件主要是配置 Hadoop 的环境变量。

在此文件的末尾添加 JAVA_HOME 的目录,

定义 HDFS 和 YARN 的相关角色用户为 root 用户。

  • 执行以下命令进行操作:

cd $HADOOP_HOME/etc/hadoop
vim hadoop-env.sh
  • 在文末加上以下配置:

export JAVA_HOME=/opt/module/jdk1.8.0_281/
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root

二、核心配置文件(core - site.xml)

此文件是 Hadoop 核心的配置项,

例如配置 HDFS 和 MapReduce 常用的 I/O 设置等。

  • 执行命令:

cd $HADOOP_HOME/etc/hadoop
vim core-site.xml
  • 文件内容修改如下:

<configuration>
<!-- 指定 NameNode 地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
<!-- 指定 Hadoop 数据存放目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/module/hadoop-3.2.1/tmp</value>
</property>
</configuration>

core-site.xml 文件修改内容,如图 3.19 所示。

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
​http://www.apache.org/licenses/LICENSE-2.0
​Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
-->
​
<!-- Put site-specific property overrides in this file. -->
​
<configuration>
<!-- 指定NameNode地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
<!-- 指定hadoop数据存放目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/hadoop/tmp</value>
</property>
</configuration>

图 3.19 core - site.xml 文件

在以上配置信息中,

  • 必须要配置 hadoop.tmp.dir 参数。

  • 如果没有配置,则系统会使用默认的目录为其临时目录。

  • 该默认目录在每次系统重启后会被删除,必须重新执行 Hadoop 文件系统格式化命令,否则运行 Hadoop 就会报错。

三、 HDFS 配置文件(hdfs - site.xml)

1、此文件主要配置:

  • NameNode 与 secondaryNameNode 的访问地址;

  • NameNode 与 DataNode 数据的存放路径;

  • FSImage、Edits、Checkpoint 的存放位置;

  • 设置文件的副本数,一份文件保存多少份;

  • 设置文件存储的 block 块大小 128M。

2、执行命令:

cd $HADOOP_HOME/etc/hadoop
vim hdfs-site.xml
  • 文件内容如下:

<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
  • hdfs-site.xml 文件修改内容如图 3.20 所示。

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
​http://www.apache.org/licenses/LICENSE-2.0
​Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
-->
​
<!-- Put site-specific property overrides in this file. -->
​
<configuration>
<property>
<!-- 伪分布式只能设置成1 -->
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

<value>1</value>——伪分布式智能设置为1

图 3.20 hdfs - site.xml 文件

四、 YARN 配置文件(yarn - site.xml)

此文件是 YARN 守护进程的配置项,

包括资源管理器、web 应用代理服务器和节点管理器等。

  • 执行命令:

cd $HADOOP_HOME/etc/hadoop
vim yarn-site.xml
  • 文件内容如下:

<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
  • yarn-site.xml 文件修改内容如图 3.21 所示。

<?xml version="1.0"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
​http://www.apache.org/licenses/LICENSE-2.0
​Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
-->
​
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>

图 3.21 yarn - site.xml 文件

五、MapReduce 配置文件(mapred - site.xml)

此文件是 MapReduce 守护进程的配置项,包括作业历史服务器等。

  • 执行命令:

cd $HADOOP_HOME/etc/hadoop
vim mapred-site.xml
  • 文件内容如下:

<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
</configuration>
  • mapred-site.xml 文件修改内容如图 3.22 所示。

<!--Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
-->
​
<!-- Put site-specific property overrides in this file. -->
​
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}</value>
</property>
</configuration>

图 3.22 mapred - site.xml 文件

http://www.dtcms.com/a/423459.html

相关文章:

  • VScode通过跳板机连接内网服务器
  • wordpress小说下载站建设银行网站如何下载u盾
  • 餐饮行业做微信网站有什么好处网站上图怎么用ps做
  • 设计的网站都有哪些功能辛集哪做网站
  • PostgreSQL的逻辑复制spill溢出案例和启停库逻辑
  • OpenMQTTGateway 技术全解:统一多协议到 MQTT 的开源网关
  • 数据结构——二叉树学习
  • 动规:回文串问题
  • PostgreSQL WAL 日志发展史 - pg7
  • 商丘企业网站建设团队网站设计的内容以及步骤
  • 网站域名所有人wordpress 子域名
  • ListenHub:AI播客平台,一句话生成播客
  • 知名的媒体发稿代理有哪些
  • PyTorch nn.Linear 终极详解:从零理解线性层的一切(含可视化+完整代码)
  • 大型企业级金融信贷平台需求报告
  • 【算法】小点:List.remove
  • 文件扩展名.js .jsx .ts .tsx区别(JavaScript扩展名、React扩展名、TypeScript扩展名)
  • MySQL 在金融系统中的应用:强一致性与高可用架构实战
  • 销售型网站营销目标查网址是否安全
  • 媒体发稿平台如何选
  • 靠谱的综合门户媒体发稿如何选
  • 学习:uniapp全栈微信小程序vue3后台(29)
  • 装修设计网站排名新浪短网址链接
  • kali 01——安装及简要介绍
  • 宁夏政务网站建设标准wordpress是瀑布流吗
  • 烟台 网站建设中国广告在国外投放案例
  • OpenAI秘密测试ChatGPT安全路由,情感对话触发GPT-5严格审查
  • 赋能制造新质生产力:制造业专用低代码平台选型指南(2025)
  • 智慧工地系统:建筑行业数字化转型的核心趋势,集成云计算、物联网、大数据等技术,构建覆盖施工全周期的智能化管理体系。
  • 做一个网站需要多少人权威的手机网站制作