1.安装
前提条件成功启动zk集群,hdfs,yarn
通过hbase官网下载jar包
1.1hbase-env.sh修改
export JAVA_HOME= 系统jdk安装目录
export HBASE_MANAGES_ZK=false
#export HBASE_MASTER_OPTS。。。。
#export HBASE_REGIONSERVER_OPTS。。。
1.2hbase-size.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop101:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- 0.98后的新变动,之前版本没有.port,默认端口为60000 -->
<property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>hadoop101:2181,hadoop102:2181,hadoop103:2181</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/module/zookeeper3.6/zdata</value>
</property>
1.3regionservers
hadoop101
hadoop102
hadoop103
1.4建立软连接
ln -s /module/hadoop2.6/etc/hadoop/core-site.xml /module/hbase1.6/conf/core-site.xml
ln -s /module/hadoop2.6/etc/hadoop/hdfs-site.xml /module/hbase1.6/conf/hdfs-site.xml
1.5启动
#启动方式1
bin/hbase-daemon.sh start master
bin/hbase-daemon.sh start regionserver
#启动方式2
bin/start-hbase.sh
bin/stop-hbase.sh
#页面访问
http://hadoop102:60010/master-status
2.shell操作
bin/hbase shell
help
list
create 'student','info'
put 'student','1001','info:sex','male'
put 'student','1001','info:age','18'
put 'student','1002','info:name','Janna'
put 'student','1002','info:sex','female'
put 'student','1002','info:age','20'
scan 'student'
scan 'student',{STARTROW => '1001', STOPROW => '1001'}
scan 'student',{STARTROW => '1001'}
describe 'student'
put 'student','1001','info:name','Nick'
put 'student','1001','info:age','100'
get 'student','1001'
get 'student','1001','info:name'
count 'student'
#删除某rowkey的全部数据
deleteall 'student','1001'
#删除某rowkey的某一列数据
delete 'student','1002','info:sex'
truncate 'student' #清空表的操作顺序为先disable,然后再truncate。
disable 'student'
drop 'student'
alter 'student',{NAME=>'info',VERSIONS=>3}
get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}
中文输出问题
scan 'WATER_BILL',{LIMIT=> 3, FORMATTER=>'toString'}
导入导出
导入语法格式:
hbase org.apache.hadoop.hbase.mapreduce.Import 表名 hdfs的数据所在路径
操作案例:
hbase org.apache.hadoop.hbase.mapreduce.Import WATER_BILL /water_bill/output_ept_10w/part-m-00000_10w
导出语法格式:
hbase org.apache.hadoop.hbase.mapreduce.Export 表名 导出hdfs的路径