阿里云主机安装RocketMQ 集群支持外网访问

本文档详细记录了如何在云环境中搭建一个RocketMQ 3.4.6版本的集群,包括配置两台主机为2m-noslave模式,设置外网访问,并提供了启动Namesrv和Broker的步骤,以及启动RocketMQ监控Console的过程。
摘要由CSDN通过智能技术生成

背景:因公司迁移机房,需要在云主机上部署一套和本地一样的rocketMQ,原本计划直接购买云rocketMQ,云rocketMQ仅支持5.0.0,本地rocketMQ 是3.4.6,公司多个服务都使用本地的3.4.6版本的RocketMQ,所以需要再云上搭建一套简易版RocketMQ集群,并支持外网访问。

准备:两台开通外网的云主机,带宽100M,16G内存,500G硬盘,两台成本1000+

           设置主机名,安装jdk,配置免密等等,前期的准备工作。

           安装包:rocketmq-3.4.6.tar.gz

           下载地址:

因为是只有两台,所以规划是2m-noslave

vi /opt/servers/rocketmq-3.4.6/devenv/conf/2m-noslave/broker-a.properties

# 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=AdpMqCluster
brokerName=broker-a
#0 表示 Master, >0 表示 Slave
brokerId=0
namesrvAddr=hadoop001:9876;hadoop002:9876
#外网ip
brokerIP1=101.200.149.*
#内网ip
brokerIP2=172.17.128.14
deleteWhen=04
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 0点
deleteWhen=00
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/opt/servers/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/opt/servers/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/servers/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/opt/servers/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/servers/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/opt/servers/rocketmq/data/abort
#限制的消息大小
#maxMessageSize=65536
maxMessageSize=5242880

#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
sendMessageThreadPoolNums=128
#拉消息线程池数量
pullMessageThreadPoolNums=128

vi /opt/servers/rocketmq-3.4.6/devenv/conf/2m-noslave/broker-b.properties

# 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=AdpMqCluster
brokerName=broker-b
#0 表示 Master, >0 表示 Slave
brokerId=0
namesrvAddr=hadoop001:9876;hadoop002:9876
#外网ip
brokerIP1=123.57.61.*
#内网ip
brokerIP2=172.17.128.15
deleteWhen=04
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 0点
deleteWhen=00
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=50000000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/opt/servers/rocketmq/data
#commitLog 存储路径
storePathCommitLog=/opt/servers/rocketmq/data/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/opt/servers/rocketmq/data/consumequeue
#消息索引存储路径
storePathIndex=/opt/servers/rocketmq/data/index
#checkpoint 文件存储路径
storeCheckpoint=/opt/servers/rocketmq/data/checkpoint
#abort 文件存储路径
abortFile=/opt/servers/rocketmq/data/abort
#限制的消息大小
#maxMessageSize=65536
maxMessageSize=5242880

#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
sendMessageThreadPoolNums=128
#拉消息线程池数量
pullMessageThreadPoolNums=128

同步目录 /opt/servers/rocketmq-3.4.6  到hadoop002;

在hadoop001上启动NamesrvStartup:

nohup sh runserver.sh com.alibaba.rocketmq.namesrv.NamesrvStartup &

在hadoop001上启动BrokerStartup:

nohup sh mqbroker autoCreateTopicEnable=true -c /opt/servers/rocketmq/devenv/conf/2m-noslave/broker-a.properties &

在hadoop002上启动NamesrvStartup:

nohup sh runserver.sh com.alibaba.rocketmq.namesrv.NamesrvStartup &

在hadoop002上启动BrokerStartup:

nohup sh mqbroker autoCreateTopicEnable=true -c /opt/servers/rocketmq/devenv/conf/2m-noslave/broker-b.properties &

在hadoop002上启动console:
vi  /opt/servers/rocketmq/rocketmq-externals-master/rocketmq-console/target/runconsole.sh
 

java -jar rocketmq-console-ng-1.0.0.jar --server.port=12581 --rocketmq.config.namesrvAddr=hadoop001:9876;hadoop002:9876

sh runconsole.sh

使用外网ip:12581 打开console界面

其他找运维人员设置相应的网络访问策略。

安装完成。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冰帆<

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值