公司的一个公网要搬到内网的一个Rancher集群上,很繁琐
原有的架构有kafka,要在内网复现一个出来
那3节点的kafka和3节点的zookeeper,真的是不想搭啊
搜啊搜啊搜啊搜,终于找到若干平替:
1Redis 的平替 Dragonfly
2Mongo 的平替 FerretDB
3Kafka 的平替 Redpanda
那就选定用Redpanda
来搞,方法还是有一些曲折的:
Redpanda 在 2025年5月16日这个节点,有5个版本
最新的25.1的版本,如果用docker compose来启动,是个压缩包,好多文件。
数据盘有三个了,而且用到了minio做后端的持久化卷,这么复杂,那不如直接搞Kafka了
那只能往前回退,选用24.2的版本,docker compose 就一个文件,不过这个版本 2025年7月31日就终结支持了。
下载的话:https://docs.redpanda.com/24.2/get-started/quick-start/
我们要的是一个broker的,那直接给出源文件
1name: redpanda-quickstart-one-broker
2networks:
3 redpanda_network:
4 driver: bridge
5volumes:
6 redpanda-0: null
7services:
8 redpanda-0:
9 command:
10 - redpanda
11 - start
12 - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092
13 # Address the broker advertises to clients that connect to the Kafka API.
14 # Use the internal addresses to connect to the Redpanda brokers'
15 # from inside the same Docker network.
16 # Use the external addresses to connect to the Redpanda brokers'
17 # from outside the Docker network.
18 - --advertise-kafka-addr internal://redpanda-0:9092,external://localhost:19092
19 - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082
20 # Address the broker advertises to clients that connect to the HTTP Proxy.
21 - --advertise-pandaproxy-addr internal://redpanda-0:8082,external://localhost:18082
22 - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081
23 # Redpanda brokers use the RPC API to communicate with each other internally.
24 - --rpc-addr redpanda-0:33145
25 - --advertise-rpc-addr redpanda-0:33145
26 # Mode dev-container uses well-known configuration properties for development in containers.
27 - --mode dev-container
28 # Tells Seastar (the framework Redpanda uses under the hood) to use 1 core on the system.
29 - --smp 1
30 - --default-log-level=info
31 image: docker.redpanda.com/redpandadata/redpanda:v25.1.4
32 container_name: redpanda-0
33 volumes:
34 - redpanda-0:/var/lib/redpanda/data
35 networks:
36 - redpanda_network
37 ports:
38 - 18081:18081
39 - 18082:18082
40 - 19092:19092
41 - 19644:9644
42 console:
43 container_name: redpanda-console
44 image: docker.redpanda.com/redpandadata/console:v3.1.0
45 networks:
46 - redpanda_network
47 entrypoint: /bin/sh
48 command: -c 'echo "$$CONSOLE_CONFIG_FILE" > /tmp/config.yml; /app/console'
49 environment:
50 CONFIG_FILEPATH: /tmp/config.yml
51 CONSOLE_CONFIG_FILE: |
52 kafka:
53 brokers: ["redpanda-0:9092"]
54 schemaRegistry:
55 enabled: true
56 urls: ["http://redpanda-0:8081"]
57 redpanda:
58 adminApi:
59 enabled: true
60 urls: ["http://redpanda-0:9644"]
61 ports:
62 - 8080:8080
63 depends_on:
64 - redpanda-0
仔细看了一下,这里面有问题,卷是空的,这可不行,必须持久化到本地,改一下
1volumes:
2 redpanda-0:
3 driver: local
4 driver_opts:
5 type: none
6 device: /data/redpanda/data
7 o: bind
然后直接启动:
1docker compose up -d
其实是启动了两个容器,一个数据端;一个是console,客户端
我们打开8080 web的端口,那客户端呢,连的就是19092端口,用法跟kafka完全一样。