RocketMQ构建docker镜像及部署(2)
1.拉取dockerHub构建好的镜像
docker pull ashscc/rocketmq:4.8.0
2.创建需要挂载进去的文件目录以及配置
mkdir -p /docker/rocketmq/conf
cd /docker/rocketmq/conf
touch broker.conf
#broker.conf配置
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 49.233.147.71
autoCreateTopicEnable=true
aclEnable=true
mkdir -p /docker/rocketmq/conf
cd /docker/rocketmq/conf
touch plain_acl.yml
# plain_acl.yml配置
# 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.
globalWhiteRemoteAddresses:
- 49.233.147.*
- 172.16.7.*
- 172.21.0.13
accounts:
- accessKey: poisonSpider
secretKey: poison6677@
whiteRemoteAddress:
admin: false
defaultTopicPerm: DENY
defaultGroupPerm: SUB
topicPerms:
- poison=SUB|SUB
groupPerms:
# the group should convert to retry topic
- poison_produce_group=PUB
- poison_consume_group_size=SUB
- poison_consume_group_detail=SUB
- accessKey: rocketmqadmin1
secretKey: bigServerMq158@
whiteRemoteAddress: 49.233.147.71
# if it is admin, it could access all resources
admin: true
3.部署nameserve域名发现服务
mkdir -p /docker/rocketmq/nameserve/logs
mkdir -p /docker/rocketmq/nameserve/store
docker run -d -p 9876:9876 --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" -v /docker/rocketmq/nameserve/logs:/home/rocketmq/logs -v /docker/rocketmq/nameserve/store:/home/rocketmq/store ashscc/rocketmq:4.8.0 sh mqnamesrv
4.部署broker控制器服务
#mkdir -p /docker/rocketmq/broker/logs
#mkdir -p /docker/rocketmq/broker/store
/home/rocketmq/logs/rocketmqlogs
docker run -d -p 10911:10911 -p 10909:10909 -p 10912:10912 -v /docker/rocketmq/conf/broker.conf:/home/rocketmq/rocketmq-4.8.0/conf/broker.conf -v /docker/rocketmq/conf/plain_acl.yml:/home/rocketmq/rocketmq-4.8.0/conf/plain_acl.yml --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" ashscc/rocketmq:4.8.0 sh mqbroker -c /home/rocketmq/rocketmq-4.8.0/conf/broker.conf
5.创建rocketmq-console所需要的文件夹和配置
5.1创建user.properties
mkdir -p /docker/rocketmq-console/data
cd /docker/rocketmq-console/data
touch users.properties
# 对登陆的console-log的用户的帐密的配置,修改规则看说明
# This file supports hot change, any change will be auto-reloaded without Console restarting.
# Format: a user per line, username=password[,N] #N is optional, 0 (Normal User); 1 (Admin)
# Define Admin
rocketmqAdmin=rmqconsole112@
# Define Users
testUser=test123
5.2启动时的变量通过系统环境变量写入
docker run -d -e "JAVA_OPTS=-Drocketmq.config.namesrvAddr=49.233.147.71:9876 -Drocketmq.config.isVIPChannel=false -Drocketmq.config.loginRequired=true -Drocketmq.config.dataPath=/tmp/rocketmq-console/data -Drocketmq.config.accessKey=rocketmqadmin1 -Drocketmq.config.secretKey=bigServerMq158@" -v /docker/rocketmq-console/data:/tmp/rocketmq-console/data --name rmqconsole -p 8081:8080 -t ashscc/rocketmq-console
本文来自博客园,作者:orangeScc,转载请注明原文链接:https://www.cnblogs.com/ashScc/p/16150540.html