Installing Kafka
Introduction
Kafka is distributed pub/sub messaging middleware with high throughput, data persistence, horizontal scalability, and stream data processing. Common applications include log collection, data transmission, online/offline analysis, and real-time monitoring. This section describes how to deploy Kafka in HCE.
Preparations
- Prepare an ECS and assign a public IP address or EIP to the ECS.
- Ensure that security group rules allow inbound traffic on port 9092.
Prerequisites
A local yum repository has been configured. For details, see Configuring an HCE Repository.
Procedure
- Install Kafka.
Run the following command to install Kafka:
dnf install kafka
After the command is executed, Kafka is installed in the /opt/kafka directory.
- Configure Kafka.
- Open the /opt/kafka/config/server.properties file and modify the following attributes:
listeners=PLAINTEXT://<private-IP-address>:9092 advertised.listeners=PLAINTEXT://<public-IP-address>:9092
- Create the /lib/systemd/system/zookeeper.service file and enter the following information:
[Unit] Description=Zookeeper service After=network.target [Service] Type=simple Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" User=root Group=root ExecStart=/opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties ExecStop=/opt/kafka/bin/zookeeper-server-stop.sh Restart=on-failure SuccessExitStatus=143 [Install] WantedBy=multi-user.target
- Create the /lib/systemd/system/kafka.service file and enter the following information:
[Unit] Description=Apache Kafka server (broker) After=network.target zookeeper.service [Service] Type=simple Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" User=root Group=root ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties ExecStop=/opt/kafka/bin/kafka-server-stop.sh Restart=on-failure SuccessExitStatus=143 [Install] WantedBy=multi-user.target
- Run the following commands in sequence to start Kafka and ZooKeeper:
systemctl daemon-reload systemctl start zookeeper systemctl start kafka
- Open the /opt/kafka/config/server.properties file and modify the following attributes:
- Verify Kafka.
- Run the following command to create a topic:
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
- Run the following command to view the new topic:
/opt/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181
If test is displayed, Kafka is deployed.
- Run the following command to create a topic:
The preceding configuration is used only for tests. Exercise caution when using the configuration in the service environment.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot