docker-compose rocketmq5.1.3
1.平常测试使用
2.创建文件夹
mkdir -p /opt/rocketmq/server
mkdir -p /opt/rocketmq/broker
3. broker.conf 将broker.conf 放到/broker下面
# 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-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
aclEnable=true
brokerIP1=192.168.56.215 #机器ip
将plain_acl.yml 将plain_acl.yml 放到/broker下面
globalWhiteRemoteAddresses:
# 注释掉全局白名单,所有IP皆可访问,根据自己需求进行控制
#- 10.10.103.*
#- 192.168.0.*
accounts:
- accessKey: nIemPn1hwRjSEjTY
secretKey: wsiXcHUX2q0Q37KbXp19EQ8JG6qqOQaj
whiteRemoteAddress:
admin: false
defaultTopicPerm: DENY
defaultGroupPerm: SUB
topicPerms:
- topicA=DENY
- chat-im-event=PUB|SUB
- topicC=SUB
groupPerms:
# the group should convert to retry topic
- GID-im-event-consumer=SUB
- GID-im-event-producer=SUB
- groupB=PUB|SUB
- groupC=SUB
- accessKey: rocketmq2
secretKey: wsiXcHUX2q0Q37KbXp19EQ8JG6qqOQaj
whiteRemoteAddress: 192.168.1.*
# if it is admin, it could access all resources
admin: true
# 添加一个给Dashboard使用的用户
- accessKey: console
secretKey: wsiXcHUX2q0Q37KbXp19EQ8JG6qqOQaj
whiteRemoteAddress:
admin: true
[root@localhost rocketmq]# ls
broker server
[root@localhost rocketmq]# cd broker/
[root@localhost broker]# ls
broker.conf logs plain_acl.yml store
[root@localhost broker]# pwd
/opt/rocketmq/broker
[root@localhost broker]#
4.docker-compose.yml 单独一个文件存放即可
version : '3.8'
services:
rocketmq-server:
image: apache/rocketmq:5.1.3
restart: unless-stopped
container_name: rocketmq-server
networks:
znbg:
ipv4_address: 10.17.59.7
ports:
- 9876:9876
volumes:
- /opt/rocketmq/server/logs/:/home/rocketmq/logs
command: sh mqnamesrv
rocketmq-broker:
image: apache/rocketmq:5.1.3
container_name: rocketmq-broker
networks:
znbg:
ipv4_address: 10.17.59.8
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- /opt/rocketmq/broker/logs:/home/rocketmq/logs
- /opt/rocketmq/broker/store:/home/rocketmq/store
command: sh mqbroker -n 10.17.59.7:9876 --enable-proxy autoCreateTopicEnable=true -c /home/rocketmq/rocketmq-5.1.3/conf/broker.conf
depends_on:
- rocketmq-server
networks:
znbg:
driver: bridge
ipam:
config:
- subnet: 10.17.59.0/24
gateway: 10.17.59.1
5.启动 docker-compose up 查看启动状态
若broker 没有启动成功 则对
/opt/rocketmq/server
/opt/rocketmq/broker
目录下 logs 文件赋权限 chmod 777 *
或者是整个目录都赋权限即可,然后重启 docker-compose up
6.查看状态
[root@localhost broker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a217d0e64e4 apache/rocketmq:5.1.3 "./docker-entrypoint…" 29 minutes ago Up 12 minutes 0.0.0.0:10909->10909/tcp, :::10909->10909/tcp, 9876/tcp, 0.0.0.0:10911-10912->10911-10912/tcp, :::10911-10912->10911-10912/tcp rocketmq-broker
1141f71c19a2 apache/rocketmq:5.1.3 "./docker-entrypoint…" 29 minutes ago Up 12 minutes 10909/tcp, 0.0.0.0:9876->9876/tcp, :::9876->9876/tcp, 10911-10912/tcp rocketmq-server
[root@localhost broker]#