In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to operate HBase shell, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Enter hbase Shell
[root@test31 ~] # hbase shell
HBase Shell; enter 'help' for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
1. View server status
Hbase (main): 001VR 0 > status
1 servers, 0 dead, 3.0000 average load
two。 View HBase version
Hbase (main): 002purl 0 > version
0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012
3.DDL operation
1) .create command
Create a table "member" with three column families "member_id" and "address" or "info", where table names, rows, and columns are enclosed in single quotes and separated by commas.
Hbase (main): 003 create 0 > member','member_id','address','info'
0 row (s) in 1.1770 seconds
2) .list command
See which tables are available in the current HBase
Hbase (main): 004VR 0 > list
TABLE
Member
Test
2 row (s) in 0.0170 seconds
3) .describe command
View the description of the table
Hbase (main): 006 describe 0 > member'
DESCRIPTION ENABLED
{NAME = > 'member', FAMILIES = > [{NAME = >' address', BLOOMFILTER = > 'NONE', REPLICATION_SCO true
PE = > '0mm, VERSIONS = >' 3mm, COMPRESSION = > 'NONE', MIN_VERSIONS = >' 0mm, TTL = > '2147483647
', BLOCKSIZE = >' 65536', IN_MEMORY = > 'false', BLOCKCACHE = >' true'}, {NAME = > 'info', BLO
OMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm, VERSIONS = > '34th, COMPRESSION = >' NONE', MIN_
VERSIONS = > '013, TTL = >' 2147483647, BLOCKSIZE = > '65536, IN_MEMORY = >' false', BLOCKCAC
HE = > 'true'}, {NAME = >' member_id', BLOOMFILTER = > 'NONE', REPLICATION_SCOPE = >' 0mm, VERS
IONS = > '319, COMPRESSION = >' NONE', MIN_VERSIONS = > '0mm, TTL = >' 2147483647, BLOCKSIZE = >
'65536, IN_MEMORY = >' false', BLOCKCACHE = > 'true'}]}
1 row (s) in 0.0320 seconds
4)。 Delete a column family: disable,alter,enable
To modify the table structure, you must first disable
Hbase (main): 004VR 0 > disable member
NameError: undefined local variable or method `member' for #
Hbase (main): 005hbase 0 > disable 'member'
0 row (s) in 2.1560 seconds
Delete the info column of the member table
Hbase (main): 006 member', 0 > alter 'member',' delete' = > 'info'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row (s) in 1.3370 seconds
Remember the enable table:
Hbase (main): 009 enable 0 > member'
0 row (s) in 2.2330 seconds
5)。 Delete a table test (disable,drop)
Hbase (main): 025 disable 0 > test'
0 row (s) in 2.2100 seconds
Hbase (main): 026 drop 0 > test'
0 row (s) in 1.2350 seconds
6)。 Query whether the table exists
Hbase (main): 033 exists 0 > test'
Table test does not exist
0 row (s) in 0.1820 seconds
7)。 Check to see if the table is enable
Hbase (main): 032 is_enabled 0 > member'
True
0 row (s) in 0.0070 seconds
4.DML operation
1)。 Insert data
Hbase (main): 005hbase 0 > put 'member','scutshuxue','info:age','24'
0 row (s) in 0.0790 seconds
Hbase (main): 005hbase 0 > put 'member','duansf','info:age','37'
0 row (s) in 0.0790 seconds
Hbase (main): 001put 0 > member','scutshuxue','info:company','alibaba'
0 row (s) in 0.6520 seconds
Hbase (main): 002 put 0 > member','xiaofeng','address:contry','china'
0 row (s) in 0.0090 seconds
Hbase (main): 007put 0 > member','xiaofeng','info:birthday','1987-4-17'
0 row (s) in 0.0120 seconds
Note: there must be no spaces after the insert statement.
2)。 Get a piece of data
Hbase (main): 012 get 'member','xiaofeng'
COLUMN CELL
Address:contry timestamp=1488307463293, value=china
Info:birthday timestamp=1488307533852, value=1987-4-17
2 row (s) in 0.0130 seconds
3)。 Get information about a column family in a record
Hbase (main): 013 get 0 > member','xiaofeng','info'
COLUMN CELL
Info:birthday timestamp=1488307533852, value=1987-4-17
1 row (s) in 0.0100 seconds
4)。 Get information about a column in a column family of a record
Hbase (main): 020 get 0 > member','xiaofeng','info:birthday'
COLUMN CELL
Info:birthday timestamp=1488307533852, value=1987-4-17
1 row (s) in 0.0090 seconds
5)。 Update a record
Change the age of duansf to 38
Hbase (main): 022 get 'member','duansf','info:age'
COLUMN CELL
Info:age timestamp=1488308172957, value=37
1 row (s) in 0.0090 seconds
Put 'member','duansf','info:age','38'
6)。 Delete a column in the member table
Hbase (main): 032 delete 'member','scutshuxue','info:age'
0 row (s) in 0.0080 seconds
7) .member table full table scan (similar to relational database select *)
Hbase (main): 002 scan 0 > member'
ROW COLUMN+CELL
Scutshuxue column=info:age, timestamp=1488306890710, value=24
Scutshuxue column=info:company, timestamp=1488307003752, value=alibaba
Xiaofeng column=address:contry, timestamp=1488307463293, value=china
Xiaofeng column=info:birthday, timestamp=1488307533852, value=1987-4-17
2 row (s) in 0.9780 seconds
8)。 Delete the entire row
Hbase (main): 036VR 0 > deleteall 'member','scutshuxue'
0 row (s) in 0.0090 seconds
9)。 Query how many rows are in the member table
Hbase (main): 041 count 0 > member'
2 row (s) in 0.0240 seconds
10)。 Empty the whole table
Hbase (main): 045 truncate 'member'
Truncating 'member' table (it may take a while):
-Disabling table...
-Dropping table...
-Creating table...
0 row (s) in 4.8640 seconds
Attached picture:
HBase Shell command interpretation
The above is all the content of this article "how to operate HBase shell". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.