Skip to content

Commit

Permalink
feat: 添加kafka sasl
Browse files Browse the repository at this point in the history
  • Loading branch information
suyar committed Nov 8, 2024
1 parent 55bff9b commit e295f73
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ CLICKHOUSE_PORT=8123

# kafka
KAFKA_VERSION=3.8.1
KAFKA_USER=admin
KAFKA_PASS=123456
KAFKA_PORT=9092-9095
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
8. elasticsearch:7.17.25(官方镜像)
9. kibana:7.17.25(官方镜像)
10. clickhouse-server:24.8(官方镜像)
11. kafka:3.8.1(官方镜像
11. kafka:3.8.1(bitnami镜像

# 目录

Expand Down
42 changes: 26 additions & 16 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -248,25 +248,35 @@ services:
max-file: "1"

kafka:
image: apache/kafka:${KAFKA_VERSION}
image: bitnami/kafka:${KAFKA_VERSION}
environment:
TZ: ${TZ}
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://:9092,EXTERNAL://127.0.0.1:9094
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_LOG_RETENTION_MINUTES: 10
KAFKA_NUM_PARTITIONS: 3
KAFKA_LOG_DIRS: "/data/kafka"
# KRaft
KAFKA_CFG_NODE_ID: 0
KAFKA_CFG_PROCESS_ROLES: broker,controller
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
# Listeners
KAFKA_CFG_LISTENERS: INTERNAL://:9092,CONTROLLER://:9093,EXTERNAL://:9094
KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://:9092,EXTERNAL://127.0.0.1:9094
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:SASL_PLAINTEXT,INTERNAL:SASL_PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: INTERNAL
# SASL
KAFKA_CFG_SASL_MECHANISM_CONTROLLER_PROTOCOL: PLAIN
KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN
KAFKA_CONTROLLER_USER: ${KAFKA_USER}
KAFKA_CONTROLLER_PASSWORD: ${KAFKA_PASS}
KAFKA_INTER_BROKER_USER: ${KAFKA_USER}
KAFKA_INTER_BROKER_PASSWORD: ${KAFKA_PASS}
KAFKA_CLIENT_USERS: ${KAFKA_USER}
KAFKA_CLIENT_PASSWORDS: ${KAFKA_PASS}
# config
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
KAFKA_CFG_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_CFG_LOG_RETENTION_MINUTES: 10
KAFKA_CFG_NUM_PARTITIONS: 3
volumes:
- ${DIR_DATA}/kafka:/data/kafka
- ${DIR_DATA}/kafka:/bitnami/kafka
hostname: kafka
container_name: dpe_kafka
ports:
Expand Down
2 changes: 1 addition & 1 deletion dpe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ init_services() {

message "初始化 kafka"
mkdir -p $DIR_DATA/kafka
chown 1000:1000 $DIR_DATA/kafka
chown 1001:1001 $DIR_DATA/kafka
chmod 1777 $DIR_DATA/kafka
}

Expand Down

0 comments on commit e295f73

Please sign in to comment.