项目采用docker-compose启动kafka,默认日志文件会写入/var/lib/docker/volumes/ 导致系统磁盘被写满。加入下面KAFKA_LOG_DIRS配置,并且把配置的容器内地址映射到系统数据文件夹下即可:
kafka:
image: wurstmeister/kafka
container_name: kafka
restart: always
ports:
- $BIND_IP:9092:9092
depends_on:
- zookeeper
links:
- zookeeper
environment:
KAFKA_ADVERTISED_HOST_NAME: $HOST_IP
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_CREATE_TOPICS: "test:2:1"
KAFKA_LOG_DIRS: "/home/kafka/log"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/kafka/log:/home/kafka/log