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 streaming, online/offline system analytics, and real-time monitoring.
This tutorial describes how you can deploy Kafka in HCE 2.0.
Preparations
- Prepare an ECS and assign a public IP address or EIP to the ECS.
- Ensure that inbound security group rules allow traffic to flow to the ECS over port 9092.
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 created 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.
Feedback
Was this page helpful?
Provide feedbackThank 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