HBase-1.2.4分布式集群搭建

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010638969/article/details/53257879

HBase-1.2.4分布式集群搭建过程


说明:

集群使用3台PC机,IP地址配置如下:

218.199.92.225  fang-ubuntu(master,regionserver)
218.199.92.226  fei-ubuntu(regionserver)
218.199.92.227  kun-ubuntu(regionserver)

其中fang-ubuntu既是master又是regionserver


安装步骤:

1.官网下载安装包

http://www-us.apache.org/dist/hbase/1.2.4/
这里选择的是hbase1.2.4稳定版。cp hbase tar包到安装目录下,解压,要保证所有节点安装的目录结构一致。

2.修改hbase-env.sh

切换到hbase-1.2.4/conf,这里hbase安装在software文件夹下:

    hadoop@fang-ubuntu:~$ cd software/hbase-1.2.4/conf/
    hadoop@fang-ubuntu:~/software/hbase-1.2.4/conf$ 

找到配置文件注释的这行# export JAVA_HOME=/usr/java/jdk1.7.0/,在下面添加jdk环境变量修改为自己的java安装目录,我的安装目录为:export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_77

3.修改hbase-配置文件hbase-site.xml

全分布式配置文件

<configuration>  
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://fang-ubuntu:9000/hbase</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>/home/hadoop/software/zookeeper</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>fang-ubuntu,fei-ubuntu,kun-ubuntu</value>
    </property>
</configuration>  

伪分布式配置文件
伪分布模式不需要配置regionservers和backup-masters

<configuration>  
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://fang-ubuntu:9000/hbase</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
</configuration>  

注意事项:rootdir目录是基于hdfs的,因此要先安装Hadoop集群,hbase根目录不需要提前创建,hbase集群启动后会自动创建。
hbase集群启动后使用如下命令查看hdfs中文件目录结构。

hadoop@fang-ubuntu:~$ hdfs dfs -ls /
Found 1 items
drwxr-xr-x   - hadoop supergroup          0  2016-11-20 15:04  /hbase

hdfs中文件目录创建成功

4.修改hbase conf目录下 regionservers配置文件

添加hbase集群启动的regionserver机器,我这里添加了三台机器:fang-ubuntu,fei-ubuntu,kun-ubuntu

hadoop@fang-ubuntu:~/software/hbase-1.2.4/conf$ cat regionservers 
fang-ubuntu
fei-ubuntu
kun-ubuntu

5.在hbase conf下创建文件backup-masters ,配置备份master

hadoop@fang-ubuntu:~/software/hbase-1.2.4/conf$ touch backup-masters 
hadoop@fang-ubuntu:~/software/hbase-1.2.4/conf$ vim backup-masters 
添加:fei-ubuntu做备份master

6.将安装配置好的hbase目录复制到集群中的每个节点中。

hadoop@fang-ubuntu:scp -r ~/software fei-ubuntu :~/   kun-ubuntu:~/

7.在集群的每个节点上修改环境变量,添加HBASE_HOME

hadoop@fang-ubuntu:~$ sudo vim /etc/profile
export HBASE_HOME=/home/hadoop/software/hbase-1.2.4/  
export PATH=$PATH:$HBASE_HOME/bin  
hadoop@fang-ubuntu:~$ source /etc/profile

8.启动hbase集群。

启动的顺序一般是hadoop -> zookeeper -> hbase,停止顺序相反!

hadoop@fang-ubuntu:~$ cd software/hbase-1.2.4/bin/
hadoop@fang-ubuntu:~/software/hbase-1.2.4/bin$ ./start-hbase.sh 

集群启动过程如下:

hadoop@fang-ubuntu:~/software/hbase-1.2.4/bin$ ./start-hbase.sh 
fei-ubuntu: starting zookeeper, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-zookeeper-fei-ubuntu.out
kun-ubuntu: starting zookeeper, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-zookeeper-kun-ubuntu.out
fang-ubuntu: starting zookeeper, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-zookeeper-fang-ubuntu.out
starting master, logging to /home/hadoop/software/hbase-1.2.4/logs/hbase-hadoop-master-fang-ubuntu.out
fei-ubuntu: starting regionserver, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-fei-ubuntu.out
kun-ubuntu: starting regionserver, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-kun-ubuntu.out
fang-ubuntu: starting regionserver, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-fang-ubuntu.out
fei-ubuntu: starting master, logging to /home/hadoop/software/hbase-1.2.4/bin/../logs/hbase-hadoop-master-fei-ubuntu.out
  • master上的进程为:
hadoop@fang-ubuntu:~/software/hbase-1.2.4/bin$ jps
6256 NameNode
7601 HRegionServer
6548 SecondaryNameNode
7908 Jps
7365 HQuorumPeer
7435 HMaster
6381 DataNode
  • slave上的进程为:
hadoop@fei-ubuntu:~$ jps
4290 HMaster
3769 DataNode
4122 HRegionServer
4012 HQuorumPeer
4556 Jps

9.启动hbsae shell,进入hbase控制台,验证hbase集群是否安装成功

hadoop@fang-ubuntu:~$ cd software/hbase-1.2.4/
hadoop@fang-ubuntu:~/software/hbase-1.2.4$ ./bin/hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/software/hbase-1.2.4/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/SparkAndHadoop/hadoop-2.7.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tue Oct 25 18:10:20 CDT 2016
hbase(main):001:0> 

创建表,查看表

hbase(main):003:0> create 't1','f1'
0 row(s) in 10.4240 seconds
=> Hbase::Table - t1
hbase(main):004:0> list
TABLE
t1 
1row(s) in 0.0080 seconds

至此HBase分布式集群搭建成功


Tips

  • 集群没有配置单独的zookeeper,使用的是hbase自带的,如果需要使用单独的zookeeper,需要修改配置文件,步骤类似
  • 集群master节点也配置成了regionserver,因此3台机器的集群上有三个regionserver,一个master
阅读更多

没有更多推荐了,返回首页