准备工作
配置好一个master,两个slave:slave1,slave2,启动hadoop
master结点
[root@master ~]# start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [master]
master: starting namenode, logging to /home/hadoop/hadoop-2.7.3/logs/hadoop-root-namenode-master.out
slave2: starting datanode, logging to /home/hadoop/hadoop-2.7.3/logs/hadoop-root-datanode-slave2.out
slave1: starting datanode, logging to /home/hadoop/hadoop-2.7.3/logs/hadoop-root-datanode-slave1.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /home/hadoop/hadoop-2.7.3/logs/hadoop-root-secondarynamenode-master.out
starting yarn daemons
starting resourcemanager, logging to /home/hadoop/hadoop-2.7.3/logs/yarn-root-resourcemanager-master.out
slave1: starting nodemanager, logging to /home/hadoop/hadoop-2.7.3/logs/yarn-root-nodemanager-slave1.out
slave2: starting nodemanager, logging to /home/hadoop/hadoop-2.7.3/logs/yarn-root-nodemanager-slave2.out
[root@master ~]# jps
5334 NameNode
5530 SecondaryNameNode
5690 ResourceManager
5981 Jps
slave1结点
[root@slave1 ~]# jps
5265 NodeManager
5155 DataNode
5459 Jps
slave2结点
[root@slave2 ~]# jps
5271 NodeManager
5160 DataNode
5497 Jps
启动hbase
master结点
[root@master ~]# start-hbase.sh
slave2: starting zookeeper, logging to /home/hadoop/hbase-1.2.6/bin/../logs/hbase-root-zookeeper-slave2.out
slave1: starting zookeeper, logging to /home/hadoop/hbase-1.2.6/bin/../logs/hbase-root-zookeeper-slave1.out
master: starting zookeeper, logging to /home/hadoop/hbase-1.2.6/bin/../logs/hbase-root-zookeeper-master.out
starting master, logging to /home/hadoop/hbase-1.2.6/logs/hbase-root-master-master.out
slave2: starting regionserver, logging to /home/hadoop/hbase-1.2.6/bin/../logs/hbase-root-regionserver-slave2.out
slave1: starting regionserver, logging to /home/hadoop/hbase-1.2.6/bin/../logs/hbase-root-regionserver-slave1.out
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
[root@master ~]# jps
6321 HQuorumPeer
6385 HMaster
6498 Jps
5334 NameNode
5530 SecondaryNameNode
5690 ResourceManager
slave1结点
[root@slave1 ~]# jps
5265 NodeManager
5155 DataNode
5764 Jps
5593 HQuorumPeer
5674 HRegionServer
slave2结点
[root@slave1 ~]# jps
5265 NodeManager
5155 DataNode
5764 Jps
5593 HQuorumPeer
5674 HRegionServer
进入HBash-shell console
hbase shell
[root@master ~]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017
hbase(main):001:0> list
TABLE
0 row(s) in 0.4440 seconds
=> []
hbase(main):002:0>
表的管理
列举表 list
hbase(main):001:0> list
TABLE
0 row(s) in 0.4440 seconds
=> []
hbase(main):002:0>
创建表
hbase(main):002:0> create 't1',{NAME=>'f1', VERSIONS=>1}, {NAME=>'f2', VERSIONS=>2}
Unknown argument ignored for column family f1: 1.8.7
Unknown argument ignored for column family f2: 1.8.7
0 row(s) in 2.9780 seconds
=> Hbase::Table - t1
查看表
hbase(main):013:0> describe 't1'
Table t1 is ENABLED
t1
COLUMN FAMILIES DESCRIPTION
{NAME => 'f1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL =>
'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'f2', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL =>
'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
2 row(s) in 0.0730 seconds
修改表
hbase(main):053:0* describe 't1'
Table t1 is ENABLED
t1
COLUMN FAMILIES DESCRIPTION
{NAME => 'f1', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', CO
MPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'f2', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', CO
MPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
2 row(s) in 0.1170 seconds
hbase(main):054:0> disable 't1'
0 row(s) in 2.2620 seconds
hbase(main):055:0> alter 't1',NAME => 'f1',VERSIONS => 11
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.4480 seconds
hbase(main):056:0> enable 't1'
0 row(s) in 1.2630 seconds
hbase(main):057:0> describe 't1'
Table t1 is ENABLED
t1
COLUMN FAMILIES DESCRIPTION
{NAME => 'f1', BLOOMFILTER => 'ROW', VERSIONS => '11', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', C
OMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
{NAME => 'f2', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', CO
MPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}
2 row(s) in 0.0790 seconds
hbase(main):058:0>
删除表
hbase(main):058:0> disable 't1'
0 row(s) in 2.2610 seconds
hbase(main):059:0> drop 't1'
0 row(s) in 1.3000 seconds
hbase(main):060:0> describe 't1'
ERROR: Unknown table t1!
Here is some help for this command:
Describe the named table. For example:
hbase> describe 't1'
hbase> describe 'ns1:t1'
Alternatively, you can use the abbreviated 'desc' for the same thing.
hbase> desc 't1'
hbase> desc 'ns1:t1'
hbase(main):061:0>
添加数据
hbase(main):010:0* put 't1' , 'rowkey001','f1:coll','value01'
0 row(s) in 0.0320 seconds
hbase(main):011:0> put 't1' , 'rowkey001','f2:coll','value02'
查看数据
hbase(main):004:0> get 't1','rowkey001','f1:coll'
COLUMN CELL
f1:coll timestamp=1600570676360, value=value01
1 row(s) in 0.1120 seconds
hbase(main):012:0> get 't1','rowkey001'
COLUMN CELL
f1:coll timestamp=1600570857429, value=value01
f2:coll timestamp=1600570869437, value=value02
2 row(s) in 0.0250 seconds
扫描表
hbase(main):077:0> scan 't1',{LIMIT=>2}
ROW COLUMN+CELL
rowkey001 column=f1:coll, timestamp=1600571650242, value=value01
rowkey001 column=f2:coll, timestamp=1600571663393, value=value02
rowkey002 column=f1:coll, timestamp=1600571735255, value=value01
2 row(s) in 0.0480 seconds
查询表种的数据行数
count ‘t1’ , {INTERVAL => 100, CACHE=>500}
hbase(main):078:0> count 't1' , {INTERVAL => 100, CACHE=>500}
2 row(s) in 0.0410 seconds
=> 2
删除数据
删除行中的某个值
delete ‘t1’, ‘rowkey001’,‘f1:coll’
hbase(main):079:0> delete 't1', 'rowkey001','f1:coll'
0 row(s) in 0.0620 seconds
hbase(main):080:0> count 't1' , {INTERVAL => 100, CACHE=>500}
2 row(s) in 0.0270 seconds
=> 2
hbase(main):081:0> scan 't1',{LIMIT=>2}
ROW COLUMN+CELL
rowkey001 column=f2:coll, timestamp=1600571663393, value=value02
rowkey002 column=f1:coll, timestamp=1600571735255, value=value01
2 row(s) in 0.0450 seconds
hbase(main):082:0>
删除行
delete ‘t1’, ‘rowkey001’
hbase(main):092:0* deleteall 't1', 'rowkey001'
0 row(s) in 0.0160 seconds
hbase(main):093:0> scan 't1',{LIMIT=>2}
ROW COLUMN+CELL
rowkey002 column=f1:coll, timestamp=1600571735255, value=value01
1 row(s) in 0.0300 seconds
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/140816.html