溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

使用shell命令操作HBase數(shù)據(jù)庫

發(fā)布時間:2020-07-28 11:22:44 來源:網(wǎng)絡(luò) 閱讀:674 作者:sky9890 欄目:關(guān)系型數(shù)據(jù)庫

操作環(huán)境:

操作系統(tǒng):Ubuntu 16.04.6 LTS?

HBase版本:HBase 1.1.5

? ? HBase是一個高可靠、高性能、面向列、可伸縮的分布式數(shù)據(jù)庫,主要用來存儲非結(jié)構(gòu)化和半結(jié)構(gòu)化的松散數(shù)據(jù)。

hadoop@dblab:/usr/local/hadoop$ cd /usr/local/hbase

hadoop@dblab:/usr/local/hbase$ bin/start-hbase.sh? ?? #啟動HBase

hadoop@dblab:/usr/local/hbase$ bin/hbase? shell?? ?? #進入Shell模式

#創(chuàng)建student表

hbase(main):001:0> create 'student','Sname','Ssex','Sage','Sdept','course'? ??

0 row(s) in 1.6440 seconds

=> Hbase::Table - student

#查看數(shù)據(jù)庫中已經(jīng)創(chuàng)建的表

hbase(main):002:0> list

TABLE? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

student? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

1 row(s) in 0.0410 seconds

=> ["student"]

#查看表結(jié)構(gòu)

hbase(main):003:0> describe 'student'

Table student is ENABLED? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

student? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

COLUMN FAMILIES DESCRIPTION? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

{NAME => 'Sage', 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 => 'Sdept', 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 => 'Sname', 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 => 'Ssex', 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 => 'course', 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'}? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

5 row(s) in 0.1650 seconds

#向表中添加數(shù)據(jù)

hbase(main):004:0> put 'student','95001','Sname','LiYing'

hbase(main):004:0> put 'student','95001','Sname','LiYing'

hbase(main):005:0> put 'student','95001','Ssex','male'

hbase(main):006:0> put 'student','95001','Sage','22'

hbase(main):007:0> put 'student','95001','Sdept','Cs'

hbase(main):008:0> put 'student','95001','Course:math','80'

ERROR: Unknown column family! Valid column names: Sage:*, Sdept:*, Sname:*, Ssex:*, course:*

hbase(main):009:0> put 'student','95001','course:math','80'

0 row(s) in 0.0330 seconds

#查看某個單元格數(shù)據(jù)

hbase(main):010:0> get 'student','95001'

COLUMN? ? ? ? ? ? ? ? ? ? ? ? ? ? ?CELL? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?Sage:? ? ? ? ? ? ? ? ? ? ? ? ? ? ?timestamp=1558580423554, value=22? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?Sdept:? ? ? ? ? ? ? ? ? ? ? ? ? ? timestamp=1558580447276, value=Cs? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?Sname:? ? ? ? ? ? ? ? ? ? ? ? ? ? timestamp=1558580336295, value=LiYing? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?Ssex:? ? ? ? ? ? ? ? ? ? ? ? ? ? ?timestamp=1558580402507, value=male? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?course:math? ? ? ? ? ? ? ? ? ? ? ?timestamp=1558580543129, value=80? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

5 row(s) in 0.0850 seconds

#查詢表中有數(shù)據(jù)所

hbase(main):011:0> scan 'student'

ROW? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? COLUMN+CELL? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sage:, timestamp=1558580423554, value=22? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sdept:, timestamp=1558580447276, value=Cs? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sname:, timestamp=1558580336295, value=LiYing? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Ssex:, timestamp=1558580402507, value=male? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=course:math, timestamp=1558580543129, value=80? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

1 row(s) in 0.0740 seconds

#刪除95001行中的Ssex列的所有數(shù)據(jù)

hbase(main):014:0> delete 'student','95001','Ssex'

hbase(main):015:0> scan 'student'

ROW? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? COLUMN+CELL? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sage:, timestamp=1558580423554, value=22? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sdept:, timestamp=1558580447276, value=Cs? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=Sname:, timestamp=1558580336295, value=LiYing? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??

?95001? ? ? ? ? ? ? ? ? ? ? ? ? ? ?column=course:math, timestamp=1558580543129, value=80?

#刪除表中為95001行的全部數(shù)據(jù)

hbase(main):016:0> deleteall 'student','95001'

0 row(s) in 0.0390 seconds

#該表中所存在任何數(shù)據(jù)

hbase(main):017:0> scan 'student'

ROW? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? COLUMN+CELL? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

#刪除表

hbase(main):006:0> disable 'student'

hbase(main):009:0> drop 'student'

#退出數(shù)據(jù)庫操作

hbase(main):018:0> exit







向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI