[英]can't access kafka outside the docker container
I installed the latest HDP into the docker container.我将最新的 HDP 安装到 docker 容器中。
docker ps
>hortonworks/sandbox-proxy:1.0
>hortonworks/sandbox-hdp:3.0.1
Kafka broker is running at 6667 port that it's working fine. Kafka 代理运行在6667端口,它工作正常。
>ssh hdfs@sandbox-hdp.hortonworks.com -p 2222
> echo "send test message" | kafka-console-producer.sh --broker-list sandbox-hdp.hortonworks.com:6667 --topic hotelReservation > /dev/null
>kafka-console-consumer.sh --bootstrap-server sandbox-hdp.hortonworks.com:6667 --topic test --from-beginning
The only problem is that I don't have access to the Kafka broker outside the docker container.唯一的问题是我无法访问 docker 容器外的 Kafka 代理。
More information for troubleshooting:有关故障排除的更多信息:
I verified that all the ports are open local machine -> proxy -> hdp我验证了所有端口都打开了本地机器 -> 代理 -> hdp
HDP Server: HDP 服务器:
hostname -I
172.18.0.2
netstat -vatn | grep 6667
tcp 0 0 172.18.0.2:6667 0.0.0.0:* LISTEN
Proxy Server代理服务器
hostname -I
172.18.0.3
nmap 172.18.0.2 -p 6667
6667/tcp open irc
netstat -vatn | grep 6667
tcp 0 0 0.0.0.0:6667 0.0.0.0:* LISTEN
My Local machine:我的本地机器:
nmap sandbox-hdp.hortonworks.com -p 6667
Host is up (0.000064s latency).
rDNS record for 127.0.0.1: localhost
PORT STATE SERVICE
6667/tcp open irc
Note: 6668 is open too.注:6668 也是开放的。
included default stream conf (/etc/nginx/conf/ stream.d / tcp-hdp.conf ):包含默认流CONF(在/ etc / nginx的/ CONF / stream.d / TCP-hdp.conf):
server {
listen 6668;
proxy_pass sandbox-hdp:6667;
}
So I decided to create new config the http: /etc/nginx/conf/ stream.d / tcp-hdp.conf所以我决定创建新配置的HTTP:在/ etc / nginx的/ conf目录/ stream.d / TCP-hdp.conf
server {
listen 6667;
server_name sandbox-hdp.hortonworks.com;
location / {
proxy_pass http://sandbox-hdp:6667;
}
}
Note: I read ( here ) that I should use advertised.listeners to access broker outside the doctor:注意:我读到( here )我应该使用advertised.listeners 来访问医生之外的broker:
>listeners=PLAINTEXT://0.0.0.0:6667
>advertised.listeners=PLAINTEXT://172.18.0.2:6667
but I 'm sure that's incorrect for my case.但我确定这对我的情况不正确。 I have access in this network, the problem is some type of Nginx mapping only .
我可以在这个网络中访问,问题只是某种类型的Nginx 映射。
Solution:解决方案:
Run the following command to find hortonworks/sandbox-proxy container id.运行以下命令以查找hortonworks/sandbox-proxy容器 ID。
docker ps
Log in to the proxy server登录代理服务器
docker exec -it CONTAINER_ID /bin/bash
add new mapping in the nginx在 nginx 中添加新映射
cd /etc/nginx/conf.stream.d
vim tcp-hdp.conf
config:配置:
server {
listen 6667;
proxy_pass sandbox-hdp:6667;
}
reload nginx mapping:重新加载 nginx 映射:
/etc/init.d/nginx reload
Test:测试:
> ./kafka-console-consumer.sh --bootstrap-server localhost:6668 --topic topicName --from-beginning
> echo "msg" | ./kafka-console-producer.sh --broker-list sandbox-hdp.hortonworks.com:6668 --topic topicName > /dev/nul
The problem was that 6667:6667 mapping was missing.问题是缺少 6667:6667 映射。 Now brokers are access both 6667 and 6668 ports.
现在代理可以访问 6667 和 6668 端口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.