Hadoop 运行环境搭建(开发重点)

news2024/9/20 20:34:39

文章目录

  • Hadoop 运行环境搭建(开发重点)
    • 一、安装JDK
    • 二、安装配置 Hadoop
      • 1、安装 hadoop
      • 2、hadoop 目录结构
      • 3、设置免密登录
      • 4、完全分布式模式(开发重点)
        • 1)分发jdk
        • 2)集群配置
          • (1) 集群部署规划
          • (2) 配置文件说明
          • (3) 配置集群
        • 4) 集群基本测试
          • (1) 上传文件到集群
        • 5) 配置历史服务器

Hadoop 运行环境搭建(开发重点)

一、安装JDK

将 hadoop 的安装包和 jdk 的安装包,上传到 hadoop102 的 /opt/software 目录下
在这里插入图片描述
输入命令:tar -zxvf jdk-8u212-linux-x64.tar.gz -C /opt/ 将jdk压缩包解压到 /opt 目录下
在这里插入图片描述
输入命令: mv jdk1.8.0_212/ jdk1.8 包的名字太长了我们给他改成jdk1.8
在这里插入图片描述
然后接下来,配置jdk的环境变量
输入命令:vim /etc/profile 添加以下的变量
在这里插入图片描述

export JAVA_HOME=/opt/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin

输入命令:source /etc/profile 保存配置
输入命令:java -version 可以看到jdk安装成功了

在这里插入图片描述

二、安装配置 Hadoop

1、安装 hadoop

/opt/software 目录下的hadoop压缩包,解压到 /opt 目录下
输入命令: tar -zxvf hadoop-3.1.3.tar.gz -C /opt 可以看到 opt目录下就有hadoop包了
在这里插入图片描述
输入命令:vim /etc/profile 配置Hadoop的环境变量
在这里插入图片描述

export HADOOP_HOME=/opt/hadoop-3.1.3
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root

输入命令:source /etc/profile 让环境生效
输入命令:hadoop version,可以看到hadoop安装成功
在这里插入图片描述

2、hadoop 目录结构

查看 hadoop 的目录结构
在这里插入图片描述
hdfs 是存储的,mapred 是计算的,yarn是资源调度的
hadoop 重要目录:
(1)bin 目录:存放对 Hadoop 相关服务(hdfs,yarn,mapred)进行操作的脚本
(2)etc 目录:Hadoop 的配置文件目录,存放 Hadoop 的配置文件
(3)lib 目录:存放 Hadoop 的本地库(对数据进行压缩解压缩功能)
(4)sbin 目录:存放启动或停止 Hadoop 相关服务的脚本
(5)share 目录:存放 Hadoop 的依赖 jar 包、文档、和官方案例

3、设置免密登录

输入命令:cd .ssh
在这里插入图片描述
输入命令:ssh-keygen -t rsa 然后按三次回车
就会生成两个文件 id_rsa(私钥)、id_rsa.pub(公钥)
在这里插入图片描述)将公钥拷将公钥拷贝到要免密登录的目标机器上
ssh-copy-id hadoop102
ssh-copy-id hadoop103
ssh-copy-id hadoop104
在这里插入图片描述
现在登录到其他的虚拟机上就不会输密码了
在这里插入图片描述
注意
还需要在 hadoop103 上采用 root 账号配置一下无密登录到 hadoop102、hadoop103、
hadoop104 服务器上。
还需要在 hadoop104 上采用 root 账号配置一下无密登录到 hadoop102、hadoop103、
hadoop104 服务器上。
还需要在 hadoop102 上采用 root 账号,配置一下无密登录到 hadoop102、hadoop103、
hadoop104
在这里插入图片描述

4、完全分布式模式(开发重点)

1)准备三台客户机(关闭防火墙,静态IP,主机名称)
2)安装JDK
3)配置环境变量
4)安装 Hadoop
5)配置环境变量
6)配置集群
7)单点启动
8)配置ssh
9)群起并测试集群

1)分发jdk

在 hadoop102 上,将hadoop12 中 /opt/jdk1.8 目录拷贝到 hadoop103,hadoop104 上面去
输入命令:scp -r $JAVA_HOME root@hadoop103:/opt
输入命令:scp -r $JAVA_HOME root@hadoop104:/opt
可以看到 hadoop103 和 hadoop104 也有jdk文件了
在这里插入图片描述
hadoop 也是同样的拷贝,拷贝到 hadoop103 和 hadoop104
输入命令: scp -r $HADOOP_HOME root@hadoop103:/opt
可以看到hadoop103 和 hadoop104 也有hadoop包了
在这里插入图片描述

2)集群配置

(1) 集群部署规划

注意:
NameNodeSecondaryNameNode 不要安装在同一台服务器
ResourceManager 也很消耗内存,不要和 NameNodeSecondaryNameNode 配置在
同一台机器上
在这里插入图片描述

(2) 配置文件说明

Hadoop 配置文件分两类:默认配置文件和自定义配置文件,只有用户想修改某一默认
配置值时,才需要修改自定义配置文件,更改相应属性值。
1、默认配置文件
在这里插入图片描述
2、自定义配置文件
core-site.xmlhdfs-site.xmlyarn-site.xmlmapred-site.xml 四个配置文件存放在
$HADOOP_HOME/etc/hadoop 这个路径上,用户可以根据项目需求重新进行修改配置

(3) 配置集群

1、核心配置文件
配置 core-site.xml
输入命令:cd $HADOOP_HOME/etc/hadoop 进入hadoop的配置的目录
在这里插入图片描述
输入命令:vim core-site.xml 配置core-site.xml 文件
在这里插入图片描述

<?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, software
  distributed 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 and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
	<!-- 指定 NameNode 的地址 -->
 <property>
 <name>fs.defaultFS</name>
 <value>hdfs://hadoop102:8020</value>
 </property>
 <!-- 指定 hadoop 数据的存储目录 -->
 <property>
 <name>hadoop.tmp.dir</name>
 <value>/opt/hadoop-3.1.3/data</value>
 </property>
 <!-- 配置 HDFS 网页登录使用的静态用户为 atguigu -->
 <property>
 <name>hadoop.http.staticuser.user</name>
 <value>aex</value>
 </property>
</configuration>

2、HDFS 配置文件
配置 hdfs-site.xml
输入命令:vim hdfs-site.xml
在这里插入图片描述

<?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, software
  distributed 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 and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<!-- nn web 端访问地址-->
<property>
 <name>dfs.namenode.http-address</name>
 <value>hadoop102:9870</value>
 </property>
<!-- 2nn web 端访问地址-->
 <property>
 <name>dfs.namenode.secondary.http-address</name>
 <value>hadoop104:9868</value>
 </property>
</configuration>

3、YARN 配置文件
配置yarn-site.xml
输入命令:vim yarn-site.xml
在这里插入图片描述

<?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, software
  distributed 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 and
  limitations under the License. See accompanying LICENSE file.
-->
<configuration>
 <!-- 指定 MR 走 shuffle -->
 <property>
 <name>yarn.nodemanager.aux-services</name>
 <value>mapreduce_shuffle</value>
 </property>
 <!-- 指定 ResourceManager 的地址-->
 <property>
 <name>yarn.resourcemanager.hostname</name>
 <value>hadoop103</value>
 </property>
 <!-- 环境变量的继承 -->
 <property>
 <name>yarn.nodemanager.env-whitelist</name>
 
<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CO
NF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAP
RED_HOME</value>
 </property>
</configuration>

4、MapReduce 配置文件
输入命令:vim mapred-site.xml

<?xml version="1.0"?>
<?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, software
  distributed 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 and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<!-- 指定 MapReduce 程序运行在 Yarn 上 -->
 <property>
 <name>mapreduce.framework.name</name>
 <value>yarn</value>
 </property>
</configuration>

在这里插入图片描述
5、在集群上分发1配置好的Hadoop配置文件
输入命令: scp -r $HADOOP_HOME root@hadoop103:$HADOOP_HOME 将配置分发给hadoop103
输入命令: scp -r $HADOOP_HOME root@hadoop104:$HADOOP_HOME 将配置分发给hadoop104
6、配置worekers
输入命令:vim worekers
在这里插入图片描述
5、进行初始化
输入命令:hdfs namenode -format 下面会出现很长一串
在这里插入图片描述
启动节点
输入命令:start-all.sh
在这里插入图片描述
在webUI 界面上查看 hdfs,浏览器输入 hadoop102:9870
在这里插入图片描述

4) 集群基本测试

(1) 上传文件到集群

输入命令:hdfs dfs -mkdrir /input 先在hdfs上创建一个 input目录
在这里插入图片描述
可以看到 hdfs 上已经有这个文件了
在这里插入图片描述
上传一个文件上去
输入命令: hdfs dfs -put jdk-8u212-linux-x64.tar.gz /input
在这里插入图片描述
可以看到文件已经上传上去了
在这里插入图片描述

5) 配置历史服务器

为了查看程序的历史运行情况,需要配置一下历史服务器,具体配置如下:
1、配置 mapred-site.xml
输入命令:vim mapred-site.xml
在这里插入图片描述

<?xml version="1.0"?>
<?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, software
  distributed 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 and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
<!-- 指定 MapReduce 程序运行在 Yarn 上 -->
 <property>
 <name>mapreduce.framework.name</name>
 <value>yarn</value>
 </property>
<!-- 历史服务器端地址 -->
<property>
 <name>mapreduce.jobhistory.address</name>
 <value>hadoop102:10020</value>
</property>
<!-- 历史服务器 web 端地址 -->
<property>
 <name>mapreduce.jobhistory.webapp.address</name>
 <value>hadoop102:19888</value>
</property>
</configuration>

2、分发配置
输入命令:scp -r /opt/hadoop-3.1.3/etc/hadoop/mapred-site.xml root@hadoop103:/opt/hadoop-3.1.3/etc/hadoop/mapred-site.xml mapred-site.xml
输入命令:scp -r /opt/hadoop-3.1.3/etc/hadoop/mapred-site.xml root@hadoop104:/opt/hadoop-3.1.3/etc/hadoop/mapred-site.xml mapred-site.xml
在这里插入图片描述
3、在hadoop102启动历史服务器
输入命令:mapred --daemon start historyserver
在这里插入图片描述
4、查看历史服务器是否启动
可以看到已经启动了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/393519.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

2.3 二分搜索技术

二分搜索算法是运用分治策略的典型例子。给定己排好府的 n个元素a10:n-1]&#xff0c;现要在这n个元素中找出一特定元素3。首先较容易想到的是用顺序搜索方法&#xff0c;逐个比较a10:1-1]中元素&#xff0c;直至找出元素&#xff0c;或搜索遍整个数组后确定&#xff0c;不在其…

现代HYUNDAI EDI需求分析

现代集团(HYUNDAI)是韩国一家以建筑、造船、汽车行业为主&#xff0c;兼营钢铁、机械、贸易、运输、水泥生产、冶金、金融、电子工业等几十个行业的综合性企业集团。本文主要介绍HYUNDAI 的EDI需求&#xff0c;带大家快速理清思路&#xff0c;明确EDI项目的推进流程。 通信标准…

前端——2.HTML标签1

这篇文章我们从0来介绍一下HTML的相关标签内容 目录 1.HTML语法规范 1.1基本语法概述 1.2标签关系 2.HTML的基本结构标签 2.1第一个HTML网页 2.2基本结构标签总结 1.HTML语法规范 下面&#xff0c;我们来看一下HTML的语法规范的内容 1.1基本语法概述 首先&#xff0c…

【0成本搭建个人博客】——Hexo+Node.js+Gitee Pages

目录 1、下载安装Git 2、下载安装Node.js 3、使用Hexo进行博客的搭建 4、更改博客样式 5、将博客上传到Gitee 6、更新博客 首先看一下Hexo的博客的效果。 1、下载安装Git Git 是一个开源的分布式版本控制系统&#xff0c;可以有效、高速地处理从很小到非常大的项目版本…

openpnnp - 载入板子后,要确定板子的放置角度

文章目录openpnnp - 载入板子后,要确定板子的放置角度概述用openpnp提供的功能来确定被夹住的板子的左下角原点位置和板子的角度备注ENDopenpnnp - 载入板子后,要确定板子的放置角度 概述 设备是有夹具的, 用百分表打过, 夹具本身在Z方向的平行度是没问题的. 但是, PCB板子的…

Flink Table Store 0.3 构建流式数仓最佳实践

摘要&#xff1a;本文整理自阿里巴巴高级技术专家&#xff0c;Apache Flink PMC 李劲松&#xff08;之信&#xff09;&#xff0c;在 FFA 2022 实时湖仓的分享。本篇内容主要分为四个部分&#xff1a;挑战&#xff1a;Streaming DW 面临的难题案例&#xff1a;FlinkFTS 典型场景…

Active Directory DNS备份和恢复

DNS是Active Directory域服务&#xff08;AD DS&#xff09;不可或缺的一部分&#xff0c;因为它全权负责DNS名称解析。当发生DNS服务器灾难时&#xff0c;无法在网络中查找资源&#xff0c;并且所有AD操作都将暂停。因此&#xff0c;恢复DNS服务器是绝对必要的。Active Direct…

JS实现css的hover效果,兼容移动端

Hi I’m Shendi JS实现css的hover效果&#xff0c;兼容移动端 功能概述 CSS的hover即触碰时触发&#xff0c;在电脑端鼠标触碰&#xff0c;移动端手指触摸 有的时候光靠css实现不了一些效果&#xff0c;例如元素触发hover&#xff0c;其他元素触发动画效果&#xff0c;所以需要…

npm i 安装报错

npm WARN EBADENGINE Unsupported engine { npm WARN… npm WARN deprecated stable0.1.8: Modern JS… 诸如此类的报错。大部分都是因为 node 版本问题&#xff01;比如node版本无法满足&#xff0c;对应项目里需要的那些模块和依赖所需要的条件。 有些模块对node版本是有要…

【兴趣探索】采用Docker部署Rustdesk自建服务器

采用Docker部署Rustdesk自建服务器 场景&#xff1a;本想找一个远程手机的软件&#xff0c;使用的三款都存在限制&#xff1a; ①向日葵一天只能远程三次&#xff0c;需要花钱升级会员 ②Todesk因为手机兼容问题&#xff0c;需要花钱买插件解决 ③Airdorid免费200M&#xf…

23年如何备考PMP考试呢?攻略+资料

我建议准备的最短时间至少1个半月到2个月&#xff0c;集中精力备考大约4个小时&#xff0c;大家可以根据自己的专注力的长短去调节每天的备考时间。 1、《PMBOK指南》第六版&#xff08;16天&#xff09; 教材是要读的&#xff0c;虽然说考试考纲和教材不太一样&#xff0c;但…

led灯性价比最高的品牌有哪些?2023名牌led灯有这些品牌值得推荐

Led灯是现在人造灯具中使用最为普遍的一种灯光&#xff0c;具有高效节能、光线柔和等特点&#xff0c;这方面有一些专业的品牌做的很不错&#xff0c;比如松下、南卡、雷士照明等等&#xff0c;那么它们好在哪儿呢&#xff1f; 一个是光线舒适度高。采用高品质的led灯珠&#…

网络编程之UDP套接字(四)

12. 基于 UDP 的套接字 UDP 是无链接的&#xff0c;可以实现服务端与多个客户端进行同时进行通讯&#xff0c;无论先启动哪一端都可以。&#xff08;qq 聊天 UDP 服务&#xff09; 12.1 基于 udp 套接字模板 UDP 服务端 s socket(AF_INET, SOCK_DGRAM) # 创建一个服务器的…

MySQL运维篇之分库分表

03、分库分表 3.1、介绍 3.1.1、问题分析 随着互联网及移动互联网的发展&#xff0c;应用系统的数据量也是呈指数式增长&#xff0c;若采用单数据库进行数据存储&#xff0c;存在以下性能瓶颈&#xff1a; IO瓶颈&#xff1a;热点数据太多&#xff0c;数据库缓存不足&#…

脑机接口科普0012——脑机接口的灭亡

本文禁止转载&#xff01;&#xff01;&#xff01;&#xff01;中国人比较好玩&#xff0c;好玩就好玩在&#xff0c;对于每个行业&#xff0c;都喜欢说一句话&#xff0c;XXX从入门到放弃&#xff01;我们才科普到第12小节&#xff0c;然后&#xff0c;我们这边就说到脑机接口…

Vue 使用 Export2Excel.js 导出多 sheet 的 excel

项目需求&#xff0c;导出多sheet的excel表格。 具体思路是&#xff1a;后端返回json数据&#xff0c;前端根据数据和具体的几项字段去导出excel表格&#xff0c;多sheet&#xff0c;多页表格到一个excel表里面&#xff0c;具体思路 根据Export2Excel插件&#xff0c;并修改插件…

NFTScan:怎么使用 NFT API 开发一个 NFT 数据分析平台?

对很多开发者来说&#xff0c;在 NFT 数据海洋中需要对每个 NFT 进行索引和筛选是十分困难且繁琐的&#xff0c;NFT 数据获取仍是一大问题。而数据平台提供的 API 使得开发者可以通过接口获取区块链上 NFT 的详细信息&#xff0c;并对其进行分析、处理、统计和可视化。在本篇文…

今天女神节,用python画个贺卡送给母亲吧

今天女神节&#xff0c;你给女神妈妈准备了什么祝福呢&#xff1f;如果还没有&#xff0c;那么画个贺卡送给她吧&#xff0c;在你眼里&#xff0c;她是一个什么样的人呢&#xff1f; 是"可爱"&#xff0c;“温柔”&#xff0c;“美丽”&#xff0c;“漂亮”&#xf…

OpenCV各模块函数使用实例(11)--- 矩阵和数组操作(Operations on arrays)

OpenCV各模块函数使用实例&#xff08;11&#xff09;M、矩阵和数组操作&#xff08;Operations on arrays&#xff09;本节描述矩阵的基本操作&#xff0c;这些操作是图像处理和其他数组算法实现的基本操作&#xff0c;包括矩阵的运算&#xff0c;特征值和特征向量&#xff0c…