zoukankan      html  css  js  c++  java
  • docker化hbase并使用外部zookeeper

    近日公司需要单节点hbase,并不使用内置zookeeper,我们的zookeeper是单节点的docker化,hbase也要做单节点的docker化,于是以下为自写的Dockerfile

    hbase安装包下载:https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/2.2.2/

    一、hbase的Dockerfile

    FROM ubuntu 
    ADD ["jdk.tar.gz","/usr/local/"]
    ADD ["hbase.tar.gz","/opt/"]
    COPY ["entrypoint.sh","/"]
    ENV JAVA_HOME /usr/local/jdk
    ENV PATH ${PATH}:${JAVA_HOME}/bin
    RUN echo "Asia/Shanghai" > /etc/timezone
    EXPOSE 16000 16010 16020 16030 
    VOLUME /opt/hbase/data
    ENTRYPOINT /entrypoint.sh
    View Code

    二、hbase的entrypoint.sh

    #!/bin/bash
    Host_Name=`hostname`
    Conf_Dir=/opt/hbase/conf
    if [ -n ${ZK_Server} ]; then
      sed -i "/zookeeper.quorum/{n;s/.*/  <value>${ZK_Server}</value>/g}" ${Conf_Dir}/hbase-site.xml
    fi
    if [-n ${ZK_Port}]; then
      sed -i "/zookeeper.property.clientPort/{n;s/.*/  <value>${ZK_Port}</value>/g}" ${Confi_Dir}/hbase-site.xml
    fi
    
    bash /opt/hbase/bin/start-hbase.sh
    tail -F /opt/hbase/logs/hbase--master-${Host_Name}.log
    View Code

    三、hbase的docker-compose文件

    version: "3"
    services:
      hbase:
        image: registry.cn-beijing.aliyuncs.com/wavewisdom-bj-registry-common/hbase:2.2.2
        container_name: hbase
        environment:
          - "ZK_Server=193.168.1.136"
          - "ZK_Port=2181"
        ports:
          - "16000:16000"
          - "16010:16010"
          - "16020:16020"
          - "16030:16030"
        volumes:
          - "/home/volumes/hbase/data:/opt/hbase/data"
          - "/etc/localtime:/etc/localtime:ro"
        restart: always
    View Code

    四、说明:观察启动日志会发现程序依然会自动binding2181端口,但是hbase和region已经注册到了自建的zookeeper中,测试正常。

    五、dockerfile等文件可通过百度网盘下载:

    链接:https://pan.baidu.com/s/1Vdxuo6diF8Js7WOcLcGBkg
    提取码:22hl

    hbase优化:https://www.jianshu.com/p/06648fb74c26

  • 相关阅读:
    例6-5
    例6-3
    例6-2
    例6-1
    例5-9
    python3
    python3
    python3
    python3
    python3
  • 原文地址:https://www.cnblogs.com/caibao666/p/12056219.html
Copyright © 2011-2022 走看看