How to quickly install and start Kafka
Install and start Kafka is quite simple even on you local computer.
Maybe you are thinking it must need lots of dependencies, but the fact is, it only needs Java.
No database, no complicate configuration are needed, so you also no need to install Docker to run it.
How to install and start Kafka
Following are some simple steps about How to quickly install and start Kafka.
Note: please make sure your local environment have installed Java 8+
- Download Kafka binary
tgz
package from Kafka download page - Unzip it:
$ tar -xzf kafka_2.13-3.2.0.tgz $ cd kafka_2.13-3.2.0
- Because Kafka depends on
zookeeper
, so we should startzookeeper
before Kafka:$ bin/zookeeper-server-start.sh config/zookeeper.properties
Note: Soon, ZooKeeper will no longer be required by Apache Kafka.
- Edit
config/server.properties
file:$ vim config/server.properties
Change following line:
#listeners=PLAINTEXT://:9092
to:
listeners=PLAINTEXT://localhost:9092
- Start Kafka:
$ bin/kafka-server-start.sh config/server.properties
Then Kafka will start on
9092
port. - Test it, produce some messages:
$ bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test_topic >test message 1 >test message 2
Consume the messages:
$ bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic test message 1 test message 2
Issues
- Error connecting to node 0.0.0.1:9092 … java.net.NoRouteToHostException: No route to host
Detail issue is:
[2022-05-25 16:28:22,997] WARN [Controller id=0, targetBrokerId=0] Error connecting to node 0.0.0.1:9092 (id: 0 rack: null) (org.apache.kafka.clients.NetworkClient)
java.net.NoRouteToHostException: No route to host
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:483)
at java.base/sun.nio.ch.Net.connect(Net.java:472)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:692)
at org.apache.kafka.common.network.Selector.doConnect(Selector.java:277)
at org.apache.kafka.common.network.Selector.connect(Selector.java:255)
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:990)
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:301)
at org.apache.kafka.clients.NetworkClientUtils.awaitReady(NetworkClientUtils.java:64)
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:291)
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:245)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96)
To solve it, we should change following configuration as STEP 4 above:
#listeners=PLAINTEXT://:9092
to:
listeners=PLAINTEXT://localhost:9092
Previous post: ffmpeg common commands
Next post: MySQL REGEXP_REPLACE() function