zoukankan      html  css  js  c++  java
  • HBase-0.98.0和Phoenix-4.0.0分布式安装指南

    目录

    目录 1

    1. 前言 1

    2. 约定 2

    3. 相关端口 2

    4. 下载HBase 2

    5. 安装步骤 2

    5.1. 修改conf/regionservers 2

    5.2. 修改conf/hbase-site.xml 3

    5.2.1. hbase.master.info.port 4

    5.2.2. hbase.master.info.bindAddress 4

    5.3. 修改conf/hbase-env.sh 4

    6. 启动运行 5

    7. 基本的HBase命令 5

    8. 备HMaster配置 6

    9. 常见错误 6

    10. 相关文档 9

    附:phoenix的安装 9

    1. 前言

    本文将HBase-0.98.0安装在Hadoop-2.4.0上,关于Hadoop-2.4.0的安装,请参见《Hadoop-2.4.0分布式安装手册》一文。安装环境为64SuSE-Linux 10.1版本。

    本文将在HBase官方提供的quickstart.html文件的指导下进行,在docs/getting_started目录下可找到quickstart.html,或直接浏览在线的:http://hbase.apache.org/book/quickstart.html

    安装使用外置的ZooKeeper,有关ZooKeeper的安装,请参见《ZooKeeper-3.4.6分布式安装指南》一文。

    关于分布式安装,请浏览:http://hbase.apache.org/book/standalone_dist.html#distributed,关于HBase使用外置的ZooKeeper配置,请浏览:http://hbase.apache.org/book/zookeeper.html

    所有在线的文档,均会出现在二进制安装包解压后的docs目录下。本文的安装环境为64SuSE 10.1 Linux

    2. 约定

    假设将Hadoop-2.4.0安装在/data/hadoop/current目录,而/data/hadoop/current实际是到/data/hadoop/hadoop-2.4.0的软链接。

    HBase安装目录为/data/hadoop/hbase,而/data/hadoop/hbase实际是到hbase-0.98.0-hadoop2的软链接。

    建议JDK1.7版本,在JDK1.8上可以成功安装Hadoop-2.4.0,但基于JDK1.8编译Hadoop-2.4.0则会遇到困难。

    3. 相关端口

    2888

    ZooKeeper,如果是Leader,用来监听Follower的连接

    3888

    ZooKeeper,用于Leader选举

    2181

    ZooKeeper,用来监听客户端的连接

    60010

    hbase.master.info.portHMaster的http端口

    60000

    hbase.master.portHMaster的RPC端口

    60030

    hbase.regionserver.info.portHRegionServer的http端口

    60020

    hbase.regionserver.portHRegionServer的RPC端口

    8080

    hbase.rest.portHBase REST server的端口

    4. 下载HBase

    官网:http://hbase.apache.org/,在这里即可找到下载HBase的链接。

    下载国内映像站点:http://mirror.bit.edu.cn/apache/hbase/HBase-0.98.0版本的下载网址:http://mirror.bit.edu.cn/apache/hbase/hbase-0.98.0/。选择下载hbase-0.98.0-hadoop2-bin.tar.gz

    5. 安装步骤

    5.1. 修改conf/regionservers

    regionservers类似于Hadoopslaves文件,不需要在RegionServer机器上执行些修改。

    将所有HRegionServersIP或主机名一行一行的例举在在regionservers文件中,注意必须一行一个,不能一行多个。本文配置如下:

    hadoop@VM_40_171_sles10_64:~/hbase/conf> cat regionservers

    10.12.154.77

    10.12.154.78

    10.12.154.79

    5.2. 修改conf/hbase-site.xml

    需要在所有机器上做同样的操作,可以借助scp命令,先配置好一台,然后复制过去,如:scp hbase-site.xml hadoop@10.12.154.79:/data/hadoop/hbase/conf/

    hbase-site.xml是HBase的配置文件。默认的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>

    </configuration>

    没关系,就用它。不要用docs目录下的hbase-default.xml,这个会让你看得难受。

    编辑hbase-site.xml,添加如下内容(摘自standalone_dist.html,搜索“Fully-distributed”):

    <configuration>

      <property>

        <name>hbase.rootdir</name>

        <value>hdfs://172.25.40.171:9001/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.zookeeper.quorum</name>

        <value>DEVNET-154-77,DEVNET-154-70,DEVNET-154-79</value>

        <description>Comma separated list of servers in the ZooKeeper Quorum.

          For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".

          By default this is set to localhost for local and pseudo-distributed modes

          of operation. For a fully-distributed setup, this should be set to a full

          list of ZooKeeper quorum servers. If HBASE_MANAGES_ZK is set in hbase-env.sh

          this is the list of servers which we will start/stop ZooKeeper on.

        </description>

      </property>

      <property>

        <name>hbase.master.maxclockskew</name>

        <value>600000</value>

        <description>Time(ms) difference of regionserver from master</description>

      </property>

    </configuration>

    “hbase.zookeeper.quorum”可以填写IP列表。hdfs://172.25.40.171:9001对应hdfs-site.xml中的“dfs.namenode.rpc-address”。“hbase.zookeeper.quorum”配置为ZooKeeper集群各节点主机名或IP

    更多的信息,可以浏览:http://hbase.apache.org/book/config.files.html

    5.2.1. hbase.master.info.port

    用于指定HMasterhttp端口。

    5.2.2. hbase.master.info.bindAddress

    用于指定HMasterhttpIP地址,如果不设定该值,可能使用IPv6地址。

    5.3. 修改conf/hbase-env.sh

    需要在所有机器上做同样的操作,可以借助scp命令,先配置好一台,然后复制过去,如:scp hbase-site.xml hadoop@10.12.154.79:/data/hadoop/hbase/conf/,修改内容如下:

    1) 设置JAVA_HOME

    # The java implementation to use.  Java 1.6 required.

    export JAVA_HOME=/data/jdk

    上述/data/jdkJDK的安装目录。

    2) 设置HBASE_MANAGES_ZK

    # Tell HBase whether it should manage it's own instance of Zookeeper or not.

    export HBASE_MANAGES_ZK=false

    如果HBASE_MANAGES_ZK值为true,则表示使用HBase自带的ZooKeeper,建议单独部署ZooKeeper,这样便于ZooKeeper同时为其它系统提供服务。

    3) 设置HBASE_CLASSPATH

    # Extra Java CLASSPATH elements.  Optional.

    export HBASE_CLASSPATH=/data/hadoop/current/etc/hadoop

    6. 启动运行

    进入HBASE_HOME/bin目录,执行start-hbase.sh即可启动HBase。请使用JDK提供的jps命令,分别查看HMasterHRegionServer进程是否已经起来,同时检查日志文件是否有错误。

    7. 基本的HBase命令

    通过执行“hbase shell”进入命令行操作界面。详细请浏览官方文档:quickstart.html

    hbase(main):003:0> create 'test', 'cf'  # 创建表test,一个列族cf

    0 row(s) in 1.2200 seconds

    hbase(main):003:0> list 'test'

    ..

    1 row(s) in 0.0550 seconds

    hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'  往表testcf列族的a字段插入值value1

    0 row(s) in 0.0560 seconds

    hbase(main):005:0> put 'test', 'row2', 'cf:b', 'value2'

    0 row(s) in 0.0370 seconds

    hbase(main):006:0> put 'test', 'row3', 'cf:c', 'value3'

    0 row(s) in 0.0450 seconds

    hbase(main):007:0> scan 'test'  扫描表test

    ROW        COLUMN+CELL

    row1       column=cf:a, timestamp=1288380727188, value=value1

    row2       column=cf:b, timestamp=1288380738440, value=value2

    row3       column=cf:c, timestamp=1288380747365, value=value3

    3 row(s) in 0.0590 seconds

    hbase(main):008:0> get 'test', 'row1'  从表test取一行数据

    COLUMN      CELL

    cf:a        timestamp=1288380727188, value=value1

    1 row(s) in 0.0400 seconds

    hbase(main):012:0> disable 'test'

    0 row(s) in 1.0930 seconds

    hbase(main):013:0> drop 'test'

    0 row(s) in 0.0770 seconds 

    hbase(main):014:0> exit

    8. 备HMaster配置

    HMaster可以有0到多个,配置和主HMaster完全相同,所以只需要复制一份已配置好的HMaster过去即可,然后同样的命令启动。启动好后,一样可以执行HBase shell命令。

    9. 常见错误

    本文的实践过程中遇到了如下一些错误:

    1) 错误1Host key not found from database

    遇到如下错误,说明不能免密码登录DEVNET-154-70、DEVNET-154-77和DEVNET-154-79,假设用户名为hadoop,则可以试试ssh hadoop@DEVNET-154-70来检查是否能免密码登录:

    ./start-hbase.sh          

    DEVNET-154-70: Host key not found from database.

    DEVNET-154-70: Key fingerprint:

    DEVNET-154-70: xihad-rotuf-lykeh-mapup-kylin-kybub-sohid-bucaf-gafyg-vecuc-tyxux

    DEVNET-154-70: You can get a public key's fingerprint by running

    DEVNET-154-70: % ssh-keygen -F publickey.pub

    DEVNET-154-70: on the keyfile.

    DEVNET-154-70: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument

    DEVNET-154-77: Host key not found from database.

    DEVNET-154-77: Key fingerprint:

    DEVNET-154-77: xuhog-tavip-donon-vuvac-tycyh-sysyz-zacur-didoz-fugif-vosar-ruxyx

    DEVNET-154-77: You can get a public key's fingerprint by running

    DEVNET-154-77: % ssh-keygen -F publickey.pub

    DEVNET-154-77: on the keyfile.

    DEVNET-154-77: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument

    DEVNET-154-79: Host key not found from database.

    DEVNET-154-79: Key fingerprint:

    DEVNET-154-79: xolim-mysyg-bozes-zilyz-futaf-tatig-zaryn-pilaf-betyf-meduf-tixux

    DEVNET-154-79: You can get a public key's fingerprint by running

    DEVNET-154-79: % ssh-keygen -F publickey.pub

    DEVNET-154-79: on the keyfile.

    DEVNET-154-79: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument

    2) 错误2Failed deleting my ephemeral node

    原因可能是因为之前配置错误,比如使用HBase自带的ZooKeeper启动过,后改为使用外围的ZooKeeper再启动。

    2014-04-22 16:26:17,452 WARN  [regionserver60020] zookeeper.RecoverableZooKeeper: Node /hbase/rs/DEVNET-154-79,60020,1398155173411 already deleted, retry=false

    2014-04-22 16:26:17,453 WARN  [regionserver60020] regionserver.HRegionServer: Failed deleting my ephemeral node

    org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /hbase/rs/DEVNET-154-79,60020,1398155173411

            at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)

            at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)

            at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:873)

            at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.delete(RecoverableZooKeeper.java:156)

            at org.apache.hadoop.hbase.zookeeper.ZKUtil.deleteNode(ZKUtil.java:1273)

            at org.apache.hadoop.hbase.zookeeper.ZKUtil.deleteNode(ZKUtil.java:1262)

            at org.apache.hadoop.hbase.regionserver.HRegionServer.deleteMyEphemeralNode(HRegionServer.java:1273)

            at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:1003)

            at java.lang.Thread.run(Thread.java:744)

    3) 错误3Master rejected startup because clock is out of sync

    来自RegionServer端的日志,HMaster拒绝RegionServer的连接。这个错误是因为HMaster上的时间和RegionServer上的时间相差超过30秒。两种解决办法:一是同步时间,二是修改hbase-site.xml中的hbase.master.maxclockskewHMaster端的hdfs-site.xml文件):。

    2014-04-22 16:34:36,701 FATAL [regionserver60020] regionserver.HRegionServer: Master rejected startup because clock is out of sync

    org.apache.hadoop.hbase.ClockOutOfSyncException: org.apache.hadoop.hbase.ClockOutOfSyncException: Server DEVNET-154-79,60020,1398155672511 has been rejected; Reported time is too far out of sync with master.  Time difference of 175968ms > max allowed of 30000ms

            at org.apache.hadoop.hbase.master.ServerManager.checkClockSkew(ServerManager.java:316)

            at org.apache.hadoop.hbase.master.ServerManager.regionServerStartup(ServerManager.java:216)

            at org.apache.hadoop.hbase.master.HMaster.regionServerStartup(HMaster.java:1281)

            at org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos$RegionServerStatusService$2.callBlockingMethod(RegionServerStatusProtos.java:5085)

            at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2008)

            at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:92)

            at org.apache.hadoop.hbase.ipc.FifoRpcScheduler$1.run(FifoRpcScheduler.java:73)

            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

            at java.util.concurrent.FutureTask.run(FutureTask.java:266)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at java.lang.Thread.run(Thread.java:744)

            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

            at java.lang.reflect.Constructor.newInstance(Constructor.java:408)

            at org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.java:106)

            at org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.java:95)

            at org.apache.hadoop.hbase.protobuf.ProtobufUtil.getRemoteException(ProtobufUtil.java:284)

            at org.apache.hadoop.hbase.regionserver.HRegionServer.reportForDuty(HRegionServer.java:1998)

            at org.apache.hadoop.hbase.regionserver.HRegionServer.run(HRegionServer.java:839)

            at java.lang.Thread.run(Thread.java:744)

    将hbase.master.maxclockskew改成可以容忍10分钟:

      <property>

        <name>hbase.master.maxclockskew</name>

        <value>600000</value>

        <description>Time(ms) difference of regionserver from master</description>

      </property>

    10. 相关文档

    HBase-0.98.0分布式安装指南》

    Hive 0.12.0安装指南》

    ZooKeeper-3.4.6分布式安装指南》

    Hadoop 2.3.0源码反向工程》

    《在Linux上编译Hadoop-2.4.0

    Accumulo-1.5.1安装指南》

    Drill 1.0.0安装指南》

    Shark 0.9.1安装指南》

    更多,敬请关注技术博客:http://aquester.cublog.cn

    附:phoenix的安装

    Phoenix的安装非常简单。官网有说明(http://phoenix.incubator.apache.org/download.html),二进制安装包可从http://www.apache.org/dyn/closer.cgi/incubator/phoenix/上下载,本文下载的是phoenix-4.0.0-incubating.tar.gz,注意和HBase的兼容关系:

    Phoenix版本

    HBase版本

    Phoenix 2.x

    HBase 0.94.x

    Phoenix 3.x

    HBase 0.94.x

    Phoenix 4.x

    HBase 0.98.1+

    安装步骤为:

    1) 将phoenix-4.0.0-incubating.tar.gz上传到Phoenix客户端机器,假设安装到/data/hadoop

    2) 解压phoenix-4.0.0-incubating.tar.gz解压后生成phoenix-4.0.0-incubating目录

    3) 建立软链接:ln -s phoenix-4.0.0-incubating phoenix

    4) 将/data/hadoop/phoenix/hadoop-2/phoenix-4.0.0-incubating-client.jar添加到CLASSPATH

    5) 将phoenix/common目录下的phoenix-core-4.0.0-incubating.jar复制到所有HBase region server的的CLASSPATH中,比如HBaselib目录

    6) 重启HBase集群

    运行phoenix也非常简单,命令格式为:

    sqlline.py zookeeper file.sql

    示例:

    hadoop@VM-40-171-sles10-64:~/phoenix/bin> ./sqlline.py 10.12.154.78

    Setting property: [isolation, TRANSACTION_READ_COMMITTED]

    issuing: !connect jdbc:phoenix:10.12.154.78 none none org.apache.phoenix.jdbc.PhoenixDriver

    Connecting to jdbc:phoenix:10.12.154.78

    Connected to: Phoenix (version 4.0)

    Driver: org.apache.phoenix.jdbc.PhoenixDriver (version 4.0)

    Autocommit status: true

    Transaction isolation: TRANSACTION_READ_COMMITTED

    Building list of tables and columns for tab-completion (set fastconnect to true to skip)...

    53/53 (100%) Done

    Done

    sqlline version 1.1.2

    0: jdbc:phoenix:10.12.154.78>   select * from test;

    Error: ERROR 1012 (42M03): Table undefined. tableName=TEST (state=42M03,code=1012)

    0: jdbc:phoenix:10.12.154.78> create table test ( a int, b string);

    Error: ERROR 601 (42P00): Syntax error. Unsupported sql type: INT (state=42P00,code=601)

    0: jdbc:phoenix:10.12.154.78> create table test (a integer, b integer);

    Error: ERROR 509 (42888): The table does not have a primary key. tableName=TEST (state=42888,code=509)

    0: jdbc:phoenix:10.12.154.78> create table test (a integer primary key, b integer) ;

    No rows affected (1.424 seconds)

    0: jdbc:phoenix:10.12.154.78> UPSERT INTO TEST VALUES (1, 1);

    1 row affected (0.099 seconds)

    0: jdbc:phoenix:10.12.154.78> UPSERT INTO TEST VALUES (2, 12);

    1 row affected (0.02 seconds)

    0: jdbc:phoenix:10.12.154.78> select * from test;

    +------------+------------+

    |     A      |     B      |

    +------------+------------+

    | 1          | 1          |

    | 2          | 12         |

    +------------+------------+

    2 rows selected (0.116 seconds)

    0: jdbc:phoenix:10.12.154.78> 

    有关语法请浏览:http://phoenix.incubator.apache.org/language/index.html,有关数据类型请浏览:http://phoenix.incubator.apache.org/language/datatypes.html

  • 相关阅读:
    动态ip发布web+绑定域名
    JQuery选择器大全
    mysql触发器
    jquery选择器
    PHP5新语法学习
    Jquery中$.ajax()方法参数详解(转)
    svn笔记
    lsof命令
    新环境常用工具
    不会转载
  • 原文地址:https://www.cnblogs.com/aquester/p/9891611.html
Copyright © 2011-2022 走看看