正确搭建hbase完全分布式集群(二)

hbase 环境搭建

1 下载

我在这里使用是hbase-1.3.5,直接到这里,如果该链接失效的话,就琢磨找别的地儿吧

2 安装

首先在centos上解压hbase-1.3.5/usr/local中,并将其重命名为hbase(只是觉得方便记忆书写而已)

#安装到/usr/local
tar -zxvf hbase-1.3.5.tar.gz -C /usr/local
#重命名
mv /usr/local/hbase-1.3.5 /usr/local/hbase

3 添加环境变量 HBASE_HOME

修改/etc/profile添加HBASE_HOME环境变量

export HBASE_HOME=/usr/local/hbase
export PATH=$PATH:$HBASE_HOME/bin

为使环境变量生效,执行source /etc/profile.

4 配置 HBASE

首先修改conf/hbase-env.sh,

export JAVA_HOME=/usr/local/java
# 不使用内置的Zookeeper
export HBASE_MANAGES_ZK=false

配置conf/hbase-site.xml,如下配置:

<configuration>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>centos,test,alpha</value>
        <description>The directory shared by RegionServers.
        </description>
    </property>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://centos:9000/hbase</value>
        <description>The directory shared by RegionServers.
        </description>
    </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 (see hbase-env.sh)
        </description>
    </property>
    <property>
        <name>hbase.master.info.port</name>
        <value>60010</value>
    </property>
</configuration>

我们选取centosmaster,testalpharegionServer,所以需要修改conf/regionservers文件

test
alpha

5 分发 hbase 到各主机

将配置好的hbase分发到testalpha,并且在这两个主机上添加好HBASE_HOME环境变量

# 分发
scp -r /usr/local/hbase root@test:/usr/local
scp -r /usr/local/hbase root@alpha:/usr/local
# 添加环境变量
export HBASE_HOME=/usr/local/hbase
export PATH=$PATH:$HBASE_HOME/bin

4.5 同步时间服务器

  • 下载ntpdate

    #更新源
    yum update #安装ntpdate yum install -y ntpdate
  • 同步centos/test/alpha三台主机时间

    # 同步时间服务器
    ntpdate 0.asia.pool.ntp.org

    以下可选时间服务器:

  1. time.nist.gov
  2. time.nuri.net
  3. 0.asia.pool.ntp.org
  4. 1.asia.pool.ntp.org
  5. 2.asia.pool.ntp.org
  6. 3.asia.pool.ntp.org

6 启动测试

  1. 先在hdfs上创建hbase-site.xml文件中指定的hbase.rootdir目录/hbase
  2. centos主机上启动hbase服务

    # 启动master
    start-hbase.sh
    # 关闭master
    stop-hbase.sh
    # 启动备份master,后面的数字为端口,如1表示16001
    local-master-backup.sh start 1

上述步骤是在实践后完成的,理论上没有问题的哦。

猜你喜欢

转载自www.cnblogs.com/hwang126/p/11042157.html