HBase集群需要整个集群所有节点安装的HBase版本保持一致,并且拥有相同的配置,具体配置步骤如下:
1. 解压缩HBase的压缩包
2. 配置HBase的环境变量
3. 修改HBase的配置文件,HBase的配置文件存放在HBase安装目录下的conf中
4. 首先在一台节点对整个HBase集群进行配置,再将此节点的配置发送到集群的其它节点上。
5. 具体需要修改的HBase的配置文件包括 hbase-site.xml、hbase-env.sh、regionservers、backup-masters、

[root@node1 ~]# tar -xzf /opt/software/hbase.tar.gz -C /opt/module/
[root@node1 ~]# vi /etc/profile
- export HBASE_HOME=/opt/module/hbase
- export PATH=$PATH:$HBASE_HOME/bin

- [root@node1 ~]# scp -rq /etc/profile node2:/etc/
- [root@node1 ~]# scp -rq /etc/profile node3:/etc/
解释
部分参数说明: -p:保留原文件的修改时间,访问时间和访问权限。 -q: 不显示传输进度条。 -r: 递归复制整个目录。 所以,如果使用scp命令只复制单个文件,可以不添加-rq参数。
[root@node1 ~]# source /etc/profile
- [root@node1 ~]# cd $HBASE_HOME/conf
- [root@node1 ~]# vi hbase-env.sh
在文件末尾添加如下配置:
- export JAVA_HOME=/opt/module/jdk1.8.0_301/
- export HBASE_MANAGES_ZK=false

[root@node1 conf]# vi hbase-site.xml
在
- <property>
- <name>hbase.rootdir</name>
- <value>hdfs://node1:9000/hbase</value>
- </property>
- <property>
- <name>hbase.unsafe.stream.capability.enforce</name>
- <value>false</value>
- </property>
- <property>
- <name>hbase.cluster.distributed</name>
- <value>true</value>
- </property>
- <property>
- <name>hbase.zookeeper.quorum</name>
- <value>node1:2181,node2:2181,node3:2181</value>
- </property>
配置完成后完整内容如下:
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <!--
- /**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- -->
- <configuration>
- <property>
- <name>hbase.rootdir</name>
- <value>hdfs://node1:9000/hbase</value>
- </property>
- <property>
- <name>hbase.unsafe.stream.capability.enforce</name>
- <value>false</value>
- </property>
- <property>
- <name>hbase.cluster.distributed</name>
- <value>true</value>
- </property>
- <property>
- <name>hbase.zookeeper.quorum</name>
- <value>node1:2181,node2:2181,node3:2181</value>
- </property>
- </configuration>
配置regionservers文件
[root@node1 conf]# vi regionservers
配置内容如下:
- node1
- node2
- node3
- [root@node1 conf]# cp $HADOOP_HOME/etc/hadoop/core-site.xml $HBASE_HOME/conf/
- [root@node1 conf]# cp $HADOOP_HOME/etc/hadoop/hdfs-site.xml $HBASE_HOME/conf/
- [root@node1 ~]# cd /opt/module/
- [root@node1 module]# scp -rq hbase node2:/opt/module/
- [root@node1 module]# scp -rq hbase node3:/opt/module/
[root@node1 ~]# start-hbase.sh

- [root@node1 ~]# hbase shell
- hbase(main):001:0> create 'test','data'
- 0 row(s) in 0.4150 seconds

解释
hbase(main):003:0> list TABLE test 1 row(s) in 0.0230 seconds

- hbase(main):004:0> put 'test','row1','data:1','values1'
- 0 row(s) in 0.1280 seconds
- hbase(main):005:0> put 'test','row2','data:2','values2'
- 0 row(s) in 0.0090 seconds
- hbase(main):006:0> scan 'test'
- ROW COLUMN+CELL
- row1 column=data:1, timestamp=1473585137461, value=values1
- row2 column=data:2, timestamp=1473585158072, value=values2
- 2 row(s) in 0.0200 seconds
- hbase(main):008:0> drop 'test'
- ERROR: Table test is enabled. Disable it first.
- hbase(main):009:0> disable 'test'
- 0 row(s) in 1.1800 seconds
- hbase(main):010:0> drop 'test'
- 0 row(s) in 0.1570 seconds


hbase(main):007:0> quit()