hadoop环境搭建

 

 

 

Hadoop-2.0.0-cdh-4.1.2

安装手册

 

 

 

 

 

 

 

 


 

<!--[if !supportLists]-->1       <!--[endif]-->环境准备

<!--[if !supportLists]-->1.1     <!--[endif]-->主机

IP

HOSTNAME

部署模块

192.168.56.102

huke-mint2

Hadoop

Hbase

Zookeeper

Cloudera Manager

Hue

<!--[if !supportLists]-->1.2     <!--[endif]-->用户

当前用户:huke

<!--[if !supportLists]-->1.3     <!--[endif]-->程序包

程序名称

说明

zookeeper-3.4.5-cdh4.2.1.tar.gz

hadoop2.0 HA协调服务

hadoop-2.0.0-cdh4.1.2.tar.gz

hadoop安装程序

hbase-0.92.1-cdh4.1.2.tar.gz

 

hue-2.1.0-cdh4.1.2.tar.gz

 

cloudera-manager-el5-cm4.1.2_x86_64.tar.gz

 

<!--[if !supportLists]-->1.4     <!--[endif]-->SSH互信

执行以下命令:

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

现在确认能否不输入口令就用ssh登录localhost:

ssh localhost

 

<!--[if !supportLists]-->1.5     <!--[endif]-->基础环境

已经安装jdk,并配置好环境变量和JAVA_HOME

<!--[if !supportLists]-->2       <!--[endif]-->程序安装

<!--[if !supportLists]-->2.1     <!--[endif]-->zookeeper

<!--[if !supportLists]-->2.1.1  <!--[endif]-->第一步:解压

tar -xzf zookeeper-3.4.5-cdh4.2.1.tar.gz

 

<!--[if !supportLists]-->2.1.2  <!--[endif]-->第二步:修改zoo.cfg

如果没有该文件就从zoo-sample.cfg复制一份,并命名为zoo.cfg

cd zookeeper-3.4.5-cdh4.2.1/conf/

vi zoo.cfg

 

zoo.cfg内容

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=/home/hadoop/app/zookeeper-3.4.5/data

# the port at which the clients will connect

clientPort=2181

#

# Be sure to read the maintenance section of the

# administrator guide before turning on autopurge.

#

# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

#

# The number of snapshots to retain in dataDir

#autopurge.snapRetainCount=3

# Purge task interval in hours

# Set to "0" to disable auto purge feature

#autopurge.purgeInterval=1

 

server.1=192.168.56.102:2888:3888

 

initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 5*2000=10 秒。

syncLimit:这个配置项标识 Leader Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒。

server.A=BCD:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。

 

<!--[if !supportLists]-->2.1.3  <!--[endif]-->第三步:创建myid

vi data/myid

myid文件内容

1

 

<!--[if !supportLists]-->2.1.4  <!--[endif]-->第四步:配置环境变量

[hadoop@datanode3 data]$ vi ~/.bash_profile

[hadoop@datanode3 data]$ source ~/.bash_profile

 

在环境变量中增加ZOOKEEPER_HOME,修改PATH

export ZOOKEEPER_HOME=/home/hadoop/app/zookeeper-3.4.5

 

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin

 

<!--[if !supportLists]-->2.1.5  <!--[endif]-->第五步:测试

启动:

huke-mint2

zkServer.sh start

JMX enabled by default

Using config: /home/huke/hadoop/ zookeeper-3.4.5-cdh4.2.1/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

 

查看状态

huke-mint2

zkServer.sh status

JMX enabled by default

Using config: /home/huke/hadoop/ zookeeper-3.4.5-cdh4.2.1/bin/../conf/zoo.cfg

Mode: standelone

<!--[if !supportLists]-->2.2     <!--[endif]-->hadoop

<!--[if !supportLists]-->2.2.1  <!--[endif]-->第一步:解压

tar -xzf hadoop-2.0.0-cdh4.3.0.tar.gz

<!--[if !supportLists]-->2.2.2  <!--[endif]-->第二步:配置core-site.xml

配置文件内容:

<configuration>

       <property>

              <name> hdfs://192.168.56.102:8020</name>

              <value>hdfs://localhost</value>

       </property>

       <property>

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

              <value>/home/huke/hadoop/data</value>

       </property>

</configuration>

<!--[if !supportLists]-->2.2.3  <!--[endif]-->第三步:配置hdfs-site.xml

配置文件内容:

<configuration>

    <!--配置dfs.nameservices 这个名称可以随意,如果同时还使用HDFS Federation机制,则应该使用逗号分隔nameservices列表--> 

    <property> 

      <name>dfs.federation.nameservices</name> 

      <value>hdp</value> 

    </property> 

    <property>

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

      <value>/home/huke/hadoop/data/name</value> 

    </property> 

    <!--配置:dfs.ha.namenodes.[nameservice ID]. 下面的dinglicomnameservice IDnn0nn1是每台namenodeserviceId--> 

    <property> 

      <name>dfs.ha.namenodes.hdp</name> 

      <value>nn0</value>  

    </property>

    <!--配置rpc通信地址:dfs.namenode.rpc-address.[nameservice ID].--> 

<!--

    <property> 

      <name>dfs.namenode.rpc-address.hdp.nn0</name> 

      <value>192.168.56.102:8888</value> 

    </property>

-->

 

    <!--配置http通信地址:dfs.namenode.http-address.[nameservice ID].--> 

    <property> 

      <name>dfs.namenode.http-address.hdp.nn0</name> 

      <value>192.168.56.102:50070</value> 

    </property> 

 

    <!--配置zk集群信息--> 

    <property> 

      <name>ha.zookeeper.quorum</name> 

      <value>192.168.56.102:2181</value> 

    </property> 

    <!--datanode数据存放目录--> 

    <property> 

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

        <value>/home/huke/hadoop/data/data</value> 

</property> 

</configuration>

<!--[if !supportLists]-->2.2.4  <!--[endif]-->第四步:配置mapred-site.xml

mapred-site.xml配置文件原本是不存在的,需要根据template文件创建,命令如下:

cp mapred-site.xml.template mapred-site.xml

 

配置文件内容

<configuration>

       <property>

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

              <value>yarn</value>

       </property>

</configuration>

<!--[if !supportLists]-->2.2.5  <!--[endif]-->第五步:配置yarn-site.xml

<?xml version="1.0"?>

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

<configuration>

              <property>

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

              <value>yarn</value>

       </property>

       <property> 

         <name>mapred.job.tracker</name> 

         <value>192.168.56.102:8021</value> 

         <final>true</final>

       </property>

</configuration>

 

<!--[if !supportLists]-->2.2.6  <!--[endif]-->第六步:配置slaves

编辑slaves文件,添加如下内容

192.168.56.102

 

<!--[if !supportLists]-->2.2.7  <!--[endif]-->第九步:配置环境变量

5台主机上做如下操作

 

在环境变量中增加如下内容:

export HADOOP_HOME=/home/hadoop/app/hadoop-2.0.0-cdh4.3.0

追加PATH变量

:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

使环境变量生效

source ~/.bash_profile

 

<!--[if !supportLists]-->3       <!--[endif]-->程序启动

<!--[if !supportLists]-->3.1     <!--[endif]-->启动zookeeper

huke-mint2

zkServer.sh start

JMX enabled by default

Using config: /home/hadoop/app/zookeeper-3.4.5/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

<!--[if !supportLists]-->3.2     <!--[endif]-->启动HDFS

主机:namenode1

HDFS格式化)

cd ../bin

./hdfs namenode –format

启动namenode

./hdfs namenode

 

启动完成后,可在浏览器中键入以下地址进行验证:

http://192.168.56.102:50070/dfshealth.jsp

http://192.168.56.102:50070/dfshealth.jsp

 

<!--[if !supportLists]-->3.3     <!--[endif]-->启动YARN

./start-yarn.sh

 

启动完成后,可在浏览器中键入以下地址进行验证:

http://192.168.56.102:8088/cluster

 

<!--[if !supportLists]-->4       <!--[endif]-->配置Hbase

<!--[if !supportLists]-->4.1     <!--[endif]-->解压

 

tar -xvf hbase-0.92.1-cdh4.1.2.tar.gz

 

 

<!--[if !supportLists]-->4.2     <!--[endif]-->修改hbase-env.sh文件

vi conf/hbase-env.sh

修改以下内容

export JAVA_HOME=/usr/local/jdk1.7.0_25/

export HBASE_MANAGES_ZK=true

export HADOOP_HOME=/home/huke/hadoop/hadoop

export HBASE_LOG_DIR=/home/huke/hadoop/hbase/logs

export HBASE_CLASSPATH=/home/huke/hadoop/hadoop/etc/hadoop

 

 

<!--[if !supportLists]-->4.3     <!--[endif]-->修改hbase-site.sh文件

<configuration>

                <property>

       <name>hbase.rootdir</name>

       <value>hdfs://192.168.56.102:8020/hbase</value> 

    </property>   

    <property>   

        <name>hbase.cluster.distributed</name>   

        <value>false</value>  

    </property>

 

    <property>

      <name>hbase.zookeeper.property.dataDir</name> 

      <value>/home/huke/hadoop/data</value> 

    </property>

    <property>  

        <name>hbase.master</name>  

        <value>192.168.56.102:60000</value>  

    </property>

    <property>

        <name>hbase.zookeeper.quorum</name>

        <value>192.168.56.102</value>

    </property> 

    <property> 

        <name>hbase.zookeeper.property.clientPort</name> 

        <value>2181</value>

    </property>

</configuration>

 

 

<!--[if !supportLists]-->4.4     <!--[endif]-->复制hdfs-site.xmlhbase/conf目录下

cp ~/hadoop/hadoop/etc/hadoop/hdfs-site.xml ./

<!--[if !supportLists]-->4.1     <!--[endif]-->启动hbase

bin/start-hbase.sh

 

你可能感兴趣的:(hadoop)