Hbase分布式安装

前提

hbase 安装的先决条件是先安装好hadoop,zookeeper,因为我们使用独立的zookeeper集群。

Hadoop安装参考:"hadoop1.1.2分布式环境搭建"  点击打开链接

Zookeeper安装参考:"zookeeper分布式安装点击打开链接

 

准备工作

服务器信息:

   

上传hbase包

将hbase上传到icity0服务器的/home/hadoop/目录中,解压并且重命名为hbase。如图操作所示:

 

配置hbase对jdk,hadoop的依赖

进入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文件

编辑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文件

 

编辑regionservers文件,增加如下内容,见图:

 

复制habase整个目录

复制habase整个目录到icity2,icity3服务器。

 

 

 

配置环境变量

修改hadoop用户的.bash_profile文件。增加如下部分,如图所示:

vi .bash_profile

 

是环境变量生效:

source .bash_profile

 

将上面的配置文件scp到icity1 icity2服务器上,然后source .bash_profile

 

启动habase

经过上面配置完后,可以通过bin/start-hbase.sh命令启动hbase集群。注意启动hbase前,先要启动hadoop和zookeeper集群。

启动hbase

bin/start-hbase.sh

 

启动报错:

 

由于之前在编辑regionservers文件是未将localhost删除,而是#localhost了。故先停止hbase后,将所有服务器上的regionservers 文件中的#localhost删除掉,重新启动hbase。

 

启动成功日志及进程:

mastericity0

Icity1 jps查看:

 

启动成功后,可以通过http://localhost:60010查看hbase的管理页面,如图所示:

 

关闭hbase

bin/stop-hbase.sh

 

hbase shell

 

通过hbase shell 进入shell操作界面:

 

更多详细操作参考官方文档。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HBase 是一个基于 Hadoop 的分布式数据库,可以用于存储和处理大规模数据。下面是 HBase 分布式安装和配置的步骤: ## 环境准备 在开始安装之前,需要确保以下环境已经准备好: - Hadoop 集群已经安装和配置好 - ZooKeeper 集群已经安装和配置好 - Java 环境已经安装和配置好 ## 下载和安装 HBase 1. 下载 HBase 安装包: ```shell wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.4.5/hbase-2.4.5-bin.tar.gz ``` 2. 解压安装包: ```shell tar -zxvf hbase-2.4.5-bin.tar.gz ``` 3. 将解压后的文件夹移动到 Hadoop 安装目录下: ```shell mv hbase-2.4.5 /usr/local/hadoop/ ``` ## 配置 HBase 1. 打开 HBase 配置文件: ```shell cd /usr/local/hadoop/hbase-2.4.5/conf cp hbase-site.xml hbase-site.xml.bak vi hbase-site.xml ``` 2. 在 hbase-site.xml 文件中添加以下配置: ```xml <configuration> <property> <name>hbase.rootdir</name> <value>hdfs://namenode:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>zk1:2181,zk2:2181,zk3:2181</value> </property> </configuration> ``` 其中,hbase.rootdir 指定 HBase 在 HDFS 上的根目录;hbase.cluster.distributed 表示 HBase 集群是分布式的;hbase.zookeeper.quorum 指定 ZooKeeper 集群的地址。 3. 打开 HBase 环境变量文件: ```shell vi /etc/profile.d/hbase.sh ``` 4. 在 hbase.sh 文件中添加以下配置: ```shell export HBASE_HOME=/usr/local/hadoop/hbase-2.4.5 export PATH=$PATH:$HBASE_HOME/bin ``` 5. 使环境变量生效: ```shell source /etc/profile.d/hbase.sh ``` ## 启动 HBase 1. 启动 HBase: ```shell start-hbase.sh ``` 2. 验证 HBase 是否启动成功: ```shell jps ``` 如果成功启动,将看到类似以下输出: ``` 23320 HMaster 23545 HRegionServer 23399 HQuorumPeer ``` ## 测试 HBase 1. 进入 HBase shell: ```shell hbase shell ``` 2. 创建一个表: ```shell create 'test', 'cf' ``` 3. 插入一条数据: ```shell put 'test', 'row1', 'cf:a', 'value1' ``` 4. 查询数据: ```shell get 'test', 'row1' ``` 如果成功插入并查询数据,将看到类似以下输出: ``` COLUMN CELL cf:a value1 ``` 至此,HBase 分布式安装和配置完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值