阿里云服务器部署安装hadoop与elasticsearch踩坑笔记

2023-09-13 20:56:17

2023-09-12 14:00——2023.09.13 20:06

目录

00、软件版本

01、阿里云服务器部署hadoop

1.1、修改四个配置文件

1.1.1、core-site.xml

1.1.2、hdfs-site.xml

1.1.3、mapred-site.xml

1.1.4、yarn-site.xml

1.2、修改系统/etc/hosts文件与系统变量

1.2.1、修改主机名解析文件/etc/hosts

1.2.2、修改系统环境变量/etc/profile.d/my_env.sh

02、阿里云服务器部署elasticsearch

2.1、三节点的同样操作

2.2、修改es的elasticsearch.yml文件


00、软件版本

环境及软件版本:

  1. centOS 7
  2. jdk-1.8
  3. hadoop-3.3.4
  4. elasticsearch-7.17.6

01、阿里云服务器部署hadoop

按照尚硅谷的教程安装hadoop-3.3.4,尚硅谷大数据技术之Hadoop.docx

1.1、修改四个配置文件

/opt/module/hadoop/hadoop-3.3.4/etc/hadoop

1.1.1、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://bd1:8020</value>
</property>
<!-- 指定hadoop数据的存储目录 -->
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/opt/module/hadoop/hadoop-3.3.4/data</value>
</property>

<!-- 配置HDFS网页登录使用的静态用户为atguigu -->
    <property>
        <name>hadoop.http.staticuser.user</name>
        <value>xxh</value>
</property>

<!-- 配置该atguigu(superUser)允许通过代理访问的主机节点 -->
    <property>
        <name>hadoop.proxyuser.xxh.hosts</name>
        <value>*</value>
</property>
<!-- 配置该atguigu(superUser)允许通过代理用户所属组 -->
    <property>
        <name>hadoop.proxyuser.xxh.groups</name>
        <value>*</value>
</property>
<!-- 配置该atguigu(superUser)允许通过代理的用户-->
    <property>
        <name>hadoop.proxyuser.xxh.users</name>
        <value>*</value>
</property>
</configuration>

1.1.2、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>bd1:9870</value>
    </property>

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

    <!-- 测试环境指定HDFS副本的数量1 -->
    <property>
        <name>dfs.replication</name>
        <value>3</value>
</property>

<!-- 关闭 hdfs 文件权限检查 -->
<property>
    <name>dfs.permissions</name>
    <value>false</value>
</property>
</configuration>

1.1.3、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>bd1:10020</value>
</property>

<!-- 历史服务器web端地址 -->
<property>
    <name>mapreduce.jobhistory.webapp.address</name>
    <value>bd1:19888</value>
</property>
</configuration>

1.1.4、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>

<!-- Site specific YARN configuration properties -->
<!-- Site specific YARN configuration properties -->
<!-- 指定MR走shuffle -->
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>

    <!-- 指定ResourceManager的地址-->
    <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>bd2</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>

    <!-- yarn容器允许分配的最大最小内存 -->
    <property>
        <name>yarn.scheduler.minimum-allocation-mb</name>
        <value>512</value>
    </property>
    <property>
        <name>yarn.scheduler.maximum-allocation-mb</name>
        <value>4096</value>
    </property>
    
    <!-- yarn容器允许管理的物理内存大小 -->
    <property>
        <name>yarn.nodemanager.resource.memory-mb</name>
        <value>4096</value>
    </property>
    
    <!-- 关闭yarn对物理内存和虚拟内存的限制检查 -->
    <property>
        <name>yarn.nodemanager.pmem-check-enabled</name>
        <value>false</value>
    </property>
    <property>
        <name>yarn.nodemanager.vmem-check-enabled</name>
        <value>false</value>
</property>
<!-- 开启日志聚集功能 -->
<property>
    <name>yarn.log-aggregation-enable</name>
    <value>true</value>
</property>

<!-- 设置日志聚集服务器地址 -->
<property>
    <name>yarn.log.server.url</name>
    <value>http://bd1:19888/jobhistory/logs</value>
</property>

<!-- 设置日志保留时间为7天 -->
<property>
    <name>yarn.log-aggregation.retain-seconds</name>
    <value>604800</value>
</property>                                                                                                                                                                                                                                                               
</configuration>

1.2、修改系统/etc/hosts文件与系统变量

1.2.1、修改主机名解析文件/etc/hosts

[root@bd1 ~]# vim /etc/hosts

# 外网ip地址
x.x.x.x bd1 
x.x.x.x bd2
x.x.x.x bd3

# 内网ip地址(使用命令ifconfig命令进行查看)
x.x.x.x bd1
x.x.x.x bd2 
x.x.x.x bd3

1.2.2、修改系统环境变量/etc/profile.d/my_env.sh

[root@bd1 ~]# vim /etc/profile.d/my_env.sh

# HADOOP_HOME
export HADOOP_HOME=/opt/module/hadoop/hadoop-3.3.4
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin

# HADOOP相关配置【重中之重,使得root用户可以直接运行hadoop】
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

# JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_212
export PATH=$PATH:$JAVA_HOME/bin

# HADOOP_HOME
export HADOOP_HOME=/opt/module/hadoop/hadoop-3.3.4
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin

# zookeeper
export ZK_HOME=/opt/module/zookeeper
export PATH=$ZK_HOME/bin:$PATH

# kafka
#KAFKA_HOME
export KAFKA_HOME=/opt/module/kafka
export PATH=$PATH:$KAFKA_HOME/bin

export PATH=$PATH:/opt/software/tool

# HADOOP相关配置
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

02、阿里云服务器部署elasticsearch

es安装教程

  1. Linux搭建es集群详细教程(最终版)_es集群搭建_Nick丶Xin的博客-CSDN博客
  2. Linux安装elk_upward337的博客-CSDN博客
  3. [2020-04-06T12:57:13,793][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exce_Lan_Se_Tian_Ma的博客-CSDN博客

2.1、三节点的同样操作

三节点集群的服务器,每台服务器都需要:

  1. 创建es用户,useradd espasswd es
  2. 安装elasticsearch,tar -zxvf elasticsearch-7.17.6-linux-x86_64.tar.gz -C /opt/module/es/
  3. 修改elasticsearch文件夹权限,chown -R es:es /opt/module/es/
  4. 修改/etc/...目录下的若干配置文件,vi /etc/security/limits.confvi /etc/security/limits.d/20-nproc.confvi /etc/sysctl.conf
  5. 修改/opt/module/es/elasticsearch-7.17.6/config/jvm.options文件。

启动elasticsearch时,需要切换到es用户,使用如下命令在后台启动es:

  1. [es@bd1 root]$ nohup /opt/module/es/elasticsearch-7.17.6/bin/elasticsearch & # 后台运行elasticsearch
  2. [es@bd2 root]$ nohup /opt/module/es/elasticsearch-7.17.6/bin/elasticsearch & # 后台运行elasticsearch
  3. [es@bd3 root]$ nohup /opt/module/es/elasticsearch-7.17.6/bin/elasticsearch & # 后台运行elasticsearch

2.2、修改es的elasticsearch.yml文件

修改每台服务器的elasticsearch.yml文件(/opt/module/es/elasticsearch-7.17.6/config/elasticsearch.yml),如下两个参数的配置每台服务器都不一样:

  1. node.name: node-1 # 节点名称,每个节点的名称不能重复
  2. network.host: 内网ip地址 # 内网ip地址,每个节点的地址不能重复

# /opt/module/es/elasticsearch-7.17.6/config/elasticsearch.yml

#es加入如下配置

#集群名称
cluster.name: cluster-es-7.17.6
#节点名称,每个节点的名称不能重复
node.name: node-1
#内网ip地址,每个节点的地址不能重复
network.host: 内网ip地址
#是不是有资格主节点
node.master: true
node.data: true

#http端口
http.port: 9200
# 服务通信端口
transport.port: 9300

# 数据文件及日志存储路径
path.data: /opt/module/es/elasticsearch-7.17.6/data
path.logs: /opt/module/es/elasticsearch-7.17.6/logs

# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现
discovery.seed_hosts: ["bd1:9300","bd2:9300","bd3:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群内同时启动的数据任务个数,默认是 2 个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认 4 个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认 4 个
cluster.routing.allocation.node_initial_primaries_recoveries: 16

😊😘加油~

更多推荐

RPC和HTTP调用的区别

RPC(RemoteProcedureCall)和HTTP调用都是用于实现远程通信的方法,但它们有一些重要的区别:通信协议:RPC:RPC通常使用自定义的二进制协议或者序列化协议(如Protobuf、Thrift)来进行通信。这些协议更加高效,因为它们可以将数据以二进制形式传输,减少了序列化和反序列化的开销。HTTP调

安卓Android_手机安装burp的https_CA证书

安卓Android_手机安装burp的https_CA证书文章目录安卓Android_手机安装burp的https_CA证书1打卡电脑wif热点,手机连上电脑的热点2burp点击--》Proxysettings3点击add---》新增代理地址和端口4设置好-展示5手机连上电脑的wifi热点6点击查看ip地址与burp代

免费,开源,可批量的离线图片文字提取软件OCR

Umi-OCR文字识别工具免费,开源,可批量的离线OCR软件适用于Windows7x64及以上免费:本项目所有代码开源,完全免费。方便:解压即用,离线运行,无需网络。批量:可批量导入处理图片,结果保存到本地txt/md/jsonl多种格式文件。也可以即时截屏识别。高效:采用PaddleOCR-jsonC++识别引擎。只

AI实战营第二期 第八节 《MMSegmentation代码课》——笔记9

AI实战营第二期第八节《MMSegmentation代码课》【课程链接】https://www.bilibili.com/video/BV1uh411T73q/【讲师介绍】张子豪OpenMMLab算法工程师【学习形式】录播+社群答疑【作业布置】本次课程为实战课,需提交笔记+作业。课程大纲:环境配置预训练模型预测图片、视

Prompt、RAG、微调还是重新训练?选择正确的生成式 AI 的方法指南

文章目录一、前言二、主要内容三、总结🍉CSDN叶庭云:https://yetingyun.blog.csdn.net/一、前言这篇博客试图根据一些常见的可量化指标,为您选择适合您用例的生成式人工智能方法提供指导。生成式AI正在以惊人的速度发展,许多组织都在尝试利用这项先进技术来解决业务问题。虽然有很多流行的方法可供选

漫谈:C语言 C++ 迷惑的语句、分号、大括号

C语言设计得很麻拐。初学者经常面临这样的麻烦:多了一个分号,if条件没通过却执行了少了一个分号,编译不下去,报奇怪的错误if(a>0);++x;这个代码的“++x”无论如何都会被执行,旁观者很快就能看出来是因为if语句后面多了一个分号。structA{inta;}这个代码会导致其后的代码(甚至是另外一个文件,取决于头文

人工智能术语翻译(六)

文章目录摘要UVWXYZ摘要人工智能术语翻译第六部分,包括U、V、W、X、Y、Z开头的词汇!U英文术语中文翻译常用缩写备注UglyDucklingTheorem丑小鸭定理Unbiased无偏UnbiasedEstimate无偏估计UnbiasedSampleVariance无偏样本方差UnconstrainedOpti

Wi-Fi7将带来前所未有的快捷、稳定的互联网,更快的传输速度

随着科技的飞速发展,无线连接技术也日渐成熟与先进。Wi-Fi,作为我们日常生活和工作中不可或缺的一部分,也正在迎来技术的革新。我们将有机会见识到新一代的Wi-Fi技术--Wi-Fi7,它将带来前所未有的快捷、稳定的互联网体验。首先,Wi-Fi7将会为我们带来更快的传输速度。预计新一代Wi-Fi(Wi-Fi7)的最高理论

快速入门:如何使用HTTP代理进行网络请求

今天我要和大家分享如何使用HTTP代理进行网络请求的快速入门指南。如果你想了解如何通过代理服务器发送和接收网络请求,那么这篇文章将为你提供一个简单而全面的指南。第一部分:HTTP代理的基础知识HTTP代理服务器充当了客户端和目标服务器之间的中间人角色。当你发送网络请求时,请求首先发送到代理服务器,然后由代理服务器将请求

基于Xml方法的Bean的配置-实例化Bean的方法-构造方法

SpringBean的配置详解Bean的实例化配置Spring的实例化方法主要由以下两种构造方法实例化底层通过构造方法对bean进行实例化构造方法实例化bean又分为无参方法实例化和有参方法实例化,在Spring中配置的<bean>几乎都是无参构造该方式,默认是无参构造方法,在此处不赘述。下面讲解有参构造方法实例化Be

Mybatis的mapper.xml批量插入、修改sql

今天要有个功能,要进行一批数据的插入和修改,为了不频繁调用数据库,所以想到了批量插入和修改,因为从毕业后,就没写过批量插入和批量修改,所以在这里记录一下,避免后续再遇到忘记怎么写了批量插入(传入的参数是List<实体>list):<insertid="insertList"keyColumn="id"keyProper

热文推荐