分享好友 最新资讯首页 最新资讯分类 切换频道
快速部署kafka集群和可视化界面
2024-12-28 05:39

3台机器部署kafka集群的分布
10.1.161.111 -> kafka(1个节点)+ zookeeper(一个节点)+ kowl(一个节点)
10.1.161.112 -> kafka(1个节点)+ zookeeper(一个节点)
10.1.161.113 -> kafka(1个节点)+ zookeeper(一个节点)

快速部署kafka集群和可视化界面

curl -fsSL https://get.docker.com | bash

yum -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker

sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-- -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker compose -v
部署方法:
bash(10.1.161.111)

https://hub.docker.com/r/bitnami/kafka
https://hub.docker.com/r/bitnami/zookeeper

version: '2'
services:
zoo:
image: 'bitnami/zookeeper:latest'
restart: unless-stopped
hostname: zoo
container_name: zoo
ports:
- 2181:2181
- 2888:2888
- 3888:3888
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/zookeeper:/bitnami/zookeeper
environment:
ZOO_SERVER_ID: 1
ZOO_SERVERS: 0.0.0.0:2888:3888,10.1.161.112:2888:3888,10.1.161.113:2888:3888
ALLOW_ANONYMOUS_LOGIN: yes

kafka:
image: 'bitnami/kafka:latest'
restart: unless-stopped
hostname: kafka
container_name: kafka
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.1.161.111
KAFKA_HOST_NAME: 10.1.161.111
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 1
KAFKA_CFG_ZOOKEEPER_CONNECT: 10.1.161.111:2181,10.1.161.112:2181,10.1.161.113:2181
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://10.1.161.111:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/kafka:/bitnami/kafka

docker compose -f 10.1.161.111.yml up -d

bash(10.1.161.112)

https://hub.docker.com/r/bitnami/kafka
https://hub.docker.com/r/bitnami/zookeeper

version: '2'
services:
zoo:
image: 'bitnami/zookeeper:latest'
restart: unless-stopped
hostname: zoo
container_name: zoo
ports:
- 2181:2181
- 2888:2888
- 3888:3888
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/zookeeper:/bitnami/zookeeper
environment:
ZOO_SERVER_ID: 2
ZOO_SERVERS: 10.1.161.111:2888:3888,0.0.0.0:2888:3888,10.1.161.113:2888:3888
ALLOW_ANONYMOUS_LOGIN: yes

kafka:
image: 'bitnami/kafka:latest'
restart: unless-stopped
hostname: kafka
container_name: kafka
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.1.161.112
KAFKA_HOST_NAME: 10.1.161.112
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 2
KAFKA_CFG_ZOOKEEPER_CONNECT: 10.1.161.111:2181,10.1.161.112:2181,10.1.161.113:2181
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://10.1.161.112:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/kafka:/bitnami/kafka

docker compose -f 10.1.161.112.yml up -d

bash(10.1.161.113)

https://hub.docker.com/r/bitnami/kafka
https://hub.docker.com/r/bitnami/zookeeper

version: '2'
services:
zoo:
image: 'bitnami/zookeeper:latest'
restart: unless-stopped
hostname: zoo
container_name: zoo
ports:
- 2181:2181
- 2888:2888
- 3888:3888
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/zookeeper:/bitnami/zookeeper
environment:
ZOO_SERVER_ID: 3
ZOO_SERVERS: 10.1.161.111:2888:3888,10.1.161.112:2888:3888,0.0.0.0:2888:3888
ALLOW_ANONYMOUS_LOGIN: yes

kafka:
image: 'bitnami/kafka:latest'
restart: unless-stopped
hostname: kafka
container_name: kafka
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.1.161.113
KAFKA_HOST_NAME: 10.1.161.113
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 3
KAFKA_CFG_ZOOKEEPER_CONNECT: 10.1.161.111:2181,10.1.161.112:2181,10.1.161.113:2181
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://10.1.161.113:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
volumes:
- https://www.cnblogs.com/zwnfdswww/p/data/kafka:/bitnami/kafka

docker compose -f 10.1.161.113.yml up -d

bash(10.1.161.111)
mkdir -p /app/conf
chmod -R 777 /app/conf
放这里面

docker-compose.yml
参考 https://github.com/cloudhut/kowl

version: '2'
services:
kowl:
image: 'quay.io/cloudhut/kowl:master'
restart: unless-stopped
hostname: kowl
container_name: kowl
ports:
- 8085:8085
volumes:
- .:/app/conf
environment:
CONFIG_FILEPATH: /app/conf/kowl.yaml

kowl.yaml
参考 https://github.com/cloudhut/kowl/blob/master/docs/config/kowl.yaml

kafka:
brokers:
- 10.1.161.111:9092
- 10.1.161.112:19092
- 10.1.161.113:19092

server:
listenPort: 8085
basePath: "/kowl/"
readTimeout: 30s
writeTimeout: 30s
idleTimeout: 30s
compressionLevel: 4

cd /app/conf
docker compose up -d

镜像源可能拉不下来,看我前面的文章,里面有解决办法
没权限自动新建文件夹:
yml文件放主目录里
sudo mkdir -p /root/data/zookeeper
sudo chmod -R 777 /root/data/zookeeper

sudo mkdir -p /root/data/zookeeper
sudo chmod -R 777 /root/data/kafka

最新文章
Google Trends和Google Insights
Google Trends(谷歌趋势)发布过中文版,是Google推出的一款基于搜索日志分析的应用产品,通过这个工具可以知道某一搜索关键词
AI绘画工具MJ新功能有点东西,小白也能轻松一键换装
先看最终做出来的效果直接来干货吧。Midjourney,下面简称MJ1.局部重绘功能来袭就在前两天,MJ悄咪咪上线了这个被众人期待的新功
AI制冷,守护绿色未来
互联网发展至今,全球已有近44亿网民,我们通过不同的设备连接互联网,享受着在线购物,在线交友等一系列智能生活,而这背后,离
DDos攻击的防御方法
到目前为止,进行DDoS攻击的防御还是比较困难的。首先,这种攻击的特点是它利用了TCP/IP协议的漏洞,除非你不
AI音乐生成将导致音乐作品版权概念的消亡
在这个迅速变化的时代,科技的进步总是令人惊叹。最近AI音乐生成技术的兴起,开始掀起了关于音乐作品版权的讨论。或
ai语音功能是什么 ai语音功能详解?
2、可以帮用户完成生活当中的众多琐事,比如说翻译、打车、酒店、购物、百科百答等等;3、能够进行全场景实时图像搜索,让电视播
CLion和IDEA集成的ai代码助手——通义灵码的使用及其自动代码补全的禁用设置等使用优化
       通义灵码,作为智能编码on助手,可以在进行编码工作时,为你提供行级/函数级实时续写、自然语言生
11、作为服务注册中心,Eureka比Zookeeper好在哪里?  ***
目录 1、什么是微服务? 2、微服务之间是如何通讯的? 3、springcloud 与dubbo有哪些区别?  4、springBoot
AI�˹�����Ʒ�����а���˹�����δ����չ
�˹����ܣ�AI���ǵ���Ƽ�������Ϊ���ֿ��ȵĻ���֮һ�����ż����IJ��Ͻ�����Ӧ�õ