I have an EC2 instance where I want to run a kafka server. I have made sure that the security group of this instance has all incoming ports opened to all traffic (just to test). Here are my settings:
server.properties:
listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://<EC2-public-ip>:9092
Zookeeper.properties:
dataDir=/home/ubuntu/kafka_2.13-3.7.0/zookeeper
maxClientCnxns=0
admin.enableServer=false
If I comment out the listeners and advertised.listeners lines in the server.properties file and then start the zookeeper and kafka servers with
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
I can then start a producer in one terminal and consumer and another and be able to see the topics sent from producer to consumer. But as soon as I add the listener and advertised.listeners back to the server.properties and try to start a consumer locally I get following errors in the server terminal:
[2024-06-15 01:59:15,898] INFO [Admin Manager on Broker 0]: Error processing create topic request CreatableTopic(name='TestTopic', numPartitions=1, replicationFactor=1, assignments=[], configs=[]) (kafka.server.ZkAdminManager)
org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 1 larger than available brokers: 0.
I have also done ufw allow default incoming so I get this:
:~/kafka_2.13-3.7.0$ netstat -tuln | grep -E '9092|2181'
tcp6 0 0 :::9092 :::* LISTEN
tcp6 0 0 :::2181 :::* LISTEN
What is causing this error? Also I cannot (obviously) start a consumer or a producer to send to the kafka server from my local machine.
Any help is appreciated.