美文网首页
HBase高可用

HBase高可用

作者: davisgao | 来源:发表于2019-08-28 15:57 被阅读0次

    1.环境准备和部署规划

    • 硬件和规划
    序号 主机 内存 系统 组件规划 进程
    10.110.172.154 16 Centos6.5 jdk-8u221、hbase2.2.0、zookeeper3.4.14 zookeeper、HMaster、RegionServer
    10.110.172.155 16 Centos6.5 jdk-8u221、hbase2.2.0、、zookeeper3.4.14 zookeeper、HMaster、RegionServer
    10.110.172.156 8 Centos6.5 jdk-8u221、hbase2.2.0、zookeeper3.4.14 zookeeper、RegionServer
    • 软件准备
    [root@hnxxzxfzjz004 soft]# ll
    total 1084100
    -rw-r--r--. 1 root root 232077218 Aug 28 11:27 hbase-2.2.0-bin.tar.gz
    -rw-r--r--. 1 root root 195094741 Jul 15  2009 jdk-8u221-linux-x64.tar.gz
    -rw-r--r--. 1 root root  37676320 Jul 15  2009 zookeeper-3.4.14.tar.gz
    
    • 目录规划
    [root@hnxxzxfzjz001 /]# tree /data
    /data
    ├── cloud  #组件安装目录
    │   ├── hbase
    │   ├── jdk
    │   └── zookeeper
    ├── soft #软件包存放位置
    └── work #组件工作目录
        ├── hbase
        └── zookeeper
    
    [root@hnxxzxfzjz004 cloud]# pwd
    /data/cloud
    [root@hnxxzxfzjz004 cloud]# cp /data/soft/hbase-2.2.0-bin.tar.gz .
    [root@hnxxzxfzjz004 cloud]# tar -zxvf hbase-2.2.0-bin.tar.gz 
    [root@hnxxzxfzjz004 cloud]# rm -rf hbase-2.2.0-bin.tar.gz 
    [root@hnxxzxfzjz004 cloud]# mv hbase-2.2.0/ hbase
    # 环境变量配置 /etc/profile
    # export HIVE_HOME=/data/cloud/hive
    # export PATH=$PATH:$HIVE_HOME/bin
    #创建日志目录
    [root@hnxxzxfzjz004 cloud]# mkdir -p /data/work/hbase/logs
    
    • 配置文件调整
      /data/cloud/hbase/conf/hbase-env.sh
    export JAVA_HOME=/data/cloud/jdk
    #不使用自身的Zookeeper
    export HBASE_MANAGES_ZK=false
    export HBASE_LOG_DIR=/data/work/hbase/logs
    

    /data/cloud/hbase/conf/hbase-site.xml

    <?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://hnxxzxfzjz005:8020/hbase</value>
    </property>
    <property>
      <name>hbase.cluster.distributed</name>
      <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>hnxxzxfzjz004:2181,hnxxzxfzjz005:2181,hnxxzxfzjz006:2181</value>
    </property>
    <property>
        <name>hbase.master.info.port</name>
        <value>60010</value>
    </property>
    <property>
      <name>hbase.tmp.dir</name>
      <value>/data/work/hbase/tmp</value>
    </property>
    <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
    </property>
    </configuration>
    

    /data/cloud/hbase/conf/backup-masters

    hnxxzxfzjz005
    
    • Hbase启动
      此处逐个启动,也可以start-hbase.sh
    #10.110.172.154,
    [root@hnxxzxfzjz004 bin]#  hbase-daemon.sh start master
    [root@hnxxzxfzjz004 bin]# hbase-daemon.sh start regionserver
    #进程查看
    [root@hnxxzxfzjz004 bin]# jps
    1153 Jps
    28913 QuorumPeerMain
    386 HMaster
    9923 JournalNode
    10072 NameNode
    15129 ResourceManager
    729 HRegionServer
    10619 DFSZKFailoverController
    #10.110.172.155,
    [root@hnxxzxfzjz005 bin]# hbase-daemon.sh start regionserver
    #10.110.172.156,
    [root@hnxxzxfzjz006 bin]# hbase-daemon.sh start regionserver
    
    • 访问测试
      Hbase集群状况

      image.png
      在HDFS创建的工作目录
      image.png
    • hbase shell测试

    [root@hnxxzxfzjz004 bin]# hbase shell
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/data/cloud/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/data/cloud/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
    2019-08-28 15:41:01,299 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    HBase Shell
    Use "help" to get list of supported commands.
    Use "exit" to quit this interactive shell.
    For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
    Version 2.2.0, rUnknown, Tue Jun 11 04:30:30 UTC 2019
    Took 0.0071 seconds                                                                                                                                         
    hbase(main):001:0> list
    TABLE                                                                                                                                                       
    0 row(s)
    Took 0.6785 seconds                                                                                                                                         
    => []
    hbase(main):002:0> create 'person','name','age'
    Created table person
    Took 2.4514 seconds                                                                                                                                         
    => Hbase::Table - person
    hbase(main):003:0> list 
    TABLE                                                                                                                                                       
    person                                                                                                                                                      
    1 row(s)
    Took 0.0242 seconds                                                                                                                                         
    => ["person"]
    hbase(main):004:0> describe person
    NameError: undefined local variable or method `person' for main:Object
    Did you mean?  version
    
    hbase(main):005:0> describe 'person'
    Table person is ENABLED                                                                                                                                     
    person                                                                                                                                                      
    COLUMN FAMILIES DESCRIPTION                                                                                                                                 
    {NAME => 'age', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'f
    alse', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false'
    , IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '655
    36'}                                                                                                                                                        
    
    {NAME => 'name', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => '
    false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false
    ', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65
    536'}                                                                                                                                                       
    
    2 row(s)
    
    QUOTAS                                                                                                                                                      
    0 row(s)
    Took 0.3943 seconds                                                                                                                                         
    hbase(main):006:0> list_namespace
    NAMESPACE                                                                                                                                                   
    default                                                                                                                                                     
    hbase                                                                                                                                                       
    2 row(s)
    Took 0.3273 seconds                                                                                                                                         
    hbase(main):009:0>
    

    person表建在default命名空间,在HDFS上的位置如下

    person

    相关文章

      网友评论

          本文标题:HBase高可用

          本文链接:https://www.haomeiwen.com/subject/bmrpectx.html