注意事项:
1:必须事先安装 Hadoop分布式集群,zookeeper分布式集群
2:查看版本号:
hbase version
tar -zxvf /opt/software/hbase-2.2.3-bin.tar.gz -C /usr/app/
mv hbase-2.2.3/ hbase2.2.3/
vi /etc/profile# hbase
export HBASE_HOME=/usr/app/hbase2.2.3
export PATH=$PATH:$HBASE_HOME/bin
HBase-env.sh
# jdk 安装目录
export HBASE_MANAGES_ZK=false
#配置hbase自己管理zookeeper
export JAVA_HOME=/usr/app/jdk1.8
hbase-site.xml
hbase.rootdir hdfs://hp1:9000/hbase
hbase.cluster.distributed true
hbase.zookeeper.quorum hp1:2181,hp2:2181,hp3:2181
regionservers
#自己的从节点主机
hp2
hp3
cp /usr/app/hadoop2.7.3/etc/hadoop/core-site.xml /usr/app/hbase2.2.3/conf/
cp /usr/app/hadoop2.7.3/etc/hadoop/hdfs-site.xml /usr/app/hbase2.2.3/conf/
scp -r /usr/app/hbase2.2.3/ hp2:/usr/app/scp /etc/profile hp2:/etc/
source /etc/profile
master主机上Zookeeper和Hadoop已经启动的情况下
bin/start-hbase.sh#关闭HBase服务:
bin/stop-hbase.sh
如图:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KDPYIzXD-1678177475722)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\image-20230306150543274.png)]](https://img.pic99.top/cnyincai/202405/d600c0d3e38236e.png)
hp1:
已经启动了HMaster 进程:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dJFe54TJ-1678177475723)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\image-20230306150656466.png)]](https://img.pic99.top/cnyincai/202405/90bf9fc36816.png)
hp2,hp3:
已经启动了 HRegionServer进程:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fJPiMhhW-1678177475723)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\image-20230306150818837.png)]](https://img.pic99.top/cnyincai/202405/358562255590789.png)
HBase Web界面URL地址为:
主机地址:16010/master/status
http://192.168.1.250:16010/master-status
如图:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-t5LFi1D4-1678177475724)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\image-20230306150957726.png)]](https://img.pic99.top/cnyincai/202405/edde774e15eeb4e.png)
进入HBase交互界面,查看状态和版本:
进入shell : hbase shell
查看集群状态: status
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GeHNgdaP-1678177475724)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\image-20230306151257456.png)]](https://img.pic99.top/cnyincai/202405/64d76168bc4e3ae.png)
HBase作为基于Hadoop的列式数据库,在成功启动HBase服务后,进入HBase交互界面(hbase shell),尝试创建表(并列族名)和插入、删除数据。
hbase(main):002:0> list
hbase(main):002:0> create 'student','info'student为表名,info为列族
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fXq4mGdK-1678177475725)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps1-16780868377331.jpg)]](https://img.pic99.top/cnyincai/202405/105d202707c31a7.jpeg)
hbase(main):003:0> put 'student','1001','info:sex','male'student为表名,1001为行键,info为列族,sex为列限定符,male为值
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OJAo9WsS-1678177475725)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps2-16780868377363.jpg)]](https://img.pic99.top/cnyincai/202405/84f0b298683b2a9.jpeg)
hbase(main):008:0>scan 'student'
hbase(main):011:0> describe ‘student’
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-t5Jccv75-1678177475726)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps4.jpg)]](https://img.pic99.top/cnyincai/202405/abdae0bc731369a.jpeg)
hbase(main):013:0> put 'student','1001','info:sex','female'
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2nI3i1bH-1678177475727)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps5.jpg)]](https://img.pic99.top/cnyincai/202405/057947ddcc17099.jpeg)
hbase(main):014:0> get 'student','10001'hbase(main):015:0> get 'student','10001','info:sex'
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VHa3qEMk-1678177475728)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps6.jpg)]](https://img.pic99.top/cnyincai/202405/629ffa7c4fa1f46.jpeg)
hbase(main):021:0> count 'student'
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NGhjToQn-1678177475728)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps7.jpg)]](https://img.pic99.top/cnyincai/202405/9f73a58c0032498.jpeg)
hbase(main):016:0> deleteall 'student','10001'删除某rowkey的某一列数据:hbase(main):017:0> delete 'student','10001','info:sex'
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xlRBvB13-1678177475729)(C:\Users\蒋欢\Desktop\题目搭建\搭建笔记\wps8.jpg)]](https://img.pic99.top/cnyincai/202405/49cf1be8b865467.jpeg)
hbase(main):018:0> truncate 'student'提示:清空表的操作顺序为先disable,然后再truncate。
首先需要先让该表为disable状态:
hbase(main):019:0> disable 'student'
然后才能drop这个表:
hbase(main):020:0> drop 'student'
hbase(main):018:0> truncate 'student'提示:清空表的操作顺序为先disable,然后再truncate。
首先需要先让该表为disable状态:
hbase(main):019:0> disable 'student'
然后才能drop这个表:
hbase(main):020:0> drop 'student'
上一篇:【数据结构】链表练习题(1)
下一篇:领域驱动设计-架构篇