从主机操作系统访问沙箱中的 kafka(尝试所有解决方案后) [英] Accessing kafka in sandbox from Host OS (after trying every solution)

查看:22
本文介绍了从主机操作系统访问沙箱中的 kafka(尝试所有解决方案后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

认为我是个菜鸟.我已经阅读了有关堆栈溢出的所有问题并尝试了一天,但解决方案只是不点击我.请专门帮助我解决我的设置和代码(因为我已经尝试了堆栈溢出相同问题的所有可能性 - )

Cnsider me a noob. I have read all the issues on stack overflow and tried for one day but the solution just do not click to me. PLEASE Help me specifically to my SETTINGS and CODE(because I have tried all possibilities from same issues on stack overflow - )

这是我的 Producer.properties 文件

这是我的 server.properties 文件

这是我的代码

Properties props = new Properties();
props.put("metadata.broker.list", "sandbox.hortonworks.com:9093");
//props.put("zk.connect", "sandbox.hortonworks.com:2181");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("request.required.acks", "1");

KeyedMessage<String, String> data = new KeyedMessage<String, String> (topic1,"ccccccccc");


System.out.println(data);
producer.send(data);

这是日食输出

KeyedMessage(tweeter,null,ccccccccc)
kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.

推荐答案

在 Hit and Trail 策略中我终于找到了问题.

Well in Hit and Trail strategy I finally Caught the problem.

server.properties 文件中有 4 个属性端口host.name广告主机名广告端口

There are 4 properties in server.properties file port, host.name, advertised host name and advertised port

和 Producer.properties 文件中的 1 个属性metadata.broker.list

And 1 property in Producer.properties file metadata.broker.list

确保broker.list 与advertised.host.name:advertised.port 相同

Make sure that broker.list is same as advertised.host.name:advertised.port

注释 host.name 属性,因为它不会影响如果提供了广告主机名.

Comment host.name property as it doesn't effect If advertised host name is given.

我只是使用 ifconfig 命令获取了我的沙箱的 ip,然后将该 IP 与 9092 端口放在两个属性中,并且它工作正常.

I simply got ip of my sandbox using ifconfig command and then put that IP with 9092 port in both properties and it worked.

这篇关于从主机操作系统访问沙箱中的 kafka(尝试所有解决方案后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆