微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

hadoop ha+zookeeper+hbase

一、环境

1、系统:Red Hat Enterprise Linux Server release 6.4

2、所需软件包

    hadoop-2.2.0.tar.gz  

    hbase-0.98.2-hadoop2-bin.tar.gz  

    jdk-7u67-linux-x64.tar.gz  

    zookeeper-3.4.6.tar.gz

3、各机器运行服务

192.168.10.40 master1 namenode resourcemanager   ZKFC   hmaster  

192.168.10.41 master2 namenode                   ZKFC   hmaster(backup)

192.168.10.42 slave1  datanode nodemanager  journalnode  hregionserver  zookeeper

192.168.10.43 slave2  datanode nodemanager  journalnode  hregionserver  zookeeper

192.168.10.44 slave3  datanode nodemanager  journalnode  hregionserver  zookeeper

二、安装步骤:(为了便于同步,一般都是在master1上操作)

1、ssh无密码登录

(mkdir -m700 .ssh)

2、jdk的安装(每台都是)

1)、解压

tar zxf jdk-7u67-linux-x64.tar.gz 

ln -sf jdk1.7.0_67 jdk

2)、配置

sudo vim /etc/profile

export JAVA_HOME=/home/richmail/jdk

export PATH=$JAVA_HOME/bin:$PATH

export CLAsspATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

3)执行,使生效

source /etc/profile

3、zookeeper的安装

1)解压

tar zxf zookeeper-3.4.6.tar.gz 

ln -sf zookeeper-3.4.6 zookeeper

2)、配置

vim zookeeper/bin/zkEnv.sh

ZOO_LOG_DIR="/home/richmail/zookeeper/logs"

cd zookeeper/conf

cp zoo_sample.cfg zoo.cfg

vim zoo.cfg

tickTime=2000

initLimit=10

synclimit=5

dataDir=/home/richmail/zookeeper/data

dataLogDir=/home/richmail/zookeeper/logs

clientPort=2181

server.1=slave1:2888:3888

server.2=slave2:2888:3888

server.3=slave3:2888:3888

mkdir -p /home/richmail/zookeeper/{data,logs}

3)、复制到slave1,slave2,slave3上 

cd

scp -rv zookeeper slave1:~/ 

ssh slave1 ‘echo 1 > /home/richmail/zookeeper/data/myid’

scp -rv zookeeper slave2:~/  

ssh slave1 ‘echo 2 > /home/richmail/zookeeper/data/myid'

scp -rv zookeeper slave3:~/  

ssh slave1 ‘echo 3 > /home/richmail/zookeeper/data/myid’

4)、启动zookeeper

分别去slave1,slave2,slave3区启动zookeeper

cd ~/zookeeper/bin

./zkServer.sh start

4、hadoop的安装

1)、解压

tar zxf hadoop-2.2.0.tar.gz

ln -sf hadoop-2.2.0 hadoop

2)、配置

cd /home/richmail/hadoop/etc/hadoop

vim core-site.xml

<configuration>

<property>

<name>fs.defaultFS</name>

<value>hdfs://cluster</value>

</property>

<property>

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

<value>/home/richmail/hadoop/storage/tmp</value>

</property>

<property>

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

<value>slave1:2181,slave2:2181,slave3:2181</value>

</property>

</configuration>

mkdir -p /home/richmail/hadoop/storage/tmp

vim hadoop-env.sh 

export JAVA_HOME=/home/richmail/jdk

export HADOOP_PID_DIR=/var/hadoop/pids  //认 /tmp下

vim hdfs-site.xml 

<configuration>

<property>

<name>dfs.nameservices</name>

<value>cluster</value>

</property>

<property>

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

<value>master1,master2</value>

</property>

<property>

<name>dfs.namenode.rpc-address.cluster.master1</name>

<value>master1:9000</value>

</property>

<property>

<name>dfs.namenode.rpc-address.cluster.master2</name>

<value>master2:9000</value>

</property>

<property>

<name>dfs.namenode.http-address.cluster.master1</name>

<value>master1:50070</value>

</property>

<property>

<name>dfs.namenode.http-address.cluster.master2</name>

<value>master2:50070</value>

</property>

<property>

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

<value>qjournal://slave1:8485;slave2:8485;slave3:8485/cluster</value>

</property>

<property>

<name>dfs.ha.automatic-failover.enabled</name>

<value>true</value>

</property>

<property>

<name>dfs.client.failover.proxy.provider.cluster</name>

<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>

</property>

<property>

<name>dfs.ha.fencing.methods</name>

<value>sshfence</value>

</property>

<property>

<name>dfs.ha.fencing.ssh.private-key-files</name>

<value>/home/richmail/.ssh/id_rsa</value>

</property>

<property>

<name>dfs.journalnode.edits.dir</name>

<value>/home/richmail/hadoop/storage/journal</value>

</property>

</configuration>

mkdir -p /home/richmail/hadoop/storage/journal

vim mapred-site.xml

<configuration>

<property>

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

<value>yarn</value>

</property>

</configuration>

vim yarn-env.sh

export YARN_PID_DIR=/var/hadoop/pids

 vim yarn-site.sh

<configuration>

<property>

<name>yarn.resourcemanager.hostname</name>

<value>master1</value>

</property>

<property>

<name>yarn.nodemanager.aux-services</name>

<value>mapreduce_shuffle</value>

</property>

</configuration>

vim slaves

slave1

slave2

slave3

3)、复制至其他机器

cd

scp -rv hadoop master2:~/

scp -rv hadoop slaver1:~/

scp -rv hadoop slaver2:~/

scp -rv hadoop slaver3:~/

4)、启动hadoop

1)、在slave1,slave2,slave3上执行journalnode

cd ~/hadoop/sbin

./hadoop-daemon.sh start journalnode

2)、在master1上执行

cd ~/hadoop/bin

./hdfs zkfc -formatZK

./hdfs namenode -format

cd ../sbin

./hadoop-daemon.sh start namenode

./start-all.sh

3)、在master2上执行

cd ~/hadoop/bin

hdfs namenode -bootstrapStandby

cd ../sbin

hadoop-daemon.sh start namenode

5)、验证

使用浏览器访问192.168.10.40:50070和192.168.10.41:50070,能够看到两个节点。一个是active,一个是standny

或者在名字节点执行命令:

hdfs haadmin -getServiceState master1

hdfs haadmin -getServiceState master2

执行hdfs haadmin –failover –forceactive master1 master2,可以使这两个节点的状态进行交换


5、hbase的安装

1)、解压

tar zxf hbase-0.98.2-hadoop2-bin.tar.gz 

ln -sf hbase-0.98.2-hadoop2 hbase 

2)、配置

cd ~/hbase/conf

vim hbase-env.sh

export JAVA_HOME=/home/richmail/jdk

export HBASE_MANAGES_ZK=false

vim hbase-env.sh 

export HBASE_PID_DIR=/var/hadoop/pids

vim regionservers

slave1

slave2

slave3

vim hbase-site.xml 

<configuration>

<property>

<name>hbase.rootdir</name>

<value>hdfs://cluster/hbase</value>

</property>

<property>

<name>hbase.master</name>

<value>60000</value>

</property>

<property>

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

<value>slave1,slave2,slave3</value>

</property>

<property>

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

<value>2181</value>

</property>

<property>

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

<value>/home/richmail/hbase/zkdata</value>

</property>

<property>

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

<value>true</value>

</property>

<property>

<name>hbase.tmp.dir</name>

<value>/home/richmail/hbase/data</value>

</property>

</configuration>

mkdir ~/hbase/{zkdata,data}

hbase有个启动错误需要把hadoop的配置文件hdfs-site.xml复制到hbase/conf下,才能解决


3)、复制至其他机器

cd

scp -rv hbase master2:~/

scp -rv hbase slaver1:~/

scp -rv hbase slaver2:~/

scp -rv hbase slaver3:~/

4)、启动hbase

在master1上执行

cd ~/hbase/bin

./start-hbase.sh

在master2上执行

./bin/hbase-daemon.sh start master --backup

至此这个集群就部署OK啦

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐