Download: http://mirror.bit.edu.cn/apache/hbase/stable/
Official Guide: http://abloz.com/hbase/book.html
Installation configuration:
Extract:
TAR-XZVF hbase-0.96.0-hadoop1-bin.tar.gz
Go to $hbase/lib and look at the related Hadoop package to see which version of Hadoop it is.
Only the installation of the pseudo-distributed hbase is logged here.
Configuration parameters, modify Hbase-site.xml:
[HTML]View PlainCopy
- <configuration>
- ...
- <property>
- <name>hbase.rootdir</name>
- <value>hdfs://localhost:9000/hbase</value>
- <description>the directory shared by Regionservers.
- </Description>
- </Property>
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- <description>the replication count for HLog & hfile storage. should not being greater than HDFS datanode count.
- </Description>
- </Property>
- ...
- </configuration>
Pseudo-distributed Startup:
Pseudo-distributed is HDFS-based, so you need to start HDFs first.
After you start hbase
SH start-hbase.sh
No unexpected error:
[Email protected]:/opt/hbase-0.96/bin$ sh start-hbase.sh
start-hbase.sh:79:/opt/hbase-0.96/bin/hbase-config.sh: [[: Not Found
start-hbase.sh:88:/opt/hbase-0.96/bin/hbase-config.sh: [[: Not Found
start-hbase.sh:53: [: false:unexpected operator
Localhost:zookeeper running as Process 24164. Stop it first.
Starting master, logging to/opt/hbase-0.96/bin/. /logs/hbase-dat-master-dat-hp.out
Could not-start ZK at requested port of 2181. ZK is started at Port:-1. Aborting as clients (e.g. shell) is not being able to find this ZK quorum.
It looks like 2181 is occupied, see the process that occupies 2181 ports:
lsof-i:2181
[Plain]View PlainCopy
- [Email protected]:/opt/hbase-0.96/logs$ lsof-i:2181
- COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
- Java 24164 dat 87u IPv6 2800953 0t0 TCP *:2181 (LISTEN)
Ps-ef|grep 24164
[Plain]View PlainCopy
- [Email protected]:/opt/hbase-0.96/logs$ ps-ef|grep 24164
- DAT 24164 24151 0 10:09? 00:00:03/opt/jdk1.7.0_25/bin/java-dproc_zookeeper-xx:onoutofmemoryerror=kill-9%p-xmx1000m-xx:+ useconcmarksweepgc-dhbase.log.dir=/opt/hbase-0.96/bin/. /logs-dhbase.log.file=hbase-dat-zookeeper-dat-hp.log-dhbase.home.dir=/opt/hbase-0.96/bin/. -dhbase.id.str=dat-dhbase.root.logger=info,rfa-dhbase.security.logger=info,rfas Org.apache.hadoop.hbase.zookeeper.HQuorumPeer start
Displays the zookeeper service that is already hbase, kills the PID, retries,
[Plain]View PlainCopy
- [Email protected]:/opt/hbase-0.96/bin$./start-hbase.sh
- Starting master, logging to/opt/hbase-0.96/bin/. /logs/hbase-dat-master-dat-hp.out
Normal start, Detect JPS
[Plain]View PlainCopy
- [Email protected]:/opt/hbase-0.96/bin$ JPS
- 25644 Hmaster
- 23468 Tasktracker
- 23199 Secondarynamenode
- 23307 Jobtracker
- 25849 Jps
- 22827 NameNode
- 23031 DataNode
Normal...
HBase Shell
Edit/etc/profile Join Hbase_home, re-entry into force, source/etc/profile
[Plain]View PlainCopy
- Export pig_install=/opt/pig-0.12.0
- Export path= $PATH: $PIG _install/bin
- Export pig_classpath=/opt/hadoop-1.2.1/conf
- Export hive_home=/opt/hive-0.12.0
- Export path= $HIVE _home/bin: $HIVE _home/conf: $PATH
- Export Ant_home=/opt/ant
- Export path= $PATH: $ANT _home/bin
- Export hbase_home=/opt/hbase-0.96
- Export path= $PATH: $HBASE _home/bin
HBase Shell Entry:
[Plain]View PlainCopy
- [Email protected]:/opt/hbase-0.96/bin$ hbase Shell
- HBase Shell; Enter ' help<return> ' for list of supported commands.
- Type "exit<return>" to leave the HBase Shell
- Version 0.96.0-hadoop1, r1531434, Fri Oct 15:11:29 PDT 2013
- HBase (Main):001:0>
Enter Help, which lists the commands supported by the HBase shell
Shutdown is to close the HBase cluster and exit is to exit the HBase shell.
HBase Shell Practice
Build table
HBase (main):006:0> create ' test ', ' CF '
List all Tables
HBase (main):007:0> list
TABLE
Test
1 row (s) in 0.0440 seconds
= = ["Test"]
Inserting data
HBase (main):008:0> put ' test ', ' row1 ', ' cf:a ', ' value1 '
0 row (s) in 0.0750 seconds
HBase (main):009:0> put ' test ', ' row2 ', ' cf:b ', ' value2 '
0 row (s) in 0.0080 seconds
HBase (main):010:0> put ' test ', ' row3 ', ' cf:c ', ' value3 '
0 row (s) in 0.0060 seconds
Check Insert Condition
HBase (main):011:0> scan ' test '
ROW Column+cell
Row1 column=cf:a, timestamp=1386389158263, value=value1
Row2 column=cf:b, timestamp=1386389170821, value=value2
Row3 column=cf:c, timestamp=1386389185954, Value=value3
3 row (s) in 0.0450 seconds
Get Row
HBase (main):012:0> get ' test ', ' row2 '
COLUMN CELL
Cf:b timestamp=1386389170821, Value=value2
1 row (s) in 0.0140 seconds
drop table after disable
HBase (Main):013:0> disable ' test '
0 row (s) in 1.4220 seconds
HBase (Main):014:0> drop ' test '
0 row (s) in 0.2740 seconds
HBase (main):015:0> list
TABLE
0 row (s) in 0.0270 seconds
= []
Ubuntu Install HBase