Kafka + Zookeeper: Connection to node -1 could not be established. Broker may not be available

后端 未结 5 524
一整个雨季
一整个雨季 2020-12-17 07:54

I am running in my locahost both Zookeeper and Kafka (1 instance each).

I create succesfully a topic from kafka:

./bin/kafka-topics.sh --zookeeper lo         


        
5条回答
  •  [愿得一人]
    2020-12-17 08:06

    I found the error. Observing zookeeper logs when the server started I noticed:

    server.1=mylocal-0.:2888:3888
    

    with a dot (.) after the name of the host.

    The script that produces the zookeeper's config is from https://github.com/kubernetes/contrib/blob/master/statefulsets/zookeeper/zkGenConfig.sh

    Looking inside I see that DOMAIN is not filled:

    HOST=`hostname -s`
    DOMAIN=`hostname -d`
    
    function print_servers() {
        for (( i=1; i<=$ZK_REPLICAS; i++ ))
        do
            echo "server.$i=$NAME-$((i-1)).$DOMAIN:$ZK_SERVER_PORT:$ZK_ELECTION_PORT"
        done
    }
    

    For my case (localhost) I don't need domain, so I removed that variable.

    Now zookeeper and kafka communicate with no errors.

提交回复
热议问题