What are the steps to install Kafka on CentOS 7?

The steps to install Kafka on CentOS 7 are as follows: 1. Update the system software packages.

  sudo yum update

Install Java Development Kit (JDK) because Kafka relies on the Java runtime environment.

  sudo yum install java-1.8.0-openjdk-devel

Download and extract Kafka.

  wget https://downloads.apache.org/kafka/2.8.0/kafka_2.12-2.8.0.tgz

  tar -xzf kafka_2.12-2.8.0.tgz

  cd kafka_2.12-2.8.0

Configure Kafka: Open the `config/server.properties` file and make necessary modifications as needed. Below are some important configuration options:

broker.id:指定Kafka代理的唯一标识符。

listeners:指定Kafka监听的网络接口和端口。

log.dirs:指定Kafka存储消息的目录。

zookeeper.connect:指定连接到Zookeeper集群的地址和端口。

6. Start Zookeeper service: Kafka relies on Zookeeper to maintain state information, so Zookeeper needs to be started before Kafka. Start Kafka service:

  bin/kafka-server-start.sh config/server.properties

7. Create a topic:

  bin/kafka-topics.sh --create --topic mytopic --bootstrap-server localhost:9092 --partitions 1 

  --replication-factor 1

Publishing and consuming messages:

  bin/kafka-console-producer.sh --topic mytopic --bootstrap-server localhost:9092

  bin/kafka-console-consumer.sh --topic mytopic --bootstrap-server localhost:9092 --from-beginning

The above are the basic steps for installing Kafka on CentOS 7. Depending on your actual needs, you may need to perform additional configurations and adjustments.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds