電腦太卡了,使用不了hadoop和hdfs了,所以今天安裝了一個偽分布式,數據存儲在本地磁盤,也沒有向HDFS中存,也沒有使用自己的zookeeper,安裝過程中還出了點小問題,總結一下,免得忘了。
1.hbase的安裝
·將壓縮包上傳到linux中,解壓,上傳我使用的是secureCRT,直接ALT+P,然后從windows中下好的,拖進去就可以了。
·解壓命令:tar -zxvf hbase.tar.gz
·修改配置文件,將目錄切換到hbase/conf,修改第一個配置文件hbse-env.sh:這個文件修改兩個位置,第一個是加入jdk,第二個是將zookeeper設置true【使用自帶的,當然是可以使用自己的】
export JAVA_HOME=/home/kwhadoop/hadoop/jdk export HBASE_MANAGES_ZK=true
·修改hbse-site.xml文件,將目錄改到本地
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/kwhadoop/te</value>
</property>
</configuration>
·啟動命令
[root@hadoop bin]#./start-hbase.sh
`啟動shell
[root@hadoop bin]# ./hbase shell
2018-03-30 18:40:12,322 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.ava ilable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.96.2-hadoop2, r1581096, Mon Mar 24 16:03:18 PDT 2014
hbase(main):001:0>
(1)創建表
hbase(main):001:0> create 'user1','info1' 0 row(s) in 47.2280 seconds => Hbase::Table - user1
(2)顯示表
hbase(main):004:0> list TABLE user1 1 row(s) in 0.0960 seconds => ["user1"]
(3)顯示表結構
hbase(main):007:0> describe 'user1' DESCRIPTION ENABLED 'user1', {NAME => 'info1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0' true , VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS = > 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.2010 seconds
(4)刪除表的時候先要將表設置為disable,否則無法刪除
hbase(main):008:0> drop 'user1' ERROR: Table user1 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'
(5)將表設置為disable
hbase(main):008:0> disable 'user1'
(6)添加字段
hbase(main):002:0> put 'user1','1232456','info1:name','kw' 0 row(s) in 0.2550 seconds
(7)全表掃描
hbase(main):003:0> scan 'user1' ROW COLUMN+CELL 1232456 column=info1:name, timestamp=1522450895874, value=kw 1 row(s) in 0.1910 seconds
(8)列族中增加字段
hbase(main):004:0> put 'user1','1232456','info1:age','23' 0 row(s) in 0.0270 seconds
hbase(main):005:0> scan 'user1'
ROW COLUMN+CELL
1232456 column=info1:age, timestamp=1522450938635, value=23
1232456 column=info1:name, timestamp=1522450895874, value=kw
1 row(s) in 0.0730 seconds
(9)統計行數
hbase(main):011:0> count 'user1' 1 row(s) in 0.1290 seconds => 1
(10)獲取一個列族的數據
hbase(main):013:0> get 'user1','1232456','info1' COLUMN CELL info1:age timestamp=1522450938635, value=23 info1:name timestamp=1522450895874, value=kw 2 row(s) in 0.0400 seconds
(11)如果插入鍵值、列族、屬性相同的屬性,這個時候起到了更新的作用
hbase(main):018:0> put 'user1','1232456','info1:age','20' 0 row(s) in 0.0130 seconds hbase(main):019:0> scan 'user1' ROW COLUMN+CELL 1232456 column=info1:age, timestamp=1522453126526, value=20 1232456 column=info1:name, timestamp=1522450895874, value=kw 1 row(s) in 0.1330 seconds
(12)獲取指定的屬性,選取時間戳最新的數據顯示
hbase(main):022:0> get 'user1','1232456','info1:age' COLUMN CELL info1:age timestamp=1522453126526, value=20 1 row(s) in 0.0450 seconds
(13)刪除數據
hbase(main):023:0> delete 'user1','1232456','info1:age' 0 row(s) in 0.2380 seconds hbase(main):024:0> describe 'user1' DESCRIPTION ENABLED 'user1', {NAME => 'info1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0' true , VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS = > 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.2180 seconds hbase(main):025:0> scan 'user1' ROW COLUMN+CELL 1232456 column=info1:name, timestamp=1522450895874, value=kw 1 row(s) in 0.0370 seconds
(14)刪除所有
hbase(main):030:0> deleteall 'user1','1232456' 0 row(s) in 0.0210 seconds
hbase(main):031:0> list
TABLE
user1
1 row(s) in 0.1370 seconds
=> ["user1"]
hbase(main):032:0>
他只是將表中的列族刪除了嗎,表的刪除需要使用disable,然后drop就可以了。
表都刪了,那就不練了
