本章主要介绍下在Linux系统下的Hadoop2.5.0伪分布式环境搭建步骤。首先要搭建Hadoop伪分布式环境,需要完成一些前置依赖工作,包括创建用户、安装JDK、关闭防火墙等。

一、创建hadoop用户

使用root账户创建hadoop用户,为了在实验环境下便于操作,赋予hadoop用户sudo权限。具体操作代码如下:

useradd hadoop # 添加hadoop用户
passwd hadoop # 设置密码
visudo
hadoop ALL=(root)NOPASSWD:ALL

二、Hadoop伪分布式环境搭建

1、关闭Linux中的防火墙和selinux

禁用selinux,代码如下:

sudo vi /etc/sysconfig/selinux # 打开selinux配置文件
SELINUX=disabled # 修改SELINUX属性值为disabled

关闭防火墙,代码如下:

sudo service iptables status # 查看防火墙状态
sudo service iptables stop # 关闭防火墙
sudo chkconfig iptables off # 关闭防火墙开机启动设置

2、安装jdk

首先,查看系统中是否有安装自带的jdk,如果存在,则先卸载,代码如下:

rpm -qa | grep java # 查看是否有安装jdk
-openjdk-.el6_3.x86_64 tzdata-java-2012j-.el6.noarch java--openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64 # 卸载自带jdk

接着,安装jdk,步骤如下:

step1.解压安装包:

tar -zxf jdk-7u67-linux-x64.tar.gz -C /usr/local/

step2.配置环境变量及检查是否安装成功:

sudo vi /etc/profile # 打开profile文件
##JAVA_HOME
export JAVA_HOME=/usr/local/jdk1..0_67
export PATH=$PATH:$JAVA_HOME/bin

# 生效文件
source /etc/profile # 使用root用户操作

# 查看是否配置成功
java -version

3、安装hadoop

step1:解压hadoop安装包

.tar.gz -C /opt/software/

建议:将/opt/software/hadoop-2.5.0/share下的doc目录删除。

step2:修改etc/hadoop目录下hadoop-env.sh、mapred-env.sh、yarn-env.sh三个配置文件中的JAVA_HOME

export JAVA_HOME=/usr/local/jdk1..0_67

step3:修改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>
     <property>
         <name>name</name>
         <value>my-study-cluster</value>
     </property>
     <property>
         <name>fs.defaultFS</name>
         <value>hdfs://bigdata01:8020</value>
     </property>
         <!-- 指定Hadoop系统生成文件的临时目录地址 -->
     <property>
         <name>hadoop.tmp.dir</name>
         <value>/opt/software/hadoop-2.5.0/data/tmp</value>
     </property>
     <property>
         <name>fs.trash.interval</name>
         <value>1440</value>
     </property>
     <property>
         <name>hadoop.http.staticuser.user</name>
         <value>hadoop</value>
     </property>
         <property>
                 <name>hadoop.proxyuser.hadoop.hosts</name>
                 <value>bigdata01</value>
         </property>
         <property>
                 <name>hadoop.proxyuser.hadoop.groups</name>
                 <value>*</value>
         </property>
 </configuration>

step4:修改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>
     <property>
         <name>dfs.replication</name>
         <value>1</value>
     </property>
     <property>
         <name>dfs.permissions.enabled</name>
         <value>false</value>
     </property>
     <property>
         <name>dfs.namenode.name.dir</name>
         <value>/opt/software/hadoop-2.5.0/data/name</value>
     </property>
     <property>
         <name>dfs.datanode.data.dir</name>
         <value>/opt/software/hadoop-2.5.0/data/data</value>
     </property>
 </configuration>

step5:修改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>bigdata01:10020</value>
     </property>
     <property>
         <name>mapreduce.jobhistory.webapp.address</name>
         <value>bigdata01:19888</value>
     </property>
 </configuration>

step6:修改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 -->

     <property>
         <name>yarn.nodemanager.aux-services</name>
         <value>mapreduce_shuffle</value>
     </property>
     <property>
         <name>yarn.resourcemanager.hostname</name>
         <value>bigdata01</value>
     </property>
     <property>
         <name>yarn.log-aggregation-enable</name>
         <value>true</value>
     </property>
     <property>
         <name>yarn.log-aggregation.retain-seconds</name>
         <value>106800</value>
     </property>
     <property>
         <name>yarn.log.server.url</name>
         <value>http://bigdata01:19888/jobhistory/job/</value>
     </property>
 </configuration>

step7:修改slaves文件

bigdata01

step8:格式化namenode

bin/hdfs namenode -format

step9:启动进程

 ## 方式一:单独启动一个进程
 # 启动namenode
 sbin/hadoop-daemon.sh start namenode
 # 启动datanode
 sbin/hadoop-daemon.sh start datanode
 # 启动resourcemanager
 sbin/yarn-daemon.sh start resourcemanager
 # 启动nodemanager
 sbin/yarn-daemon.sh start nodemanager
 # 启动secondarynamenode
 sbin/hadoop-daemon.sh start secondarynamenode
 # 启动历史服务器
 sbin/mr-jobhistory-daemon.sh start historyserver

 ## 方式二:
 sbin/start-dfs.sh # 启动namenode、datanode、secondarynamenode
 sbin/start-yarn.sh # 启动resourcemanager、nodemanager
 sbin/mr-jobhistory-daemon.sh start historyserver # 启动历史服务器

step10:检查

1.通过浏览器访问HDFS的外部UI界面,加上外部交互端口号:50070

  http://bigdata01:50070

2.通过浏览器访问YARN的外部UI界面,加上外部交互端口号:8088

  http://bigdata01:8088

3.执行Wordcount程序

  bin/yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar wordcount input output

  注:输入输出目录自定义

结束!

以上为Hadoop2.5.0伪分布式环境搭建步骤,如有问题,请指出,谢谢!

Hadoop2.5.0伪分布式环境搭建的更多相关文章

  1. 在Win7虚拟机下搭建Hadoop2.6.0伪分布式环境

    近几年大数据越来越火热.由于工作需要以及个人兴趣,最近开始学习大数据相关技术.学习过程中的一些经验教训希望能通过博文沉淀下来,与网友分享讨论,作为个人备忘. 第一篇,在win7虚拟机下搭建hadoop ...

  2. hive-2.2.0 伪分布式环境搭建

    一,实验环境: 1, ubuntu server 16.04 2, jdk,1.8 3, hadoop 2.7.4 伪分布式环境或者集群模式 4, apache-hive-2.2.0-bin.tar. ...

  3. Spark2.4.0伪分布式环境搭建

    一.搭建环境的前提条件 环境:ubuntu-16.04 hadoop-2.6.0  jdk1.8.0_161. spark-2.4.0-bin-hadoop2.6.这里的环境不一定需要和我一样,基本版 ...

  4. Ubuntu15.10下Hadoop2.6.0伪分布式环境安装配置及Hadoop Streaming的体验

    Ubuntu用的是Ubuntu15.10Beta2版本,正式的版本好像要到这个月的22号才发布.参考的资料主要是http://www.powerxing.com/install-hadoop-clus ...

  5. Hadoop2.6.0伪分布环境搭建

    用到的软件: 一.安装jdk: 1.要安装的jdk,我把它拷在了共享文件夹里面.   (用优盘拷也可以) 2.我把jdk拷在了用户文件夹下面. (其他地方也可以,不过路径要相应改变) 3.执行复制安装 ...

  6. ubuntu14.04搭建Hadoop2.9.0伪分布式环境

    本文主要参考 给力星的博文——Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04 一些准备工作的基本步骤和步骤具体说明本文不再列出,文章中提到的“见参考”均指以上 ...

  7. 安装hadoop2.6.0伪分布式环境

    集群环境搭建请见:http://blog.csdn.net/jediael_lu/article/details/45145767 一.环境准备 1.安装linux.jdk 2.下载hadoop2.6 ...

  8. 安装hadoop2.6.0伪分布式环境 分类: A1_HADOOP 2015-04-27 18:59 409人阅读 评论(0) 收藏

    集群环境搭建请见:http://blog.csdn.net/jediael_lu/article/details/45145767 一.环境准备 1.安装linux.jdk 2.下载hadoop2.6 ...

  9. hadoop2.4.1伪分布式环境搭建

    注意:所有的安装用普通哟用户安装,所以首先使普通用户可以以sudo执行一些命令: 0.虚拟机中前期的网络配置参考: http://www.cnblogs.com/qlqwjy/p/7783253.ht ...

随机推荐

  1. marathon的高可用服务自动发现和负载均衡

    上一篇我们说谈了docker+zookeeper+mesos+marathon集群,本篇我们来谈谈marathon的集群和自动发现服务. marathon的服务自动发现和负载均衡有两种,1是mesos ...

  2. 八种主流NoSQL数据库系统对比(转)

    出处:http://database.51cto.com/art/201109/293029.htm 虽然SQL数据库是非常有用的工具,但经历了15年的一支独秀之后垄断即将被打破.这只是时间问题:被迫 ...

  3. Hadoop中Writable类之四

    1.定制Writable类型 Hadoop中有一套Writable实现,例如:IntWritable.Text等,但是,有时候可能并不能满足自己的需求,这个时候,就需要自己定制Writable类型. ...

  4. mfc的一点总结-----Edit Control操作

    获取Edit Control(编辑框)的内容: CString key; GetDlgItem(IDC_EDIT1)->GetWindowText(key); 其中IDC_EDIT1是所要获取编 ...

  5. UVA 11997 K Smallest Sums 优先队列 多路合并

    vjudge 上题目链接:UVA 11997 题意很简单,就是从 k 个数组(每个数组均包含 k 个正整数)中各取出一个整数相加(所以可以得到 kk 个结果),输出前 k 小的和. 这时训练指南上的一 ...

  6. Oracle EBS R12多组织访问架构

    关于R12的新特性Multi-Org Access Control(MOAC).Oracle宣传的好处主要有:1.enable users to access to secured data in o ...

  7. WPF透明窗体不支持缩放解决方案

    方案一 WPF中的无边框透明窗体,由于没有边并且透明,窗体无法进行缩放操作,今天来讲解如何解决这个问题. 先说一下思路,我们先手为该窗体添加4个边,4个角用于缩放操作,然后再为他们写事件,完成拖放操作 ...

  8. JPA之@GeneratedValue注解

    JPA的@GeneratedValue注解,在JPA中,@GeneratedValue注解存在的意义主要就是为一个实体生成一个唯一标识的主键(JPA要求每一个实体Entity,必须有且只有一个主键), ...

  9. php实现socket简单的例子

    一.Socket简介 1.socket只不过是一种数据结构 2.使用这个socket数据结构去开始一个客户端和服务器之间的会话 3.服务器是一直在监听准备产生一个新的会话.当一个客户端连接服务端,它就 ...

  10. 开发一个小的php扩展

    今天试了一下在php添加扩展,看了挺多资料,细节上不一致,其他大体是差不多的. 我们来开发一个叫ccvita_string的函数,他的主要作用是返回一段字符,对应的php代码可能如此: functio ...