centos7下hadoop3.0搭建文档

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7下hadoop3.0搭建文档相关的知识,希望对你有一定的参考价值。

 准备资源和环境

下载Centos 7.2 iso安装镜像,jdk1.8 for Linux压缩包,hadoop3.0.0压缩包。下载链接分别如下:

https://www.centos.org/download/

http://www.Oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

http://hadoop.apache.org/releases.html

如下:

[[email protected] home]# ls

hadoop-3.0.0-alpha4  hadoop-3.0.0-alpha4.tar.gz  jdk-8u101-linux-x64.rpm

[[email protected] home]#

 

 

准备三台centos7的系统:

Master:192.168.161.133

Slave1:192.168.161.135

Slave2:192.168.161.136

 

二安装jdkhadoop

1 安装jdk

rpm -ivh jdk-8u101-linux-x64.rpm

查看jdk安装目录

rpm -qal|grep java

 

 

2 安装hadoop

进入home目录,直接解压hadoop即可

tar -zvxf  hadoop-3.0.0-alpha4.tar.gz

 

3. 环境变量

 

vi /etc/profile

#Hadoop 3.0
export HADOOP_HOME=/home/hadoop-3.0.0-alpha4
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

source /etc/profile

注意:/home/hadoop-3.0.0-alpha4为解压路径

 

三配置hadoop

      先在192.168.161.133上面配置hadoop,然后scpslave上。

hadoop3.0需要配置的文件有core-site.xmlhdfs-site.xmlyarn-site.xmlmapred-site.xmlhadoop-env.shworkers

 

 

 

新建目录:

cd /home/hadoop-3.0.0-alpha4

mkdir tmp

mkdir -p hdfs/{data,name}

 

1 core-site.xml配置文件

<configuration>

<property>

    <name>fs.defaultFS</name>

     <value>hdfs://192.168.161.133:9000</value>

  </property>

 

  <property>

      <name>hadoop.tmp.dir</name>

      <value>file:///home/hadoop-3.0.0-alpha4/tmp</value>

  </property>

</configuration>

 

 

 

2 hdfs-site.xml配置文件

 

<configuration>

 <property>

   <name>dfs.replication</name>

   <value>3</value>

 </property>

 <property>

   <name>dfs.namenode.name.dir</name>

   <value>file:///home/hadoop-3.0.0-alpha4/hdfs/name</value>

 </property>

 <property>

   <name>dfs.datanode.data.dir</name>

   <value>file:///home/hadoop-3.0.0-alpha4/hdfs/data</value>

 </property>

 <property>

   <name>dfs.namenode.secondary.http-address</name>

   <value>192.168.161.135:9001</value>

 </property>

</configuration>

 

 

 

 

 

3 works

 

192.168.161.135

192.168.161.136

 

 

 

4 mapred-site配置

 

<configuration>

    <property>

        <name>mapreduce.framework.name</name>

        <value>yarn</value>

    </property>

 

<property>

 <name>mapreduce.application.classpath</name>

 <value>

  /home/hadoop-3.0.0-alpha4/etc/hadoop,

  /home/hadoop-3.0.0-alpha4/share/hadoop/common/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/common/lib/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/hdfs/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/hdfs/lib/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/mapreduce/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/mapreduce/lib/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/yarn/*,

  /home/hadoop-3.0.0-alpha4/share/hadoop/yarn/lib/*

 </value>

</property>

</configuration>

 

 

 

5 yarn-site.xml配置

 

<configuration>

 

<!-- Site specific YARN configuration properties -->

    <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.ShuffleHandle</value>

    </property>

    <property>

        <name>yarn.resourcemanager.resource-tracker.address</name>

        <value>192.168.161.133:8025</value>

    </property>

    <property>

        <name>yarn.resourcemanager.scheduler.address</name>

        <value>192.168.161.133:8030</value>

    </property>

    <property>

        <name>yarn.resourcemanager.address</name>

        <value>192.168.161.133:8040</value>

    </property>

</configuration>

 

 

 

6 hadoop-env.sh中配置java_home

 

export JAVA_HOME=/usr/java/jdk1.8.0_101

 

 

 

 

 

7 将配置好的hadoop文件夹传输到slave上面

cd /home/

scp -r hadoop-3.0.0-alpha4  [email protected]:/home/

scp -r hadoop-3.0.0-alpha4  [email protected]:/home/

 

 

启动hadoop

1. 格式化namenode

bin/hdfs namenode -format  

2. 启动dfsyarn

sbin/start-dfs.sh  

sbin/start-yarn.sh  

 

启动会报错,解决方法:

 

2.1 sbin/start-dfs.sh  报错:

是因为缺少用户定义造成的,所以分别编辑开始和关闭脚本 
vim sbin/start-dfs.sh 
vim sbin/stop-dfs.sh 
在顶部空白处添加内容: 
HDFS_DATANODE_USER=root 
HADOOP_SECURE_DN_USER=hdfs 
HDFS_NAMENODE_USER=root 
HDFS_SECONDARYNAMENODE_USER=root 

 

 

2.2 sbin/start-yarn.sh  报错

是因为缺少用户定义造成的,所以分别编辑开始和关闭脚本 
$ vim sbin/start-yarn.sh 
$ vim sbin/stop-yarn.sh 

在顶部空白处添加内容: 

YARN_RESOURCEMANAGER_USER=root

HADOOP_SECURE_DN_USER=yarn

YARN_NODEMANAGER_USER=root

 

 

2.3 可以采用另外一种方法启动

启动hadoop

首先格式化主节点命名空间,使用命令:

/home/joe/hadoop-3.0.0-alpha1/bin/hdfsnamenode –formate

其次在主节点上启动存储服务资源管理主服务。使用命令:

/home/joe/hadoop-3.0.0-alpha1/sbin/hadoop-daemon.sh start namenode #启动主存储服务

/home/joe/hadoop-3.0.0-alpha1/sbin/yarn-daemon.sh start resourcemanager # 启动资源管理服务。

最后在从节点上启动存储从服务资源管理从服务(以下两条命令要在两台机器上分别执行)

/home/joe/hadoop-3.0.0-alpha1/sbin/hadoop-daemon.sh start datanode #启动从存储服务

/home/joe/hadoop-3.0.0-alpha1/sbin/yarn-daemon.sh start nodemanager #启动资源管理从服务

 

3 通过jps命令查看

master

[[email protected] hadoop-3.0.0-alpha4]# jps

3842 ResourceManager

4217 Jps

2766 NameNode

[[email protected] hadoop-3.0.0-alpha4]#

 

Slave1

[[email protected] home]# jps

2561 DataNode

3333 Jps

3224 NodeManager

2621 SecondaryNameNode

[[email protected] home]#

 

Slave2:

[[email protected] home]# jps

3256 Jps

2955 DataNode

3084 NodeManager

[[email protected] home]#

 

 

4现在便可以打开页面http://192.168.161.133:8088http://192.168.161.133:9870;看到下面两个页面时说明安装成功。

 

 

 

 

 

五借鉴网址:

http://blog.csdn.net/u010499619/article/details/52886872

http://www.linuxidc.com/Linux/2016-11/137244.htm

http://blog.csdn.net/u013725455/article/details/70147331

http://www.linuxidc.com/Linux/2016-10/136166.htm

 

 

 

 

 

 

 

 


以上是关于centos7下hadoop3.0搭建文档的主要内容,如果未能解决你的问题,请参考以下文章

centos7下hadoop3.0搭建文档

centos7下hadoop3.0搭建文档

超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群

基于Cent OS7搭建apache网站后的访问控制配置详解

十cent OS下搭建SVN服务器

CentOS7 搭建LVS+keepalived负载均衡