kafka汇总
安装
基于docker-compose安装
dcoker-compose 文件目录如下
├── data
│ ├── etc
│ │ └── localtime
│ ├── logs
│ └── var
│ └── run
│ └── docker.sock
├── docker-compose-kafka.yaml
├── readme.md
└── zookeeper
├── data
└── datalog
yaml文件
- docker-compose-kafka.yaml
version: "3"
networks:
web:
services:
zookeeper:
image: wurstmeister/zookeeper ## 镜像
ports:
- "2181:2181" ## 对外暴露的端口号
volumes:
- "./zookeeper/data:/data"
- "./zookeeper/datalog:/datalog"
kafka:
image: wurstmeister/kafka
depends_on:
- zookeeper
volumes:
- ./data/etc/localtime:/etc/localtime
- ./data/var/run/docker.sock:/var/run/docker.sock
- ./data/logs:/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.0.106 ## 宿主机IP
KAFKA_ZOOKEEPER_CONNECT: 192.168.0.106:2181
KAFKA_ADVERTISED_PORT: 9092
# KAFKA_CREATE_TOPICS: test:1:1ls
KAFKA_DELETE_TOPIC_ENABLE: "true"
KAFKA_BROKER_ID: 1
kafka-manager:
image: sheepkiller/kafka-manager
links:
- zookeeper
environment:
ZK_HOSTS: 192.168.0.106:2181
APPLICATION_SECRET: letmein
KM_ARGS: -Djava.net.preferIPv4Stack=true
# ZK_HOSTS: 192.168.110.147 ## zookeeper地址
ports:
- "9095:9000" # 宿主机port:container_port
执行
- 1.进入目录
cd /Users/myself/vagrant/php/machine/Pro1/docker_lnmp/data/kafka
- 2.执行
批量全部执行 docker-compose -f docker-compose-kafka.yaml up -d 单个执行 docker-compose -f docker-compose-kafka.yaml up -d zookeeper docker-compose -f docker-compose-kafka.yaml up -d kafka docker-compose -f docker-compose-kafka.yaml up -d kafka-manager
- 3.停止服务
docker-compose -f docker-compose-kafka.yaml stop
- 4.停止并删除容器
docker-compose -f docker-compose-kafka.yaml down
查看结果
luwei@luweideMacBook-Pro-2 kafka % docker-compose -f docker-compose-kafka.yaml up -d
WARNING: Some networks were defined but are not used by any service: web
Creating network "kafka_default" with the default driver
Creating kafka_zookeeper_1 ... done
Creating kafka_kafka-manager_1 ... done
Creating kafka_kafka_1 ... done
问题
- 1.问题描述
[2022-03-20 10:07:32,409] ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists
at org.apache.zookeeper.KeeperException.create(KeeperException.java:126)
at kafka.zk.KafkaZkClient$CheckedEphemeral.getAfterNodeExists(KafkaZkClient.scala:1837)
at kafka.zk.KafkaZkClient$CheckedEphemeral.create(KafkaZkClient.scala:1775)
at kafka.zk.KafkaZkClient.checkedEphemeralCreate(KafkaZkClient.scala:1742)
at kafka.zk.KafkaZkClient.registerBroker(KafkaZkClient.scala:95)
at kafka.server.KafkaServer.startup(KafkaServer.scala:312)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
at kafka.Kafka$.main(Kafka.scala:82)
at kafka.Kafka.main(Kafka.scala)
原因解释
如果删除容器后映射关系还未删除,把logs 里面历史的删掉ch
本作品采用《CC 协议》,转载必须注明作者和本文链接