1.上傳解壓文件
文件:hbase-1.0.1.1-bin.tar
2.更改配置文件
在hbase-env.sh中,
export JAVA_HOME=/home/lang/software/jdk1.8.0_121
export HBASE_MANAGES_ZK=true
在hbase-site.xml中
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/lang/software/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/lang/software/zookeeper</value>
</property>
</configuration>
3.啟動hbase
$HBASE_HOME/bin/start-hbase.sh
打開jps如下圖所示:
4.關閉hbase
$HBASE_HOME/bin/stop-hbase.sh
5.進入HBase shell
5.0 $HBASE_HOME/bin/hbase shell
5.1創建表students,兩個列族:info ,address
5.2 添加數據
put 'students','zhangsan','info:sno','001'
put 'students','zhangsan','info:sname','張三'
put 'students','zhangsan','address','天津'
5.3查詢數據
get 'students','zhangsan'
5.4 更新數據
5.5 刪除數據
delete 'students','zhangsan','address'
5.6 統計表的行數
count 'students'
5.7 清空表
truncate 'students
5.8 刪除表
disable 'students'
drop 'students'
6.列族的數量是固定的,列的數量是添加數據時寫
7.偽分布式安裝將數據文件存儲到HDFS上
修改hbase-site.xml文件:
<configuration>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/lang/software/zookeeper</value>
</property>
</configuration>
在hdfs上建立hbase文件夾