kafka版本
2.12-2.0.1
更改端口号
1、修改配置文件 config/server.properties
port=9093
listeners=PLAINTEXT://:9093
host.name=外网映射地址
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092
advertised.listeners=PLAINTEXT://外网映射地址:9093
zookeeper.connect=localhost:2182
2、修改配置文件 config/connect-distributed.properties
bootstrap.servers=localhost:9093
3、修改配置文件 config/connect-standalone.properties
bootstrap.servers=localhost:9093
4、修改配置文件:config/zookeeper.properties
clientPort=2182
启动服务,发现报错
[2021-03-04 17:27:38,158] INFO Got user-level KeeperException when processing sessionid:0x1000a46e31e0000 type:create cxid:0x16 zxid:0x2a6 txntype:-1 reqpath:n/a Error Path:/brokers/ids/0 Error:KeeperErrorCode = NodeExists for /brokers/ids/0 (org.apache.zookeeper.server.PrepRequestProcessor)
[2021-03-04 17:27:38,160] ERROR Error while creating ephemeral at /brokers/ids/0, node already exists and owner '72068832371015680' does not match current session '72068893612310528' (kafka.zk.KafkaZkClient$CheckedEphemeral)
[2021-03-04 17:27:38,160] INFO Result of znode creation at /brokers/ids/0 is: NODEEXISTS (kafka.zk.KafkaZkClient)
[2021-03-04 17:27:38,166] ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists
at org.apache.zookeeper.KeeperException.create(KeeperException.java:122)
at kafka.zk.KafkaZkClient.checkedEphemeralCreate(KafkaZkClient.scala:1525)
at kafka.zk.KafkaZkClient.registerBrokerInZk(KafkaZkClient.scala:84)
at kafka.server.KafkaServer.startup(KafkaServer.scala:257)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
at kafka.Kafka$.main(Kafka.scala:75)
at kafka.Kafka.main(Kafka.scala)
未更改端口号时:
未更改端口号时,只做了一个外网映射
内网ip:9092----->外网ip:9092
只改了config/server.properties文件
listeners=PLAINTEXT://:9092
host.name=外网ip
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092
advertised.listeners=PLAINTEXT://外网ip:9092
求大佬帮助,感谢φ(>ω<*)
1、改成你的内网ip就可以了,默认会绑定到外网的。
listeners=PLAINTEXT://{你的内网ip}:9093
advertised.listeners
和host.name
都删了吧,已经过时了。2、你的错误是
有脏数据,清理一下zk的数据和kafka的数据。
可以了~
你的答案