M1 docker手动编译rocketmq
构建rocketmq-docker
镜像
-
拉取代码:
git clone https://github.com/apache/rocketmq-docker.git
-
cd rocketmq-docker
-
-
其中Readme.md,会有步骤介绍。
-
cd image-build
-
sh build-image.sh 4.8.0 alpine
「4.8.0 alpine
是我要构建的rocketmq的版本」 -
通过
docker images
,来验证。
构建rocketmq-console
-
git clone https://github.com/apache/rocketmq-dashboard
.新版本已经没有rocketmq-console-ng,需要搜索rocketmq-dashboard。 -
cd rocketmq-dashboard-master/
-
mvn clean package -Dmaven.test.skip=true
-
将target中的jar包复制到src/main/docker中。
-
创建配置文件
-
创建
broker.conf
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. brokerClusterName = DefaultCluster brokerName = broker-b brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH # Set self-defined brokerIP address (e.g. the host node's) brokerIP1=本机IP
-
创建
rocketmq.yml
version: '3'
services:
namesrv:
image: apache/rocketmq:4.8.0-alpine
container_name: rmqnamesrv
ports:
- 9876:9876
command: sh mqnamesrv
broker:
image: apache/rocketmq:4.8.0-alpine
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- /Users/dingchuan/Documents/rocketmq/conf/broker.conf:/home/rocketmq/rocketmq-4.8.0/conf/broker.conf
- /Users/dingchuan/Documents/rocketmq/logs:/home/rocketmq/logs
- /Users/dingchuan/Documents/rocketmq/store:/home/rocketmq/store
command: sh mqbroker -n namesrv:9876 -c /home/rocketmq/rocketmq-4.8.0/conf/broker.conf
depends_on:
- namesrv
mqconsole:
image: candice0630/rocketmq-console-ng:2.0
container_name: rmqconsole
ports:
- 8181:8080
environment:
JAVA_OPTS: -Drocketmq.config.namesrvAddr=namesrv:9876 -Drocketmq.config.isVIPChannel=false
depends_on:
- namesrv
- 要修改配置文件volumes中的/Users/dingchuan/Documents/rocketmq/conf/broker.conf,改成步骤二自己创建的broker.conf的路径
- image的版本,根据第1步构建的rocketmq-docker镜像来修改,此处选择4.8.0-alpine
-
通过rocketmq.yml构建镜像组:
docker-compose -f rocketmq.yml up -d
-
回到docker desktop 验证。
-
console验证。