注意事项:
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
如图:
hp1:
已经启动了HMaster 进程:
hp2,hp3:
已经启动了 HRegionServer进程:
HBase Web界面URL地址为:
主机地址:16010/master/status
http://192.168.1.250:16010/master-status
如图:
进入HBase交互界面,查看状态和版本:
进入shell : hbase shell
查看集群状态: status
HBase作为基于Hadoop的列式数据库,在成功启动HBase服务后,进入HBase交互界面(hbase shell),尝试创建表(并列族名)和插入、删除数据。
hbase(main):002:0> list
hbase(main):002:0> create 'student','info'student为表名,info为列族
hbase(main):003:0> put 'student','1001','info:sex','male'student为表名,1001为行键,info为列族,sex为列限定符,male为值
hbase(main):008:0>scan 'student'
hbase(main):011:0> describe ‘student’
hbase(main):013:0> put 'student','1001','info:sex','female'
hbase(main):014:0> get 'student','10001'hbase(main):015:0> get 'student','10001','info:sex'
hbase(main):021:0> count 'student'
hbase(main):016:0> deleteall 'student','10001'删除某rowkey的某一列数据:hbase(main):017:0> delete 'student','10001','info:sex'
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)
下一篇:领域驱动设计-架构篇