zoukankan      html  css  js  c++  java
  • HBase0.90.4集群安装配置Distributed模式

    基于分布式模式安装HBase,首先它是在安装在HDFS集群之上,所以,首先要做的就是能够正确配置分布式模式的HDFS集群:保证Nanemode和Datanode进程都正确启动。HBase是一个分布式NoSQL数据库,建立于HDFS之上,并且对于集群模式的HBase需要对各个结点之间的数据进行协调(Coordination),所以HBase直接将ZooKeeper作为一个分布式协调系统来实现HBase数据复制(Replication)存储。有关ZooKeeper的介绍可以参考官方文档:http://zookeeper.apache.org。

    HBase的基于主从架构模式:HBase集群中存在一个Hbase Master Server,类似于HDFS中的Namenode的角色;而作为从结点的Region Server,类似于HDFS中的Datanode。

    对于HBase分布式模式的安装,又基于Zookeeper的是否被HBase管理,分为两种模式:

    基于HBase管理的Zookeeper集群,启动和关闭HBase集群,同时也控制Zookeeper集群
    外部Zookeeper集群:一个完全独立于HBase的ZooKeeper集群,不受HBase管理控制(启动与停止ZooKeeper集群)

    下面,我们基于一个单独安装的ZooKeeper集群,不基于HBase管理,进行安装。根据官网文档,很容易就能安装配置好,并尝试使用。
    1、安装配置HDFS集群
    启动HDFS集群实例,一台master作为Namenode结点,其余3台slaves作为Datanode结点。
    其中,master服务端口为9000。
    2、创建HBase存储目录
    #创建目录hdfs://master:9000/hbase
    Hadoop fs -mkdir /hbase
    #验证/hbase目录创建成功
    Hadoop fs -lsr /
    3、配置HBase
    (1)解压缩HBase软件包,修改系统环境变量,在~/.bashrc中最后面加入如下配置:
    export JAVA_HOME=/home/Hadoop/installation/jdk1.6.0_30
    export Hadoop_HOME=/home/hadoop/installation/hadoop-0.22.0
    export HBASE_HEAPSIZE=128
    export HBASE_MANAGES_ZK=false
    使配置生效:

    . ~/.bashrc
    (2)修改hbase-0.90.4/conf/hbase-env.sh脚本内容:
    首先要重命名hbase-0.90.4目录下的一个目录:
    Hadoop@master:~/installation/hbase-0.90.4$ mv hbase-webapps/ webapps
    默认会查找webapps目录。然后修改脚本,内容如下:
    export JAVA_HOME=/home/Hadoop/installation/jdk1.6.0_30
    export Hadoop_HOME=/home/hadoop/installation/hadoop-0.22.0
    export HBASE_HEAPSIZE=128
    export HBASE_MANAGES_ZK=false
    export HBASE_CLASSPATH=$HBASE_HOME/
    最后一个表示使用外部Zookeeper集群,而不让HBase集群去管理。
    (3)修改conf/hbase-site.xml文件内容,如下所示:

    hbase.rootdir
    hdfs://master:9000/hbase

    hbase.cluster.distributed
    true

    hbase.zookeeper.property.dataDir
    /home/Hadoop/storage/zookeeper

    hbase.zookeeper.quorum
    slave-01,slave-02,slave-03


    上面配置中:
    hbase.rootdir 指定了HBase存储的根目录是在HDFS的hdfs://master:9000/hbase目录下,该目录要被HBase集群中Region Server共享。不要忘记了,在启动HBase集群之前,在HDFS集群中创建/hbase目录,在master上执行命令Hadoop fs -mkdir /hbase即可。
    hbase.cluster.distributed 指定了我们使用完全分布的模式进行安装
    hbase.zookeeper.property.dataDir 指定了HBase集群使用的ZooKeeper集群的存储目录
    hbase.zookeeper.quorum指定了用于协调HBase集群的ZooKeeper集群结点,必须配置奇数个结点,否则HBase集群启动会失败
    所以,在启动HBase集群之前,首先要保证ZooKeeper集群已经成功启动。
    (4)接下来,检查HBase的lib中的Hadoop的版本是否之前我们启动的HDFS集群使用的版本一致:
    rm ~/installation/hbase-0.90.4/lib/hadoop-core-0.20-append-r1056497.jar
    cp ~/installation/Hadoop-0.22.0/*.jar ~/installation/hbase-0.90.4/lib/
    我直接将HBase解压缩包中的Hadoop的jar文件删除,用当前使用版本的Hadoop的jar文件。这一步很重要,如果不细看官方文档,你可能会感觉很怪异,实际HBase软件包中lib下的Hadoop的版本默认是0.20的,如果你启动的HDFS使用的是0.22,则HBase启动会报版本不一致的错误。
    (5)修改conf/regionservers文件,配置HBase集群中的从结点Region Server,如下所示:
    slave-01
    slave-02
    slave-03
    一行一个主机字符串,上面使用是从结点主机的域名。上面配置,与HDFS的从结点的配置非常类似。
    (6)经过上面几个骤,基本已经在一台机器上(master)配置好HBase了,这时,需要将上述的全部环境变量配置,也在各个从结点上进行配置,然后将配置好的HBase安装文件拷贝分发到各个从结点上:
    scp -r ~/installation/hbase-0.90.4 Hadoop@slave-01:/home/hadoop/installation
    scp -r ~/installation/hbase-0.90.4 Hadoop@slave-02:/home/hadoop/installation

    4、配置Zookeeper集群
    具体安装、配置和启动,详见文章 http://www.linuxidc.com/Linux/2012-05/59751.htm 的说明。
    在开始启动HBase集群之前,要先启动Zookeeper集群,保证其运行正常。
    5、启动HBase集群

    启动HBase集群了,执行如下脚本:
    start-hbase.sh
    你可以使用jps查看一下,当前master上启动的全部进程,如下所示:
    Hadoop@master:~/installation/hbase-0.90.4$ jps
    15899 SecondaryNameNode
    15553 NameNode
    21677 Jps
    21537 HMaster
    其中,HMaster进程就是HBase集群的主结点服务进程。
    slaves结点上启动的进程,以slave-03为例:
    Hadoop@slave-03:~/installation/hbase-0.90.4$ jps
    6919 HRegionServer
    4212 QuorumPeerMain
    7053 Jps
    3483 DataNode
    上面,HReginServer是HBase集群的从结点服务进程,QuorumPeerMain是ZooKeeper集群的结点服务进程。
    或者,查看日志,是否出现启动异常:
    master上 : tail -500f $HBASE_HOME/logs/hbase-Hadoop-master-master.log
    slave-01上: tail -500f $HBASE_HOME/logs/hbase-Hadoop-zookeeper-slave-01.log
    slave-02上: tail -500f $HBASE_HOME/logs/hbase-Hadoop-zookeeper-slave-02.log
    slave-03上: tail -500f $HBASE_HOME/logs/hbase-Hadoop-zookeeper-slave-03.log
    6、验证HBase安装
    启动HBase shell,如果能够显示如下信息则说明HBase集群启动成功:
    Hadoop@master:~/installation/hbase-0.90.4$ hbase shell
    12/01/09 01:14:09 WARN conf.Configuration: Hadoop.native.lib is deprecated. Instead, use io.native.lib.available
    12/01/09 01:14:09 WARN conf.Configuration: Hadoop.native.lib is deprecated. Instead, use io.native.lib.available
    12/01/09 01:14:09 WARN conf.Configuration: Hadoop.native.lib is deprecated. Instead, use io.native.lib.available
    HBase Shell; enter 'help ' for list of supported commands.
    Type "exit " to leave the HBase Shell
    Version 0.90.4, r1150278, Sun Jul 24 15:53:29 PDT 2011

    hbase(main):001:0> help
    HBase Shell, version 0.90.4, r1150278, Sun Jul 24 15:53:29 PDT 2011
    Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
    Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.

    COMMAND GROUPS:
    Group name: general
    Commands: status, version

    Group name: ddl
    Commands: alter, create, describe, disable, drop, enable, exists, is_disabled, is_enabled, list

    Group name: dml
    Commands: count, delete, deleteall, get, get_counter, incr, put, scan, truncate

    Group name: tools
    Commands: assign, balance_switch, balancer, close_region, compact, flush, major_compact, move, split, unassign, zk_dump

    Group name: replication
    Commands: add_peer, disable_peer, enable_peer, remove_peer, start_replication, stop_replication

    SHELL USAGE:
    Quote all names in HBase Shell such as table and column names. Commas delimit
    command parameters. Type after entering a command to run it.
    Dictionaries of configuration used in the creation and alteration of tables are
    Ruby Hashes. They look like this:

    {'key1' => 'value1', 'key2' => 'value2', ...}

    and are opened and closed with curley-braces. Key/values are delimited by the
    '=>' character combination. Usually keys are predefined constants such as
    NAME, VERSIONS, COMPRESSION, etc. Constants do not need to be quoted. Type
    'Object.constants' to see a (messy) list of all constants in the environment.

    If you are using binary keys or values and need to enter them in the shell, use
    double-quote'd hexadecimal representation. For example:

    hbase> get 't1', "key\x03\x3f\xcd"
    hbase> get 't1', "key\003\023\011"
    hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"

    The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
    For more on the HBase Shell, see http://hbase.apache.org/docs/current/book.html
    hbase(main):002:0> status
    3 servers, 0 dead, 0.0000 average load

    hbase(main):003:0> version
    0.90.4, r1150278, Sun Jul 24 15:53:29 PDT 2011

    hbase(main):004:0>
    你可以按照前面使用本地文件系统安装过程中,使用的命令来进行相关的操作。

  • 相关阅读:
    东南大学2021年高等代数
    北京师范大学2021年数学分析
    华东师范大学2021年数学分析考研试题参考解答修正版
    中国科学院大学2021年数学分析考研试题参考解答
    [数学考研竞赛00052]浙江大学2021年数学分析考研试题参考解答
    python3.6, cv2.imread()导入图片失败,none
    python商品分类信息
    mongodb 聚合(Map-Reduce)
    mongodb 聚合(aggregate)
    Java-Security(七):Spring Security方法注解认证启用
  • 原文地址:https://www.cnblogs.com/powerxu/p/2496807.html
Copyright © 2011-2022 走看看