对于rocketmq配置问题的记录
对于双主双从的两台机器,一台机器配master1,slave2,一台机器配master2,slave1,防止宕机的情况
首先在两台机器上配 :vi /etc/hosts:
添加内容如下:
#nameserver:
第一台机器的公网ip rocketmq-nameserver1
第二台机器的公网ip rocketmq-nameserver2
#broker:
第一台机器公网ip rocketmq-master1
第一台机器公网ip rocketmq-slave2
第二台机器公网ip rocketmq-master2
第二台机器公网ip rocketmq-slave1
以我的为例:
两台机器都要配这个,配完后输入以下命令重启网卡生效
/etc/init.d/network restart
接下来开始配broker
对于机器一:master1和slave2的broker配置如下:
master1:
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.
/**
* [brokerName description]
* @type {[type]}
*
* brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
*/
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/user/local/rocketmq/store
#commitLog 存储路径
storePathCommitLog=/user/local/rocketmq/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/user/local/rocketmq/store/consumequeue
#消息索引存储路径
storePathIndex=/user/local/rocketmq/store/index
#checkpoint 文件存储路径
storeCheckpoint=/user/local/rocketmq/store/checkpoint
#abort 文件存储路径
abortFile=/user/local/rocketmq/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=SYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
brokerIP1=第一台机器的公网ip
brokerIP2=第二台机器的公网ip
(该配置文件中的namesrvAddr)即在hosts中配只的ip地址对应的别名(nameserver,对于存储路径开始的以下参数,两台机器的文件夹路径需要不同,相同的话broker会起不来)
接下来是slave2的配置
slave2
broker-b-s.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=DefaultCluster
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
**/
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=11011
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/user/local/rocketmq/store2
#commitLog 存储路径
storePathCommitLog=/user/local/rocketmq/store2/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/user/local/rocketmq/store2/consumequeue
#消息索引存储路径
storePathIndex=/user/local/rocketmq/store2/index
#checkpoint 文件存储路径
storeCheckpoint=/user/local/rocketmq/store2/checkpoint
#abort 文件存储路径
abortFile=/user/local/rocketmq/store2/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
#
brokerIP1=第一台机器公网ip
brokerIP2=第二台机器公网ip
对于机器二:master2,slave1的配置如下
master2:
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=DefaultCluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
*/
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=10911
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/user/local/rocketmq/store
#commitLog 存储路径
storePathCommitLog=/user/local/rocketmq/store/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/user/local/rocketmq/store/consumequeue
#消息索引存储路径
storePathIndex=/user/local/rocketmq/store/index
#checkpoint 文件存储路径
storeCheckpoint=/user/local/rocketmq/store/checkpoint
#abort 文件存储路径
abortFile=/user/local/rocketmq/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=SYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
#
brokerIP1=第一台机器公网ip
brokerIP2=第二台机器公网ip
此处注意事项和上文相同
slave1
broker-a-s.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 description]
* @type {[type]}
* brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
*/
#所属集群名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此处不同的配置文件填写的不一样
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer地址,分号分割
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许 Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
listenPort=11011
#删除文件时间点,默认凌晨 4点
deleteWhen=04
#文件保留时间,默认 48 小时
fileReservedTime=120
#commitLog每个文件的大小默认1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每个文件默认存30W条,根据业务情况调整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/user/local/rocketmq/store2
#commitLog 存储路径
storePathCommitLog=/user/local/rocketmq/store2/commitlog
#消费队列存储路径存储路径
storePathConsumeQueue=/user/local/rocketmq/store2/consumequeue
#消息索引存储路径
storePathIndex=/user/local/rocketmq/store2/index
#checkpoint 文件存储路径
storeCheckpoint=/user/local/rocketmq/store2/checkpoint
#abort 文件存储路径
abortFile=/user/local/rocketmq/store2/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#发消息线程池数量
#sendMessageThreadPoolNums=128
#拉消息线程池数量
#pullMessageThreadPoolNums=128
#
brokerIP1=第一台机器公网ip
brokerIP2=第二台机器公网ip
注意事项同上
配置完成后,先分别启动nameserver(两台机器):
(前提:runbroker.sh和runserver.sh的内存已更改,因为默认内存较大,不改的话起不来)
nohup sh mqnamesrv &
再分别按配置启动broker(两台机器)
机器一(master1,slave2):
nohup sh mqbroker -n 当前机器公网ip:9876 -c broker-a.properties &
nohup sh mqbroker -n 当前机器公网ip:9876 -c broker-b-s.properties &
机器二(master2,slave1):
nohup sh mqbroker -n 当前机器公网ip:9876 -c broker-b.properties &
nohup sh mqbroker -n 当前机器公网ip:9876 -c broker-a-s.properties &
全部启动完毕后,每台机器执行jps查看应该是这样的:
接下来进行可视化界面的设置RocketMQ
有一个对其扩展的开源项目incubator-rocketmq-externals,这个项目中有一个子模块叫rocketmq-console
,这个便是管理控制台项目了,先将incubator-rocketmq-externals拉到本地,因为我们需要自己对rocketmq-console
进行编译打包运行。
这是一个springboot项目
git clone https://github.com/apache/rocketmq-externals
cd rocketmq-console
mvn clean package -Dmaven.test.skip=true
在打包前,打开项目路径下的application.properties修改
rocketmq.config.namesrvAddr=第一台机器公网ip:9876;第二台机器公网ip:9876
rocketmq.config.isVIPChannel=false
使用maven打包成jar包
上传到两台机器上
然后执行
java -jar xxxx.jar
然后从本机访问对应ip地址的8080端口即可访问可视化控制台,如果是云服务器,记得把端口都开开,9876,8080什么的,机器的防火墙需要关闭,具体百度,然后界面是这样的
有一个问题,我所看的教程这边的broker是4个的,我的是分别在两台机器上显示:
这里分开在两个端显示了,不知道为何
本文地址:https://blog.csdn.net/qq_40719095/article/details/109636777
上一篇: MySQL存储引擎InnoDB的体系架构
下一篇: 2020年第一周赛事(浙江省赛,秦皇岛)
推荐阅读
-
php配置有关问题,phpinfo可以解析,但是其他的却不行。求教
-
这个问题不该在这里问哦!看看吧,一段SENDMAIL的配置。不过想要_PHP
-
Bigcommerce:config.php的配置有关问题:无法写入自定义的新的配置信息
-
关于MPAndroidChart RadarChart 雷达图遇到的一些问题记录。
-
12 关于truffle的一些问题记录
-
关于eclipse下利用tomcat调试jsp的一些问题的解决记录
-
关于MPAndroidChart BarChart 柱状图组遇到的一些问题记录。
-
关于php查询数据库记录显示的有关问题
-
Linux服务器中对于Memcache的安装配置方法
-
浅谈python中对于json写入txt文件的编码问题