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中
hbase.rootdir
file:///home/lang/software/hbase
hbase.zookeeper.property.dataDir
/home/lang/software/zookeeper
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文件:
hbase.cluster.distributed
true
hbase.rootdir
hdfs://localhost:9000/hbase
hbase.zookeeper.property.dataDir
/home/lang/software/zookeeper
在hdfs上建立hbase文件夹