docker 下Kafka 单机安装(一)以及问题
docker-compose.yml 文件 执行之前需要 修改你的 KAFKA_ADVERTISED_HOST_NAME
1 version: '2' 2 3 services: 4 zoo1: 5 image: wurstmeister/zookeeper 6 restart: unless-stopped 7 hostname: zoo1 8 ports: 9 - "6181:2181" 10 container_name: zookeeper_kafka 11 12 # kafka version: 1.1.0 13 # scala version: 2.12 14 kafka1: 15 image: wurstmeister/kafka 16 ports: 17 - "9092:9092" 18 environment: 19 KAFKA_ADVERTISED_HOST_NAME: 192.168.0.105 20 KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181" 21 KAFKA_BROKER_ID: 1 22 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 23 KAFKA_CREATE_TOPICS: "stream-in:1:1,stream-out:1:1" 24 depends_on: 25 - zoo1 26 container_name: kafka
Kafka Tool 工具 连接 Zookeeper 端口号 6181
docker-compose 启动 zookeeper 之后 报错
ZooKeeper JMX enabled by default Using config: /opt/zookeeper-3.4.13/bin/../conf/zoo.cfg library initialization failed - unable to allocate file descriptor table - out of memory/usr/bin/start-zk.sh: line 4: 11 Aborted (core dumped) /opt/zookeeper-3.4.13/bin/zkServer.sh start-foreground
解决
修改docker创建容器的默认ulimit配置。
步骤如下:
查看docker的systemd配置位置
编辑docker.service
在ExecStart命令后加上创建容器的默认ulimit配置,如下,设置容器启动时的ulimit为65535:65535:
--default-ulimit nofile=65535:65535
配置好的样子
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=65535:65535
重启docker
systemctl daemon-reload
systemctl restart docker
方法3
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_42241322/article/details/137122868