Hbase安装配置

二、安装配置HABSE
HBase-0.92.x HBase-0.94.x HBase-0.96
Hadoop-0.20.205 S X X
Hadoop-0.22.x S X X
Hadoop-1.0.x S S S
Hadoop-1.1.x NT S S
Hadoop-0.23.x X S NT
Hadoop-2.x X S S
 
前提条件,安装jdk,并配置了环境变量
1.单机模式
 
直接解压安装包
tar -zxvf xxxxx.tar.gz
修改conf/hbase-site.xml,配置hbase使用的数据文件的位置,默认在/tmp/hbase-[username],此目录是linux的临时目录,可能会被系统清空,所以最好修改一下
<property>
<name>hbase.rootdir</name>
<value>file:///<path>/hbase</value>
</property>
测试
bin/start-hbase.sh
bin/hbase shell
hbase>status
 
hbase>help
 
hbase>create 'testtable',''colfam1','colfam2'
hbase>list
hbase>describe 'testtable'
hbase>put 'testtable','myrow-1','colfam1:q1','value-1'
hbase>put 'testtable','myrow-2','colfam1:q2','value-2'
hbase>put 'testtable','myrow-2','colfam1:q3','value-3'
hbase>scan 'testtable'
hbase>get 'testtable','myrow-1'
hbase>delete 'testtable','myrow-2','colfam1:q2'
hbase>scan 'testtable'
hbase>disable 'testtable'
hbase>drop 'testtable'
 
#建表时可以指定VERSIONS,配置的是当前列族在持久化到文件系统中时,要保留几个最新的版本数据,这并不影响内存中的历史数据版本
hbase>create 'testtable',{NAME=>'colfam1',VERSIONS=>3},{NAME=>'colfam2',VERSIONS=>1}
hbase>put 'testtable','myrow-1','colfam1:q1','value-1'
#直接使用scan而不加RAW=>true只能查询到最新版本的数据
hbase>scan 'testtable'
hbase>put 'testtable','myrow-1','colfam1:q1','value-2'
hbase>scan 'testtable'
hbase>put 'testtable','myrow-1','colfam1:q1','value-3'
hbase>scan 'testtable'
#可以在查询时加上RAW=>true来开启对历史版本数据的查询,VERSIONS=>3指定查询最新的几个版本的数据
hbase>scan 'testtable',{RAW=>true,VERSIONS=>3}
hbase>put 'testtable','myrow-1','colfam1:q1','value-4'
hbase>scan 'testtable'
hbase>scan 'testtable',{RAW=>true,VERSIONS=>3}
 
hbase>put 'testtable','myrow-1','colfam2:x1','value-1'
hbase>scan 'testtable'
hbase>put 'testtable','myrow-1','colfam2:x1','value-2'
hbase>scan 'testtable'
hbase>scan 'testtable',{RAW=>true,VERSIONS=>3}
 
#重启hbase
hbase>scan 'testtable',{RAW=>true,VERSIONS=>3}
 
#TODO:画图解释结构,没有数据的不占用空间,物理结构按列存储,方便压缩。
 
hbase>exit
bin/stop-hbase.sh
--------------------
hbase命令行下不能使用删除:
可以使用 ctrl+删除键 来进行删除
修改xshell配置:
文件->属性->终端->键盘
->delete键序列[VT220Del]
->backspace键序列[ASCII127]
--------------------
 
2.伪分布式模式
修改conf/hbase-env.sh修改JAVA_HOME
export JAVA_HOME=xxxx
修改hbase-site.xml,配置使用hdfs
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop00:9000/hbase</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
启动hbase
 
3.完全分布式模式
修改conf/hbase-env.sh修改JAVA_HOME
export JAVA_HOME=xxxx
修改hbase-site.xml,配置开启完全分布式模式
配置hbase.cluster.distributed为true。
配置hbase.rootdir设置为HDFS访问地址
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop00:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
 
配置region服务器,修改conf/regionservers文件,其中配置所有hbase主机,每个主机名独占一行,hbase启动或关闭时会按照该配置顺序启动或关闭主机中的hbase
 
使用已有的zookeeper集群。这种方式下zookeeper脱离了hbase,不会随着hbase的启动关闭而启动关闭。需要自己来启动关闭。
hbase默认使用自带的zookeeper,如果需要使用外部zookeeper,需要先关闭
修改conf/hbase-env.sh禁用内部zookeeper
export HBASE_MANAGES_ZK false
在hbase-site.xml中配置Zookeeper的连接地址与端口号
<property>
<name>hbase.zookeeper.quorum</name>
<value>hadoop01:2181,hadoop02:2181,hadoop03:2181</value>
</property>
 
--------------------------------------------------
~HBASE配置文件说明
hbase-env.sh配置HBase启动时需要的相关环境变量
hbase-site.xml配置HBase基本配置信息
HBASE启动时默认使用hbase-default.xml中的配置,如果需要可以修改hbase-site.xml文件,此文件中的配置将会覆盖hbase-default.xml中的配置
修改配置后要重启hbase才会起作用
--------------------------------------------------
 
启动集群
启动zookeeper
启动hdfs
启动hbase
访问http://xxxxx:60010来访问web界面,通过web见面管理hbase
也可以通过hbase shell脚本来访问bhase
 
关闭集群
stop-hbase.sh
原文地址:https://www.cnblogs.com/zpb2016/p/5791599.html