HBase 集群配置

来源:互联网 发布:apache sh commands 编辑:程序博客网 时间:2024/05/16 03:27
  HBase 是一个开源的非关系(NoSQL)的可伸缩性分布式数据库。它是面向列的,并适合于存储超大型松散数据。HBase适合于实时,随机对Big数据进行读写操作的业务环境。关于HBase的更多介绍请参见HBase项目官网。

    本文环境与上一讲--完全分布式Hadoop集群配置一致。OS是Ubuntu Server 10.04,HBase版本是0.20.6。

         HRegionServer&HQuorumPeer:dm1,IP:192.168.0.17;

         HRegionServer&HQuorumPeer:dm2,IP:192.168.0.18;

         HRegionServer&HQuorumPeer:dm3,IP:192.168.0.9;

                  HMaster&NameNode:dm4,IP:192.168.0.10;(SecondaryNameNode)

  虽然secondarynamenode和namenode放在同一台机器上比较不合理。但是考虑到这只是个实验的小集群(硬件环境不允许),再者有xenserver的时序快照的保障,就不将SecondaryNameNode部署在其他机器上了。

 

     主要的还是配置工作,依然将HBase放在/home下,编辑/home/hbase/conf下的hbase-site.xml,hbase-default.xml,hbase-env.sh 这几个文件。具体步骤如下:

     一.编辑所有机器上的hbase-site文件,命令如下:

 

view sourceprint?
1vi /home/hbase/conf/hbase-site.xml

      编辑文件如下列代码所示。注意项有2:

    1.其中首先需要注意hdfs://dm4:9000/hbase这里,必须与你的Hadoop集群的core-site.xml文件配置保持完全一致才行,如果你Hadoop的hdfs使用了其它端口,请在这里也修改。再者就是Hbase该项并不识别机器IP,只能使用机器hostname才可行,即若使用dm4的IP(192.168.0.10)是会抛出java错误,至于具体的错误由于时间久远,我就懒得去翻查那大量的log了。

      2.hbase.zookeeper.quorum 的个数必须是奇数

 

view sourceprint?
01<configuration>
02<property>
03 <name>hbase.rootdir</name>
04 <value>hdfs://dm4:9000/hbase</value>
05</property>
06<property>
07 <name>hbase.cluster.distributed</name>
08 <value>true</value>
09</property>
10<property>
11<name>hbase.master</name>
12<value>192.168.0.10:60000</value>
13</property>
14<property>
15 <name>hbase.zookeeper.quorum</name>
16 <value>192.168.0.9,192.168.0.17,192.168.0.18</value>
17</property>
18</configuration>

   二.编辑所有机器的 hbase-default.xml,命令如下:

 

view sourceprint?
1vi /home/hbase/conf/hbase-default.xml

    只需修改前面hbase.rootdir 与hbase.cluster.distributed 这两项。修改如下面代码所示:

HBase的数据重启就被擦掉,如果需要数据持久化的,就修改rootdir项,写定你的HDFS目录。

至于default内其它的项的含义与修改,再请参考官网。 

 

view sourceprint?
01<configuration>
02 <property>
03 <name>hbase.rootdir</name>
04<value>hdfs://dm4:9000/hbase_rootdir</value>
05 <description>The directory shared by region servers.
06 Should be fully-qualified to include the filesystem to use.
07 E.g: hdfs://NAMENODE_SERVER:PORT/HBASE_ROOTDIR
08 </description>
09 </property>
10 <property>
11 <name>hbase.master.port</name>
12 <value>60000</value>
13 <description>The port master should bind to.</description>
14 </property>
15 <property>
16 <name>hbase.cluster.distributed</name>
17 <value>true</value>
18 <description>The mode the cluster will be in. Possible values are
19 false: standalone and pseudo-distributed setups with managed Zookeeper
20 true: fully-distributed with unmanaged Zookeeper Quorum (see hbase-env.sh)
21 </description>
22 </property>

   三. 编辑所有机器的hbase-env.sh,命令如下:

 

view sourceprint?
1vi /home/hbase/conf/hbase-env.sh

     修改代码如下所示:

view sourceprint?
1export HBASE_OPTS="$HBASE_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkS
2weepGC -XX:+CMSIncrementalMode"
3 export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.22
4export HBASE_MANAGES_ZK=true
5export HBASE_HOME=/home/hbase
6export HADOOP_HOME=/home/hadoop

     四.编辑所有机器的HBase的HMasters和HRegionServers。修改/home/hbase/conf 文件夹下的regionservers文

件。添加DataNode的IP即可。代码如下:

 

view sourceprint?
1192.168.0.9
2192.168.0.17
3192.168.0.18

    行文至此,HBase集群的配置已然完成。以下便是启动和测试。

    五.启动.测试HBase数据库。

     在HMaster即Namenode (dm4)启动HBase数据库(Hadoop集群必须已经启动)。 启动命令:

 

view sourceprint?
1/home/hbase/bin/start-hbase.sh

  Hbase启动如下图所示:

    最好输入JPS命令测试一下你当前Hbase集群进程。如下图:

 

 

 

然后输入如下命令进入hbase的命令行管理界面:

 

view sourceprint?
1/home/hbase/bin/hbase shell

   在hbase shell下 输入list,如下所示,列举你当前数据库的名称,如下图所示。如果你的Hbase没配置成功会抛出java错误。

 

   我们也可以通过WEB页面来管理查看HBase数据库。

  HMaster:http://192.168.0.10:60010/master.jsp

  我的HBase数据库截图:

原创粉丝点击