无法从本地IDE连接到docker hbase

时间:2018-07-25 15:12:15

标签: java docker hadoop docker-compose hbase

我有一台IP地址为10.101.48.150的docker机器。 使用下一个docker-compose.yml的独立hbase在哪里:

version: "3"

services:
  namenode:
    image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8
    container_name: namenode
    volumes:
      - hadoop_namenode:/hadoop/dfs/name
    networks:
      hbasenetwork:
        aliases:
            - namenode
    environment:
      - CLUSTER_NAME=test
    env_file:
      - ./hadoop.env

  datanode:
    image: bde2020/hadoop-datanode:2.0.0-hadoop2.7.4-java8
    container_name: datanode
    volumes:
      - hadoop_datanode:/hadoop/dfs/data
    networks:
      hbasenetwork:
        aliases:
            - datanode
    environment:
      SERVICE_PRECONDITION: "namenode:50070"
    env_file:
      - ./hadoop.env

  resourcemanager:
    image: bde2020/hadoop-resourcemanager:2.0.0-hadoop2.7.4-java8
    container_name: resourcemanager
    networks:
      hbasenetwork:
        aliases:
            - resourcemanager
    environment:
      SERVICE_PRECONDITION: "namenode:50070 datanode:50075"
    env_file:
      - ./hadoop.env

  nodemanager1:
    image: bde2020/hadoop-nodemanager:latest
    container_name: nodemanager
    networks:
      hbasenetwork:
        aliases:
            - nodemanager1
    environment:
      SERVICE_PRECONDITION: "namenode:50070 datanode:50075 resourcemanager:8088"
    env_file:
      - ./hadoop.env

  historyserver:
    image: bde2020/hadoop-historyserver:2.0.0-hadoop2.7.4-java8
    container_name: historyserver
    volumes:
      - hadoop_historyserver:/hadoop/yarn/timeline.
    networks:
      hbasenetwork:
        aliases:
            - historyserver
    environment:
      SERVICE_PRECONDITION: "namenode:50070 datanode:50075 resourcemanager:8088"
    env_file:
      - ./hadoop.env

  hbase:
    image: bde2020/hbase-standalone:latest
    container_name: hbase
    volumes:
      - hbase_data:/hbase-data
      - hbase_zookeeper_data:/zookeeper-data
    ports:
      - 16000:16000
      - 16010:16010
      - 16020:16020
      - 16030:16030
      - 2888:2888
      - 3888:3888
      - 2182:2181
    hostname: hbase
    networks:
      hbasenetwork:
        aliases:
            - hbase
    environment:
      SERVICE_PRECONDITION: "namenode:50070 datanode:50075"
    env_file:
      - ./hbase-standalone.env

volumes:
  hadoop_namenode:
  hadoop_datanode:
  hadoop_historyserver:
  hbase_data:
  hbase_zookeeper_data:
networks:
  hbasenetwork:
    driver: bridge

我的Java代码:

HBaseAdmin.checkHBaseAvailable(config);

我的配置是:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>10.101.48.150</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2182</value>
    </property>
</configuration>

当我尝试通过Java使用它时,会看到下一条消息:

running.java.net.UnknownHostException: hbase

我了解我的Java使用10.101.48.150:2082从docker hbase容器中请求什么,响应smt并以“ hbase”的方式获取地址,我的本地网络对任何“ hbase”和故障一无所知。我尝试将10.101.48.150 hbase行添加到主机文件,但随后看到下一个错误:

java.net.ConnectException: Connection refused: no further information

我不明白如何将本地IDE与Hbase容器连接。

1 个答案:

答案 0 :(得分:0)

在docker的hbase服务上,您确实映射了这些端口:

ports:
  - 16000:16000
  - 16010:16010
  - 16020:16020
  - 16030:16030
  - 2888:2888
  - 3888:3888
  - 2182:2181

端口2082没有端口映射,因此您的应用程序无法成功连接到它。