简体   繁体   English

docker-compose网络/端口处理

[英]docker-compose network / ports handling

I have two components: hbas&ookeeper as single container and hbase-printer (my java code) in my host. 我有两个组成部分: 作为主机的hbas&ookeeper和主机中的hbase-printer(我的Java代码)。 My goal is to print the content of some hbase table. 我的目标是打印一些hbase表的内容。 The problem is that the connection to 2181 (zookeeper port) succeed but than it looks like I'm getting directed to side randomly port to communicate and this port is not exposed. 问题是到2181(动物园管理员端口)的连接成功,但是比起我被定向到侧面随机端口进行通信并且此端口未暴露。 I'm using docker-compose.yml : 我正在使用docker-compose.yml

version: '2'
services:
  hbase:
    image: dy1-dockerv2-local.jfrog.io/hbase:latest
    restart: always
    hostname: hbase-docker
    ports:
      - "60010:60010"
      - "60000:60000"
      - "60020:60020"
      - "60030:60030"
      - "9095:9095"
      - "8085:8085"
      - "8080:8080"
      - "2181:2181"
      - "9091:9091"
      - "9090:9090"
    expose:
      - "9091"
      - "2181"
    volumes:
      - ./data/hbase:/data
      - ./logs/hbase/:/opt/hbase/logs
    network_mode: "bridge"

In my java logs I'm getting: 在我的Java日志中,我得到:

23-02-2017 09:29:54,413 INFO [ClientCnxn]: [main-SendThread(localhost:2181)] Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x15a69d8a7a30006, negotiated timeout = 40000
23-02-2017 09:30:16,955 INFO [HBaseRPC]: [main] Problem connecting to server: hbase-docker/172.17.0.2:39521

In my host I can see the listening ports: 在主机中,我可以看到侦听端口:

$ netstat -na | grep LISTEN
tcp6       0      0  ::1.2181               *.*                    LISTEN
tcp4       0      0  *.2181                 *.*                    LISTEN
tcp6       0      0  ::1.8080               *.*                    LISTEN
tcp4       0      0  *.8080                 *.*                    LISTEN
tcp6       0      0  ::1.8085               *.*                    LISTEN
tcp4       0      0  *.8085                 *.*                    

(and the rest of the ports I've defined in my docker-compose.yml file (以及我在docker-compose.yml文件中定义的其余端口

And in the container I see: 在容器中,我看到:

root@hbase-docker:/# netstat -na | grep LISTEN
tcp6       0      0 172.17.0.2:39521        :::*                    LISTEN
tcp6       0      0 :::2181                 :::*                    LISTEN
tcp6       0      0 :::60010                :::*                    LISTEN
tcp6       0      0 172.17.0.2:32785        :::*                    LISTEN
tcp6       0      0 :::43189                :::*                    LISTEN

I see that the side port 39521 is available inside the container but not exposed to the host. 我看到侧面端口39521在容器内部可用,但没有暴露给主机。 I cannot add it to my docker-compose.yml because it changed randomly (looks like something between 30000-50000). 我无法将其添加到我docker-compose.yml因为它是随机更改的(看起来像介于30000-50000之间)。 How can I expose the random port to my host? 如何将随机端口暴露给主机?

You are most like facing https://issues.apache.org/jira/browse/HBASE-10289 , which was fixed in 0.99.0 and 0.98.4. 您最喜欢面对https://issues.apache.org/jira/browse/HBASE-10289 (已在0.99.0和0.98.4中修复)。 As of the comments on the answer, you are still on an old version of hbase, probably < 0.99.0. 作为对答案的评论,您仍在使用旧版本的hbase,可能<0.99.0。

You should try to use a newer version of hbase. 您应该尝试使用更新版本的hbase。 You'll find one on the Docker Hub for example: https://hub.docker.com/r/dajobe/hbase/ 例如,您将在Docker Hub上找到一个: https : //hub.docker.com/r/dajobe/hbase/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM