基于Hadoop平台的电信客服数据的处理与分析③项目开发:搭建基于Hadoop的全分布式集群---任务6:安装并配置Hadoop

任务描述

项目的运行环境为基于Hadoop的全分布式模式集群。

任务的主要内容为安装Hadoop分布式集群环境。

任务指导

Hadoop集群需要整个集群所有节点安装的Hadoop版本保持一致,并且拥有相同的配置

具体配置步骤如下:

1. 解压缩Hadoop的压缩包

2. 配置Hadoop的环境变量

3. 修改Hadoop的配置文件,Hadoop的配置文件存放在Hadoop安装目录下的etc/hadoop/中

4. 首先在一台节点对整个Hadoop集群进行配置,再将此节点的配置发送到集群的其它节点上。

5. 具体需要修改的Hadoop的配置文件包括 core-site.xml、hdfs-site.xml、mapred-site.xml、yarn-site.xml、hadoop-env.sh、slaves

任务实现

1. 安装Hadoop。在【master1】服务器解压并配置完成后,再复制到其它服务器。

在/opt/software目录下解压Hadoop的安装包;

输入【cd  /opt/software】命令转到/opt/software目录下;

输入【tar -xzf hadoop-2.10.1.tar.gz -C /opt/app/】命令解压;

2. 配置Hadoop环境变量,修改系统配置文件/etc/profile。

在集群中所有节点添加Hadoop的环境变量

输入【vi  /etc/profile】命令,编辑/etc/profile文件。

在/etc/profile文件尾部追加如下内容:

export HADOOP_HOME=/opt/app/hadoop-2.10.1
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

使用【source  /etc/profile】使配置文件生效。 

3. 进入hadoop的配置文件夹。

[root@master1 ~]# cd  $HADOOP_HOME/etc/hadoop

4. 配置core-site.xml文件。该文件存放在$HADOOP_HOME/etc/hadoop目录下,配置内容如下:

<?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>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master1:9000</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/opt/app/hadoop_path/tmp</value>
</property>
<property>
<name>fs.trash.interval</name>
<value>1440</value>
</property>
<property>
<name>fs.trash.checkpoint.interval</name>  
<value>0</value>
</property>
</configuration>

5. 配置 hdfs-site.xml 文件,该文件存放在$HADOOP_HOME/etc/hadoop目录下,配置内容如下:

<?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>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>slave2:9001</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/opt/app/hadoop_path/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/opt/app/hadoop_path/hdfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>

6. 配置 mapred-site.xml 文件。

首先,输入【cp  mapred-site.xml.template  mapred-site.xml】命令将mapred-site.xml.template命名为mapred-site.xml。

配置$HADOOP_HOME/etc/hadoop目录下的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>
<property>
<name>mapreduce.framework.name</name>  
<value>yarn</value>  
</property>  
<property>  
<name>mapreduce.jobhistory.address</name>  
<value>master1:10020</value>  
</property>  
<property>  
<name>mapreduce.jobhistory.webapp.address</name>  
<value>master1:19888</value>  
</property> 
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
<!-- 开启uber模式(针对小作业的优化) -->
<property>
<name>mapreduce.job.ubertask.enable</name>
<value>true</value>
</property>
<!-- 配置启动uber模式的最大map数 -->
<property>
<name>mapreduce.job.ubertask.maxmaps</name>
<value>9</value>
</property>
<!-- 配置启动uber模式的最大reduce数 -->
<property>
<name>mapreduce.job.ubertask.maxreduces</name>
<value>1</value>
</property>
</configuration>

7. 配置yarn-site.xml文件,该文件存放在$HADOOP_HOME/etc/hadoop目录下,配置内容如下:

<?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>
<property>  
<name>yarn.nodemanager.aux-services</name>  
<value>mapreduce_shuffle</value>  
</property>  
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>  
</property>  
<property>  
<name>yarn.resourcemanager.address</name>  
<value>master1:8032</value>  
</property>  
<property>  
<name>yarn.resourcemanager.scheduler.address</name>  
<value>master1:8030</value>  
</property>  
<property>  
<name>yarn.resourcemanager.resource-tracker.address</name>  
<value>master1:8031</value>  
</property>  
<property>  
<name>yarn.resourcemanager.admin.address</name>  
<value>master1:8033</value>  
</property>  
<property>  
<name>yarn.resourcemanager.webapp.address</name>  
<value>master1:8088</value>  
</property>  
</configuration>

8. 配置hadoop-env.sh文件,文件存放在$HADOOP_HOME/etc/hadoop目录下,配置文件的JAVA_HOME变量。如果不设置,无法正常启动集群。

输入【vim  hadoop-env.sh】打开准备修改的配置文件hadoop-env.sh,修改JAVA_HOME环境变量。

找到默认的JAVA_HOME配置修改为如下配置:

export JAVA_HOME=/opt/app/jdk1.8.0_181

在【hadoop-env.sh】文件末尾添加如下内容,使Hadoop在操作HBase能使用对应的类库:

export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/opt/app/hbase-2.3.5/lib/*

9. 配置slaves文件,该文件存在在$HADOOP_HOME/etc/hadoop目录下,删除默认的localhost,增加3个从节点的IP地址或host主机名。

slave1
slave2

10. 为Hadoop创建目录

[root@master1 ~]# mkdir -p /opt/app/hadoop_path/tmp
[root@master1 ~]# mkdir -p /opt/app/hadoop_path/hdfs/name
[root@master1 ~]# mkdir /opt/app/hadoop_path/hdfs/data

10. 将配置好的Hadoop复制到其他节点对应位置上,通过scp命令发送。

[root@master1 ~]# scp  -rq  /opt/app/hadoop-2.10.1  slave1:/opt/app
[root@master1 ~]# scp  -rq  /opt/app/hadoop-2.10.1  slave2:/opt/app

[root@master1 ~]# scp  -rq  /opt/app/hadoop_path  slave1:/opt/app
[root@master1 ~]# scp  -rq  /opt/app/hadoop_path  slave2:/opt/app

转发后在所有节点执行【 source /etc/profile 】命令重新加载环境变量

  • 21
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值