Kafka_Installation_Documentation
Kafka_Installation_Documentation
Prerequisites
- **Docker**: Ensure Docker is already installed on your Ubuntu server.
- **Docker Compose**: Ensure Docker Compose is installed on your Ubuntu server.
```bash
docker network create kong_mlajan-network
```
version: '3.8'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
container_name: cp-zookeeper
networks:
- kong_mlajan-network
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:latest
hostname: kafka
container_name: cp-kafka
depends_on:
- zookeeper
networks:
- kong_mlajan-network
ports:
- 9093:9093
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS:
DOCKER_NET://kafka:9092,HOST_NET://18.219.109.108:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP:
DOCKER_NET:PLAINTEXT,HOST_NET:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER_NET
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CONFLUENT_SUPPORT_METRICS_ENABLE: 0
kafka_ui:
image: provectuslabs/kafka-ui:latest
depends_on:
- kafka
networks:
- kong_mlajan-network
ports:
- '8080:8080'
environment:
- KAFKA_CLUSTERS_0_ZOOKEEPER=zookeeper:2181
- KAFKA_CLUSTERS_0_NAME=local
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092
networks:
kong_mlajan-network:
external: true
```bash
docker-compose up -d
```
2. **Create a topic**:
```bash
kafka-topics --create --topic test-topic --bootstrap-server kafka:9092 --partitions 1 --
replication-factor 1
```
3. **Produce messages**:
```bash
kafka-console-producer --topic test-topic --bootstrap-server kafka:9092
```
Type your messages and press `Enter`.
4. **Consume messages**:
Open another terminal and execute:
```bash
kafka-console-consumer --topic test-topic --from-beginning --bootstrap-server kafka:9092
```
```