HBase安装学习
一、下载安装
$ wget http://archive.cloudera.com/cdh5/cdh/5/hbase-1.2.0-cdh5.7.0.tar.gz
$ tar -zxvf hbase-1.2.0-cdh5.7.0.tar.gz -C ~/apps
$ cd ~/apps/hbase-1.2.0-cdh5.7.0
二、配置文件
$ vi conf/hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>file:///home/hadoop/localhbase/hbase</value>
<!-- <value>hdfs://hadoop000:8020/hbase</value> -->
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/hadoop/localhbase/zookeeper</value>
</property>
配置到环境变量
export HBASE_HOME=/home/hadoop/apps/hbase-1.2.0-cdh5.7.0
export PATH=$HBASE_HOME/bin:$PATH
三、启动
1. 启动hbase服务:
$ start-hbase.sh
2. 启动hbase命令行:
$ hbase shell
3. 查看hbase 帮助
hbase(main):001:0> help
四、简单使用
hbase(main):005:0> create 'test1', 'cf'
0 row(s) in 4.4480 seconds
=> Hbase::Table - test1
hbase(main):006:0> list 'test1'
TABLE
test1
1 row(s) in 0.0290 seconds
=> ["test1"]
hbase(main):007:0> desc 'test1'
Table test1 is ENABLED
test1
COLUMN FAMILIES DESCRIPTION
{NAME => 'cf', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS
=> 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSI
ONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
1 row(s) in 0.2890 seconds
hbase(main):008:0> put 'test1', 'row1', 'cf:a', 'value1'
0 row(s) in 0.4990 seconds
hbase(main):009:0> put 'test1', 'row2', 'cf:b', 'value2'
0 row(s) in 0.1450 seconds
hbase(main):010:0> put 'test1', 'row3', 'cf:c', 'value3'
0 row(s) in 0.1770 seconds
hbase(main):011:0> scan 'test1'
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1560971554385, value=value1
row2 column=cf:b, timestamp=1560971563871, value=value2
row3 column=cf:c, timestamp=1560971573651, value=value3
3 row(s) in 0.2090 seconds
hbase(main):012:0> get 'test1', 'row1'
COLUMN CELL
cf:a timestamp=1560971554385, value=value1
1 row(s) in 0.0320 seconds
hbase(main):013:0> enable 'test1'
0 row(s) in 3.1270 seconds
hbase(main):014:0> drop 'test1'
ERROR: Table test1 is enabled. Disable it first.
Here is some help for this command:
Drop the named table. Table must first be disabled:
hbase> drop 't1'
hbase> drop 'ns1:t1'
hbase(main):015:0> disable 'test1'
0 row(s) in 3.1270 seconds
hbase(main):016:0> drop 'test1'
0 row(s) in 3.0160 seconds