hbase学习笔记

hbase 基本架构

版本选用

  • hadoop 2.7.4
  • hbase 1.2.6

    hadoop hbase版本兼容

hbase 定位

与hadoop对接

1
2
3
4
<property>
<name>hbase.rootdir</name>
<value>hdfs://namenode.example.org:8020/hbase</value>
</property>

与zookeeper对接

hbase 自带的zookeeper

hbase-env.sh

1
2
# Tell HBase whether it should manage its own instance of ZooKeeper or not.
export HBASE_MANAGES_ZK=true

startup

When HBase manages ZooKeeper, it will start/stop the ZooKeeper servers as a part of the regular start/stop scripts. If you would like to run ZooKeeper yourself, independent of HBase start/stop, you would do the following

1
${HBASE_HOME}/bin/hbase-daemons.sh {start,stop} zookeeper

外部的zookeeper

hbase-env.sh

1
2
# Tell HBase whether it should manage its own instance of ZooKeeper or not.
export HBASE_MANAGES_ZK=false

hbase-site.xml

1
2
3
4
5
6
7
8
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node-a.example.com,node-b.example.com,node-c.example.com</value>
</property>

单机配置与安装

存储在本地文件

1
2
3
4
5
6
7
8
9
10
11
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/testuser/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/testuser/zookeeper</value>
</property>
</configuration>

存储在HDFS

1
2
3
4
5
6
7
8
9
10
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://namenode.example.org:8020/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>false</value>
</property>
</configuration>

伪分布式配置与安装

hbase-site.xml

1
2
3
4
5
6
7
8
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:8020/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>

分布式安装

Node Name Master ZooKeeper RegionServer
node-a.example.com yes yes no
node-b.example.com backup yes yes
node-c.example.com no yes yes

hbase-site.xml

1
2
3
4
5
6
7
8
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node-a.example.com,node-b.example.com,node-c.example.com</value>
</property>

conf/regionservers

1
2
3
node-a.example.com
node-b.example.com
node-c.example.com

conf/backup-masters

1
2
node-b.example.com
node-c.example.com