Why I cannot connect to Kafka from outside?

前端 未结 8 1976
梦毁少年i
梦毁少年i 2020-12-02 14:19

I am running kafka on ec2 instance. So amazon ec2 instance has two ips one is internal ip and second one is for external use.

I created producer from local machine,

相关标签:
8条回答
  • 2020-12-02 15:06

    For EC2 you should edit the /etc/hosts file to add:

    XXX.XXX.XXX.XXX ip-YYY-YYY-YYY-YYY
    

    where XXX... is your external IP and the ip-YYY-YYY-YYY-YYY is the string returned by the hostname command. You can use 127.0.0.1 instead of your external IP to communicate inside the server.

    host.name is deprecated - as are advertised.host.name and advertised.port

    0 讨论(0)
  • 2020-12-02 15:08

    I just did this in AWS. First get the Kafka server to listen on the correct interface/IP using host.name. For your case this would be the internal IP, not localhost, since your intent is for outside Kafka clients to connect. Any local clients will need to use that same address, not localhost.

    Then set advertised.host.name to a host name, not an IP address. The trick is to get that host name to always resolve to the correct IP for both internal and external machines. I use /etc/hosts inside and DNS outside. See my full answer about Kafka and name resolution here.

    0 讨论(0)
提交回复
热议问题