zoukankan      html  css  js  c++  java
  • 27-hadoop-hbase安装

    hbase的安装分为单机模式和完全分布式

    单机模式

    单机模式的安装很简单, 需要注意hbase自己内置一个zookeeper, 如果使用单机模式, 那么该机器的zookeepr不可以启动

    1, 添加java的环境变量  vim {HBASE_HOME}/conf/hbase-env.sh

    export JAVA_HOME=/usr/opt/jdk1.7.0_79

    2, 修改配置文件  {HBASE_HOME}/conf/hbase-site.xml

    <property>
    <name>hbase.rootdir</name>
    <value>file:////data/hbase</value>
    </property>
    <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/opt/data/zkData</value>
    </property>

    3, 启动

    ./bin/start-hbase.sh

    4, 链接

    ./bin/hbase shell

    5, 查看命令

    help

    6, 查看表

    list

    ok, 单机模式搭建完成

    集群模式

    前提: zookeeper集群正常启动, hadoop集群正常启动

    1, ./conf/hbase-site.xml

    <configuration>
      <!-- 指定hdfs的存放目录--> <property> <name>hbase.rootdir</name> <value>hdfs://hdfscluster/hbase</value> </property>
    <!--开启集群模式--> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property>
    <!-- 指定zookeeper--> <property> <name>hbase.zookeeper.quorum</name> <value>192.168.208.106,192.168.208.107,192.168.208.108</value> </property> </configuration>

    其中, root.dir是在{HADOOP_HOME}/etc/hadoop/core-site.xml 中

    2, ./conf/regionserver中, 配置2台从, 即regionserver

    192.168.208.106
    192.168.208.107
    192.168.208.108

    可选配置: 在 backup-mater中配置高可用 ( 我没配置)

    192.168.208.107
    192.168.208.108

    3, hdoop.conf.dir 配置在 hbase-env.sh中 的hbase_classpath下

    有3种配置方式, 我们选第一种

    1. Add a pointer to your HADOOP_CONF_DIR to the HBASE_CLASSPATH environment variable in hbase-env.sh.

    2. Add a copy of hdfs-site.xml (or hadoop-site.xml) or, better, symlinks, under ${HBASE_HOME}/conf, or

    3. if only a small set of HDFS client configurations, add them to hbase-site.xml.

     最终 hbae-env.sh的需要配置: 

    export JAVA_HOME=/usr/opt/jdk1.7.0_79
    export HBASE_CLASSPATH=/usr/opt/hadoop-2.5.1/etc/hadoop/
    export HBASE_MANAGES_ZK=false    # 设置内置zookeeper不可用

    4, 分发到从机

    scp -r hbase-1.1.3/ root@192.168.208.107:/opt
    scp -r hbase-1.1.3/ root@192.168.208.108:/opt

    5, 需要的话配置环境变量

    6, 启动: 

    ./bin/start-hbase.sh

    7, 链接

    hbase shell

    或者访问: 192.168.208.106:16010

     

    8, 杀掉hbase

    使用命令 stop-hbase.sh, 然后等待杀死即可, 如果杀不死, 需要到zookeeper下删除 hbase节点下的元素据信息, 如果仍然杀不死, 需要删除数据信息

    集群模式需要开放的端口, 粘贴一段官网文档的原话: ( http://hbase.apache.org/book.html#_introduction

    Each HMaster uses three ports (16010, 16020, and 16030 by default). The port offset is added to these ports, so using an offset of 2, the backup HMaster would use ports 16012, 16022, and 16032. The following command starts 3 backup servers using ports 16012/16022/16032, 16013/16023/16033, and 16015/16025/16035. 

    Each RegionServer requires two ports, and the default ports are 16020 and 16030. 

    The following command starts four additional RegionServers, running on sequential ports starting at 16202/16302 (base ports 16200/16300 plus 2).

    几个简单的shell命令: 

    创建命名空间: 多个表壳属于一个命名空间

    create namespace 'namespce'

    创建

    create 'table','cf1','cf2', Version=2 # 保存2个版本
    create 'namespace:table' # 在命名空间下创建表

    查看表结构

    desc 'table'

    表删除

    disable 'table'
    drop 'table'

    查看表数据

    scan 'table' # 全表扫描 

    系类来自尚学堂极限班视频

  • 相关阅读:
    Asp.Net MVC中Controller与View之间传递的Model
    Asp.Net MVC中DropDownListFor的用法
    在Window的IIS中创建FTP的Site并用C#进行文件的上传下载
    在Salesforce中创建Web Service供外部系统调用
    在Salesforce中处理Xml的生成与解析
    JS 正则表达式详解
    【LeetCode】211. Add and Search Word
    【LeetCode】210. Course Schedule II
    【LeetCode】209. Minimum Size Subarray Sum
    【LeetCode】208. Implement Trie (Prefix Tree)
  • 原文地址:https://www.cnblogs.com/wenbronk/p/7397860.html
Copyright © 2011-2022 走看看