Hbase2.1.3分布式部署

本文介绍了HBase 2.1.3在五台虚拟机上的部署与测试过程。作者的Hadoop版本为2.7.6,jdk为1.8,部署在Cento7上。具体步骤包括下载解压、配置环境变量,修改conf下的文件,最后进行测试,并解决了部署中遇到的web访问报错问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我的Hadoop版本为2.7.6,jdk为1.8版本的,都和Hbase2.1.3兼容,部署在Cento7上,我将在五台虚拟机上测试部署 ( master1,master2, slave1,slave2,slave3 )

具体可以查看官网的给的表:http://hbase.apache.org/book.html#java, http://hbase.apache.org/book.html#hadoop

1.下载解压,配置环境变量

下面操作都在master1上操作,操作完成后再通过scp 传到其他几台虚拟机上

# 使用wget下载
wget https://www-us.apache.org/dist/hbase/2.1.3/hbase-2.1.3-bin.tar.gz

tar -zxvf hbase-2.1.3-bin.tar.gz # 解压


vim /etc/profile  # 编辑文件,添加下面内容(Hbase的路径)


export HBASE_HOME=/usr/local/hbase # hbase路径
export PATH=$PATH:$HBASE_HOME/bin

配置hbase之前,我的Hadoop和zookeeper都已经配置好了。参考下面两篇博客

https://blog.csdn.net/rongDang/article/details/88098476

https://blog.csdn.net/rongDang/article/details/87867442

在 /etc/profile 添加完hbase的路径后,要使环境变量生效,source /etc/profile

2.修改conf下的文件:hbase-env.sh,hbase-site.xml

首先将Hadoop中的两个文件: hdfs-site.xml和core-site.xml 文件复制到 hbase的conf 目录下。这样是告诉hbase,HDFS文件目录在哪,这两个文件中包含HDFS的目录信息

# 该操作在hbase的conf目录下执行
cp /usr/local/hadoop/etc/hadoop/hdfs-site.xml ./

cp /usr/local/hadoop/etc/hadoop/core-site.xml ./

修改hbase-env.sh文件

# 指定jdk的路径
export JAVA_HOME=/usr/local/jdk

# 不使用hbase自带的zookeeper
export HBASE_MANAGES_ZK=false

修改hbase-site.xml文件

        <!--设置HDFS上存放元数据的dir-->
        <property>
                <name>hbase.rootdir</name>
                <value>hdfs://master1:9000/hbase</value>
        </property>
        <!--是否开放分布式-->
        <property>
                <name>hbase.cluster.distributed</name>
                <value>true</value>
        </property>
        <!--zookeeper集群的URL配置,多个host中间用逗号-->
        <property>
                <name>hbase.zookeeper.quorum</name>
                <value>master1,master2,slave1,slave2,slave3</value>
        </property>
        <!--zookeeper配置,日志存储路径-->
        <property>
                <name>hbase.zookeeper.property.dataDir</name>
                <value>/usr/local/hbase/data</value>
        </property>
        <!--本地文件系统tmp目录,一般配置成local模式的设置一下,但是最好还是需要设置一下,因为很多文件都会默认设置成它下面的-->
        <property>
                <name>hbase.tmp.dir</name>
                <value>/usr/local/hbase/tmp</value>
        </property>
        <property>
                <name>zookeeper.znode.parent</name>
                <value>/hbase</value>
        </property>
        <!--设置通信的接口-->
        <property>
                <name>hbase.zookeeper.property.clientPort</name>
                <value>2181</value>
        </property>

我的hbase-site.xml是这样设置的,因为是第一次部署出了很多问题,所以在百度上查了很多的内容,病急乱投医,site文件就改了这么多,捣鼓着,就配置好了

修改regionservers文件

这个文件和Hadoop中的slaves文件类似,改文件中写你要做为RegionServer的主机名,或主机地址,这里我将master2,slave1,slave2,slave3作为region服务器。

master2
slave1
slave2
slave3

上面操作都完成后,将hbase文件夹传到其他四台虚拟机上,同理,其他四台虚拟机也要修改 /etc/profile 文件。

scp -r /usr/local/hbase root@master2:/usr/local/

关于环境变量有没有配置好,通过 hbase version 查看hbase版本就可以知道

3.测试hbase

首先,开启Hadoop,zookeeper

在master1上执行: start-all.sh          开启Hadoop集群

在五台虚拟机上执行:zkServer.sh    开启zookeeper

开启hbase

在master1上执行: start-hbase.sh 

通过jps来查看状态

通过web来访问查看,

关于部署碰到的问题:

web访问时报  InvalidProtocolBufferException  错误:参考https://www.cndba.cn/dave/article/3325

查看hbase下logs中的日志文件,对应内容如下:

2019-03-18 22:15:00,556 INFO  [main] master.HMaster: hbase.rootdir=hdfs://master1:9000/hbase, hbase.cluster.distributed=true
2019-03-18 22:15:00,655 INFO  [master/master1:16000:becomeActiveMaster] master.HMaster: Adding backup master ZNode /hbase/backup-masters/master1,16000,1552961693744
2019-03-18 22:15:01,003 INFO  [master/master1:16000:becomeActiveMaster] master.ActiveMasterManager: Another master is the active master, null; waiting to become the next active master

master.ActiveMasterManager: Another master is the active master, null; waiting to become the next active master
这里的null值是导致异常的主要原因。

因为Hbase的信息是存储在Zookeeper中的,之前测试的结果可能对这里产生了影响,所以连上Zookeeper,把/hbase目录删除了。

zkCli.sh   # 进入zookeeper

get /hbase  

rmr /hbase   # 递归删除hbase下的内容

删除后,再重新启动hbase的master 

hbase-daemon.sh stop master
hbase-daemon.sh start master

再次通过网页查看就成功了。

 

 

 

### HBase Pseudo-Distributed Deployment Guide For setting up a pseudo-distributed environment, where the master and region server run on a single machine but as separate processes, several configurations need to be adjusted within specific files. #### Configuration Adjustments The `hbase-site.xml` file requires modifications that specify paths for data storage directories which should not point to temporary locations like `/tmp`. This ensures stability across system reboots. Additionally, settings related to ZooKeeper must also be configured here when deploying in standalone or pseudo-distributed modes[^1]. In terms of user permissions, it&#39;s important to note that there exists an attribute named `hbase.superuser`, defined in `hbase-policy.xml`, allowing certain users elevated privileges over operations performed through HBase shell commands. These superusers can execute administrative tasks without facing restrictions applied to regular users. Regarding interaction with HBase after setup completion, one uses HBase Shell extensively. Built upon (J)Ruby’s IRB interface, this tool extends Ruby capabilities by incorporating specialized functions tailored specifically towards managing tables, inserting rows, scanning row contents among other functionalities available directly from command line interfaces[^2]. Columns management differs significantly between traditional relational databases and HBase; understanding these nuances will aid effective schema design during development phases[^3]. ```xml <!-- Example configuration snippet --> <configuration> <property> <name>hbase.rootdir</name> <value>file:///path/to/hbasedir</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/path/to/zkdata</value> </property> </configuration> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值