安装配置
Hbase需要zookeeper的支持,本博客有专门写zookeeper安装教程的可参看。
单机安装的话可以用Hbase自带的,伪分布安装的话自己安装一个Zookeeper即可。
下面HBASE_MANAGES_ZK=false: false使用自带的zookeeper,否则需要配置独立的zookeeper。
mkdir -p /opt/hbase
cd /opt/hbase
sudo wget http://mirrors.cnnic.cn/apache/hbase/stable/hbase-1.1.5-bin.tar.gz
#编辑{HBASE_HOME}/conf/hbase-env.sh,设置JAVA_HOME和HBASE_CLASSPATH
export JAVA_HOME=/opt/java/jdk1.7.0_79
export HBASE_CLASSPATH=/opt/hadoop/hbase/hbase-1.1.5/conf
export HBASE_MANAGES_ZK=false
修改hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://172.16.22.251:9005/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master</name>
<value>localhost:60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop/hadoop_tmp/zookeeper</value>
</property>
hbase.rootdir:需要和hadoop中core-site.xml中fs.default.name中的路径相同,这里配置到hdfs上,不配置到本地。
hbase.cluster.distributed:hbase.cluster.distributed指定了Hbase的运行模式。false是单机模式,true是分布式模式。
hbase.zookeeper.quorum是Zookeeper集群的地址列表,用逗号分割。
hbase.zookeeper.property.clientPort:zookeeper客户端端口。
启动Hbase Master
[hadoop@localhost bin]$ ./start-hbase.sh
starting master, logging to /opt/hadoop/hbase/hbase-1.1.5/logs/hbase-hadoop-master-localhost.localdomain.out
starting regionserver, logging to /opt/hadoop/hbase/hbase-1.1.5/logs/hbase-hadoop-1-regionserver-localhost.localdomain.out
验证Hbase Master是否启动成功
http://172.16.22.251:16010(各版本可能默认端口不一样)
Hbase Shell
启动Hbase Shell后查看
[hadoop@localhost bin]$ hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.1.5, r239b80456118175b340b2e562a5568b5c744252e, Sun May 8 20:29:26 PDT 2016
hbase(main):001:0> status
1 servers, 0 dead, 2.0000 average load
创建一个数据库
hbase(main):002:0> create 'test', 'id', 'name', 'address', 'info'
0 row(s) in 1.4900 seconds
=> Hbase::Table - test
hbase(main):003:0> list
TABLE
test
1 row(s) in 0.0250 seconds
hbase(main):005:0> describe 'test'
Table test is ENABLED
test
COLUMN FAMILIES DESCRIPTION
{NAME => 'address', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEE
P_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'id', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DEL
ETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_D
ELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'name', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_D
ELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
4 row(s) in 0.1220 seconds
查看Hdfs上的hbase数据
[hadoop@localhost bin]$ hdfs dfs -ls /hbase
Found 9 items
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:07 /hbase/.tmp
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:07 /hbase/MasterProcWALs
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:01 /hbase/WALs
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:07 /hbase/archive
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:01 /hbase/corrupt
drwxr-xr-x - hadoop supergroup 0 2016-05-30 18:23 /hbase/data
-rw-r--r-- 1 hadoop supergroup 42 2016-05-30 18:23 /hbase/hbase.id
-rw-r--r-- 1 hadoop supergroup 7 2016-05-30 18:23 /hbase/hbase.version
drwxr-xr-x - hadoop supergroup 0 2016-06-04 17:02 /hbase/oldWALs
常用的工具页面
http://hbase-host:50070/dfshealth.jsp
Habse在hdfs上的状态
http://hbase-host:16010/zk.jsp
hbase的zookeeper Dump
http://hbase-host:16010/master-status
Hbase Master状态
http://hbase-host:16010/rs-status
Hbase Region状态
原文链接:Hadoop学习笔记(12)--Hbase安装,转载请注明来源!