集群规划:
主机名 IP 安装的软件 运行的进程
hdp-ha-01 192.168.1.63 jdk、hadoop、zookeeper、hbase NameNode,SecondaryNameNode,NodeManager,ResourceManager,QuorumPeerMain、hmaster
hdp-ha-02 192.168.1.63 jdk、hadoop、zookeeper、hbase DataNode、NodeManager、QuorumPeerMain、、hregionserver
hdp-ha-03 192.168.1.64 jdk、hadoop、zookeeper、hbase DataNode、NodeManager、QuorumPeerMain、hregionserver
安装步骤:
(1)下载hbase安装包,上传hbase安装包到linux
(2)解压
(3)配置hbase集群,要修改3个文件
注意:要把hadoop的hdfs-site.xml和core-site.xml 放到hbase/conf下
(3.1)修改hbase-env.sh
export JAVA_HOME=/usr/java/jdk1.7.0_55 //告诉hbase使用外部的zk export HBASE_MANAGES_ZK=false |
(3.2)修改 hbase-site.xml
|
(3.3)修改 regionservers
weekend03 weekend04 weekend05 weekend06 |
(3.4) 拷贝hbase到其他节点
scp -r /weekend/hbase-0.96.2-hadoop2/ weekend02:/weekend/
scp -r /weekend/hbase-0.96.2-hadoop2/ weekend03:/weekend/
scp -r /weekend/hbase-0.96.2-hadoop2/ weekend04:/weekend/
scp -r /weekend/hbase-0.96.2-hadoop2/ weekend05:/weekend/
scp -r /weekend/hbase-0.96.2-hadoop2/ weekend06:/weekend/
(4) 将配置好的HBase拷贝到每一个节点并同步时间。
(5) 启动所有的hbase进程
首先启动zk集群
./zkServer.sh start
启动hbase集群
start-dfs.sh
启动hbase,在主节点上运行:
start-hbase.sh
(6) 通过浏览器访问hbase管理页面
192.168.1.201:60010
(7) 为保证集群的可靠性,要启动多个HMaster
hbase-daemon.sh start master
[root@xuegod63 download]#
[root@xuegod63 download]# tar -zxf hbase-1.3.1-bin.tar.gz -C /usr/local/
[root@xuegod63 download]# cd /usr/local/
[root@xuegod63 local]# ls
bin games include libexec share ucenter1.5 vmware-tools-distrib
etc hadoop-2.6.2 lib redis-3.2.8 src ucenter_home2.0 zookeeper-3.4.6
fail2ban-0.8.14 hbase-1.3.1 lib64 sbin tomcat7 VMwareTools-9.6.2-1688356.tar.gz
[root@xuegod63 local]#
[root@xuegod63 local]# cd hbase-1.3.1/
[root@xuegod63 hbase-1.3.1]# ls
bin conf LEGAL LICENSE.txt NOTICE.txt xuegod65
CHANGES.txt hbase-webapps lib logs README.txt
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]# vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_15
export JRE_HOME=/usr/java/jdk1.7.0_15/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export HADOOP_HOME=/usr/local/hadoop-2.6.2
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$ZOOKEEPER_HOME/bin::$PATH
export HBASE_HOME=/usr/local/hbase-1.3.1
export PATH=$HBASE_HOME/bin::$PATH
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]# ls
bin conf LEGAL LICENSE.txt NOTICE.txt xuegod65
CHANGES.txt hbase-webapps lib logs README.txt
[root@xuegod63 hbase-1.3.1]# cd conf/
[root@xuegod63 conf]# ls
core-site.xml hbase-env.sh hdfs-site.xml
hadoop-metrics2-hbase.properties hbase-policy.xml log4j.properties
hbase-env.cmd hbase-site.xml regionservers
[root@xuegod63 conf]#
修改hbase-env.sh
[root@xuegod63 conf]# vim hbase-env.sh
#添加一下内容:
# The java implementation to use. Java 1.7+ required.
export JAVA_HOME=/usr/java/jdk1.7.0_15
# Extra Java CLASSPATH elements. Optional.
#设置到Hadoop的etc/hadoop目录是用来引导Hbase找到Hadoop,即hbase和hadoop进行关联
export HBASE_CLASSPATH=/usr/local/hadoop-2.6.2/etc/hadoop
export HBASE_MANAGES_ZK=false 默认为true,使用自带的zookeeper,如果设置为false,需要自己配置zookeeper.
[root@xuegod63 conf]#
[root@xuegod63 conf]#
[root@localhost65 conf]# vim hbase-site.xml
[root@xuegod63 conf]#
要把hadoop的hdfs-site.xml和core-site.xml 放到hbase/conf下
[root@xuegod63 conf]# cp /usr/local/hadoop-2.6.2/etc/hadoop/hdfs-site.xml ./
[root@xuegod63 conf]# cp /usr/local/hadoop-2.6.2/etc/hadoop/core-site.xml ./
[root@xuegod63 conf]# ls
core-site.xml hbase-env.sh hdfs-site.xml
hadoop-metrics2-hbase.properties hbase-policy.xml log4j.properties
hbase-env.cmd hbase-site.xml regionservers
[root@xuegod63 conf]# vim core-site.xml
[root@xuegod63 conf]#
Master只能有一个,如果启动多个master,则其他的都为standby。Regionserver可以有多个。
编辑所有机器的HBase的HMasters和HRegionServers。修改/conf 文件夹下的regionservers文件。添加DataNode的IP即可,通常是将regionserver与datanode服务器放在一起
[root@xuegod63 conf]#
[root@xuegod63 conf]# ls
core-site.xml hbase-env.sh hdfs-site.xml
hadoop-metrics2-hbase.properties hbase-policy.xml log4j.properties
hbase-env.cmd hbase-site.xml regionservers
[root@xuegod63 conf]# vim regionservers
xuegod63
xuegod64
xuegod65
[root@xuegod63 conf]#
[root@xuegod63 local]#
[root@xuegod63 local]# scp -r hbase-1.3.1/ xuegod64:/usr/local/
[root@xuegod63 local]# scp -r hbase-1.3.1/ xuegod65:/usr/local/
[root@xuegod63 local]#
[root@xuegod64 local]# ls
bin hadoop-2.7.3.tar lib64 share zookeeper-3.4.6
etc hbase-1.3.1 libexec src
games include redis-3.2.8 VMwareTools-9.6.2-1688356.tar.gz
hadoop-2.6.2 lib sbin vmware-tools-distrib
[root@xuegod64 local]#
[root@xuegod65 ~]# cd /usr/local/
[root@xuegod65 local]# ls
bin hadoop-2.6.2 lib64 share ucenter_home2.0
etc hbase-1.3.1 libexec src VMwareTools-9.6.2-1688356.tar.gz
fail2ban-0.8.14 include redis-3.2.8 tomcat7 vmware-tools-distrib
games lib sbin ucenter1.5 zookeeper-3.4.6
[root@xuegod65 local]#
[root@xuegod63 local]# start-hbase.sh
starting master, logging to /usr/local/hbase-1.3.1/logs/hbase-root-master-xuegod63.out
xuegod65: starting regionserver, logging to /usr/local/hbase-1.3.1/bin/../logs/hbase-root-regionserver-xuegod65.out
xuegod64: starting regionserver, logging to /usr/local/hbase-1.3.1/bin/../logs/hbase-root-regionserver-xuegod64.out
xuegod63: starting regionserver, logging to /usr/local/hbase-1.3.1/bin/../logs/hbase-root-regionserver-xuegod63.out
[root@xuegod63 local]# jps
7026 NameNode
6814 QuorumPeerMain
8258 HRegionServer
8304 Jps
8133 HMaster
7270 SecondaryNameNode
7440 ResourceManager
7539 NodeManager
[root@xuegod63 local]#
Xuegod64服务:
[root@xuegod64 ~]# jps
5656 HRegionServer
6616 Jps
5307 DataNode
5188 QuorumPeerMain
5411 NodeManager
[root@xuegod64 ~]#
Xuegod65服务:
[root@xuegod65 local]# jps
4435 Jps
4275 HRegionServer
4030 NodeManager
3833 QuorumPeerMain
[root@xuegod65 local]#
注意:在集群使用命令start-hbase.sh启动的服务为Hmaster,并且master只能有一个,其他的为standby, HregionServer则为hbase中regionserver配置文件中的配置的主机。可以为多个。
可以通过手动启动standby节点,如下:
[root@xuegod63 hbase-1.3.1]# hbase-daemon.sh start master
starting master, logging to /usr/local/hbase-1.3.1/logs/hbase-root-master-xuegod63.out
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]# jps
7026 NameNode
6814 QuorumPeerMain
9028 Jps
8258 HRegionServer
7270 SecondaryNameNode
7440 ResourceManager
8797 Hmaster #表示hbase已经启动成功
7539 NodeManager
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]# zkCli.sh
Connecting to localhost:2181
2017-09-25 23:18:29,809 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2017-09-25 23:18:29,823 [myid:] - INFO [main:Environment@100] - Client environment:host.name=xuegod63
2017-09-25 23:18:29,824 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.7.0_15
2017-09-25 23:18:29,834 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2017-09-25 23:18:29,834 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.7.0_15/jre
2017-09-25 23:18:29,834 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../conf:/usr/java/jdk1.7.0_15/lib:/usr/java/jdk1.7.0_15/jre/lib:
2017-09-25 23:18:29,834 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017-09-25 23:18:29,835 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2017-09-25 23:18:29,835 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=
2017-09-25 23:18:29,835 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux
2017-09-25 23:18:29,835 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2017-09-25 23:18:29,836 [myid:] - INFO [main:Environment@100] - Client environment:os.version=2.6.32-431.el6.x86_64
2017-09-25 23:18:29,836 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root
2017-09-25 23:18:29,836 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root
2017-09-25 23:18:29,836 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/usr/local/hbase-1.3.1
2017-09-25 23:18:29,841 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@27c09226
Welcome to ZooKeeper!
2017-09-25 23:18:29,917 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-09-25 23:18:29,945 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
JLine support is enabled
2017-09-25 23:18:29,990 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15eb96af2fd0008, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[hbase, zookeeper]
[zk: localhost:2181(CONNECTED) 1] ls /hbase
[meta-region-server, backup-masters, switch, table, draining, region-in-transition, table-lock, running, master, namespace, hbaseid, online-snapshot, replication, splitWAL, recovering-regions, rs, flush-table-proc]
[zk: localhost:2181(CONNECTED) 2]
[root@xuegod63 hbase-1.3.1]#
[root@xuegod63 hbase-1.3.1]# stop-hbase.sh
stopping hbase.....................
[root@xuegod63 hbase-1.3.1]#
浏览器输入:http://192.168.3.63:16010/ hbase默认端口是16010。
创建脚本:
[root@server66 ~]# vim cphbase.sh
#!/bin/bash
if [ "$#" != "2" ]; then
echo "usage:$(basename $0)
echo "example:$(basename $0) hbase-1.3 hbase"
fi
SRC_PATH="/usr/local/$1/conf/regionservers"
for srv in $(cat $SRC_PATH);
do
echo "sending command to $srv...";
rsync -vaz --exclude='logs/*' /usr/local/$1 $srv:/root/test/
# ssh $srv "rm -rf /usr/local/$2;ln -s /usr/local/$1 /usr/local/$2"
done
echo "done.............";
~
[root@server66 ~]#
执行复制操作:
[root@server66 ~]# sh cphbase.sh hbase-1.3.1 hbase-1.3.1