tar -zxvf hbase-2.4.9-bin.tar.gz -C /opt/module
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64 export HBASE_MANAGES_ZK=false
<configuration> <property> <name>hbase.rootdir</name> <value>hdfs://hadoop101:8020/HBase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>hadoop101,hadoop102,hadoop103</value> </property> </configuration>
hadoop101 hadoop102 hadoop103
然后利用分发脚本把hbase分发到另外两个环境。或者手动复制过去
进到hbase的根目录下,启动 :
bin/start-hbase.sh
对应的停止服务:
bin/stop-hbase.sh
启动成功后,可以通过“host:port”的方式来访问 HBase 管理页面,例如:
http://hadoop101:16010
bin/hbase shell
hbase(main):001:0> help
hbase(main):002:0> list
hbase(main):002:0> create 'student','info'
hbase(main):003:0> put 'student','1001','info:sex','male' hbase(main):004:0> put 'student','1001','info:age','18' hbase(main):005:0> put 'student','1002','info:name','Janna' hbase(main):006:0> put 'student','1002','info:sex','female' hbase(main):007:0> put 'student','1002','info:age','20'
hbase(main):008:0> scan 'student' hbase(main):009:0> scan 'student',{STARTROW => '1001', STOPROW =>'1001'} hbase(main):010:0> scan 'student',{STARTROW => '1001'}
hbase(main):011:0> describe ‘student’
hbase(main):012:0> put 'student','1001','info:name','Nick' hbase(main):013:0> put 'student','1001','info:age','100'
hbase(main):014:0> get 'student','1001' hbase(main):015:0> get 'student','1001','info:name'
hbase(main):021:0> count 'student'
hbase(main):016:0> deleteall 'student','1001'
hbase(main):017:0> delete 'student','1002','info:sex'
hbase(main):018:0> truncate 'student'
提示: 清空表的操作顺序为先 disable,然后再 truncate。
hbase(main):019:0> disable 'student'
hbase(main):020:0> drop 'student'
提示: 如果直接 drop 表,会报错: ERROR: Table student is enabled. Disable it first.
将 info 列族中的数据存放 3 个版本:
hbase(main):022:0> alter 'student',{NAME=>'info',VERSIONS=>3} hbase(main):022:0> get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}