HBASE
[root@linux01 install]# tar zxf hbase-1.2.0-cdh5.14.2.tar.gz -C ../soft
[root@linux01 soft]# mv hbase-1.2.0-cdh5.14.2 hbase120
[root@linux01 conf]# vi ./hbase-env.sh
27 export JAVA_HOME=/opt/soft/jdk180
128 export HBASE_MANAGES_ZK=false
[root@linux01 conf]# vi ./hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://192.168.111.131:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/soft/hbase120/hbasedir</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
start-hbase.sh
stop-hbase.sh
进入到hbase shell
[root@gree139 conf]# hbase shell
查看版本
hbase(main):001:0> version
查看命名空间
hbase(main):008:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.1410 seconds
查看命名空间下的表
hbase(main):009:0> list_namespace_tables 'hbase'
TABLE
meta
namespace
2 row(s) in 0.0150 seconds
创建namespace
hbase(main):010:0> create_namespace 'lijia'
0 row(s) in 0.0500 seconds
删除namespace
hbase(main):012:0> drop_namespace 'lijia'
0 row(s) in 0.0280 seconds
查看命名空间下有多少表
hbase(main):005:0> list_namespace_tables 'gree'
TABLE
0 row(s) in 0.0170 seconds
创建表
hbase(main):006:0> create 'gree:student','baseInfo','schoolInfo'
0 row(s) in 2.2740 seconds
=> Hbase::Table - gree:student
禁用gree:student表
hbase(main):010:0> disable 'gree:student'
0 row(s) in 2.2670 seconds
删除表(删除表之前先禁用表,否则删除失败)
hbase(main):012:0> drop 'gree:student'
0 row(s) in 1.2600 seconds
查询表结构
hbase(main):016:0> describe 'gree:student'
Table gree:student is ENABLED
gree:student
COLUMN FAMILIES DESCRIPTION
{NAME => 'baseInfo', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CEL
LS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSION
S => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'schoolInfo', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_C
ELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSI
ONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
2 row(s) in 0.0170 seconds
插入数据
hbase(main):017:0> put 'gree:student','rowkey1','baseInfo:name','tom'
0 row(s) in 0.0680 seconds
hbase(main):024:0> put 'gree:student','rowkey1','schoolInfo:name','njzb'
0 row(s) in 0.0140 seconds
hbase(main):022:0> put 'gree:student','rowkey1','baseInfo:age','32'
0 row(s) in 0.0090 seconds
hbase(main):026:0> get 'gree:student','rowkey1','baseInfo'
COLUMN CELL
baseInfo:age timestamp=1637287937682, value=32
baseInfo:birthday timestamp=1637287837416, value=1989-01-01
baseInfo:name timestamp=1637287603055, value=tom
3 row(s) in 0.0040 seconds
hbase(main):027:0> get 'gree:student','rowkey1','schoolInfo'
COLUMN CELL
schoolInfo:name timestamp=1637288031855, value=njzb
1 row(s) in 0.0030 seconds
hbase(main):028:0> get 'gree:student','rowkey1','baseInfo:name'
COLUMN CELL
baseInfo:name timestamp=1637287603055, value=tom
1 row(s) in 0.0090 seconds
hbase(main):026:0> get 'gree:student','rowkey1','baseInfo'
COLUMN CELL
baseInfo:age timestamp=1637287937682, value=32
baseInfo:birthday timestamp=1637287837416, value=1989-01-01
baseInfo:name timestamp=1637287603055, value=tom
3 row(s) in 0.0040 seconds
hbase(main):027:0> get 'gree:student','rowkey1','schoolInfo'
COLUMN CELL
schoolInfo:name timestamp=1637288031855, value=njzb
1 row(s) in 0.0030 seconds
hbase(main):028:0> get 'gree:student','rowkey1','baseInfo:name'
COLUMN CELL
baseInfo:name timestamp=1637287603055, value=tom
1 row(s) in 0.0090 seconds
退出
hbase(main):014:0> exit
http://192.168.153.139:60010/
单机版HBASE安装、配置、使用笔记
于 2021-11-20 19:46:18 首次发布