单机hbase安装及使用

发布于:2022-11-09 ⋅ 阅读:(10) ⋅ 点赞:(0) ⋅ 评论:(0)

hbase安装

1.下载hbase包

目录

hbase安装

使用hbase


网址为:Index of /dist/hbase/2.0.2

2.通过winscp软件将hbase上传到虚拟机

 

 

 

3.将hbase解压到programs文件夹并为其修改短名

 

 

 

 

4.进入hbase/conf文件修改hbase-env.sh

添加

export JAVA_HOME=/usr/local/java
export HBASE_MANAGES_ZK=true

 

 

 

5.修改hbase-site.xml文件

<property>
<name>hbase.rootfir</name>
<value>file:///usr/local/hbase/rootdir</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/hbase/zookeeper</value>
</property>

 

6.进入etc/profile配置hbase环境变量

vi /etc/profile

export HBASE_HOME=/usr/local/hbase
export PATH=$HBASE_HOME/bin:$PATH

 

7.使环境生效

source /etc/profile

8.启动hbase

start-hbase.sh

9.启动hbase shell

 

 

10.测试hbase
输入list

 

--------------------------------------------------------------------------------------使用hbase

1.查看版本信息version

2.查看hbase运行状态status

 

3.查看当前用户whoami

 4.退出为:exit

5.查看已存在的表list

 6.创建表

create 'student_sports',{NAME=>'basic_info',VERSIONS=>3},{NAME=>'score',VERSIONS=>3}

7.查看表结构desc

8.查看表是否存在exists

 

9.将表设置为不可以状态disable

 

 10.添加新的列族alter

alter 'student_sports',{NAME=>'new_cf',VERSIONS=>3}

 11.将表设置为可用enable

 

 12.删除列族

 alter 'student_sports',{NAME=>'new_cf',METHOD=>'delete'}

 13.插入数据

put 'student_sports','410000001','basic_info:name','Tom'

 put 'student_sports','410000001','basic_info:height','180cm'

put 'student_sports','410000001','basic_info:weight','75kg'

put 'student_sports','410000001','basic_info:standing','2.12m'

put 'student_sports','410000001','basic_info:running','04:32'

 14.更新数据

put 'student_sports','410000001','basic_info:name','Tomny'

 15.获取数据

 get 'student_sports','410000001'

 16.查看表行数count

 

17.全表扫描

18.删除列和行数据

列:

delete 'student_sports','410000001','basic_info:name'

 行:

deleteall 'student_sports','410000001','basic_info:name'

 19.清空表

 truncate 'student_sports'

20.删除表

要删除表必须先禁用表