hbase 安装的先决条件是先安装好hadoop,zookeeper,因为我们使用独立的zookeeper集群。
Hadoop安装参考:"hadoop1.1.2分布式环境搭建" 点击打开链接
Zookeeper安装参考:"zookeeper分布式安装" 点击打开链接
服务器信息:
将hbase上传到icity0服务器的/home/hadoop/目录中,解压并且重命名为hbase。如图操作所示:
进入hbase下面的conf目录,
vi hbase-env.sh
此文件中增加如下部分:
export JAVA_HOME=/usr/java/jdk1.7.0_09
export HBASE_MANAGES_ZK=false //告诉hbase不使用自带的zookeeper。
export HBASE_HOME=/home/hadoop/hbase
export HADOOP_HOME=/home/hadoop/hadoop //hadoop 的home目录。
编辑hbase-site.xml文件,增加如下内容:
<property>
<name>hbase.hregion.memstore.flush.size</name>
<value>5242880</value>
<description>
Maximum desired file size for an HRegion. If filesize exceeds
value + (value / 2), the HRegion is split in two. Default: 256M.
Keep the maximum filesize small so we splitmore often in tests.
</description>
</property>
<property>
<name>hbase.hregion.max.filesize</name>se.hregion.memstore.flush.size
<value>20971520</value>
<description>
Maximum desired file size for anHRegion. If filesize exceeds
value + (value / 2), the HRegion is split in two. Default: 256M.
Keep the maximum filesize small so we split more often in tests.
</description>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
<description>Property from ZooKeeper's config zoo.cfg.
The port at which the clients will connect.
</description>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>icity0,icity1,icity2</value>
<description>Comma separated list of servers in the ZooKeeperQuorum.
For example,"host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
By default this is set to localhost for local and pseudo-distributedmodes
of operation. For a fully-distributed setup, this should be set to afull
list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set inhbase-env.sh
this is the list of servers which we will start/stop ZooKeeper on.
</description>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>1200000</value>
<description>Property from ZooKeeper's config zoo.cfg.
The directory where the snapshot is stored.
</description>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://icity0:9000/hbasedir</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
<description>The mode the cluster will be in. Possible values are
false: standalone and pseudo-distributed setups with managed Zookeeper
true: fully-distributed with unmanaged Zookeeper Quorum (seehbase-env.sh)
</description>
</property>
<property>
<name>hbase.master</name>
<value>icity0:60000</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
注:dfs.replication这个参数的配置根据实际需要修改,如果需要复制5份,就填5.如果不配置,在hadoop-site.xml中也为配置的话,其默认复制3份。
编辑regionservers文件,增加如下内容,见图:
复制habase整个目录到icity2,icity3服务器。
修改hadoop用户的.bash_profile文件。增加如下部分,如图所示:
vi .bash_profile
是环境变量生效:
source .bash_profile
将上面的配置文件scp到icity1 icity2服务器上,然后source .bash_profile。
经过上面配置完后,可以通过bin/start-hbase.sh命令启动hbase集群。注意启动hbase前,先要启动hadoop和zookeeper集群。
bin/start-hbase.sh
启动报错:
由于之前在编辑regionservers文件是未将localhost删除,而是#localhost了。故先停止hbase后,将所有服务器上的regionservers 文件中的#localhost删除掉,重新启动hbase。
启动成功日志及进程:
其master为icity0;
Icity1 jps查看:
启动成功后,可以通过http://localhost:60010查看hbase的管理页面,如图所示:
bin/stop-hbase.sh
通过hbase shell 进入shell操作界面:
更多详细操作参考官方文档。