rocketmq双主模式
1、官网
https://rocketmq.apache.org/
官方安装文档
https://rocketmq.apache.org/docs/quick-start/
2、rocketmq多主配置文件参考(conf/2m-noslave/broker-a.properties)
10.0.0.2服务器
[root@a ~]# cat /usr/local/rocketmq/conf/2m-noslave/broker-a.properties brokerClusterName=rocketmq-cluster brokerName=broker-a brokerId=0 namesrvAddr=10.0.0.2:9876;10.0.0.3:9876 brokerIP1=10.0.0.2 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true listenPort=10168 deleteWhen=04 fileReservedTime=48 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=500000 diskMaxUsedSpaceRatio=88 storePathRootDir=/data/rocketmq/store storePathCommitLog=/data/rocketmq/store/commitlog storePathConsumeQueue=/data/rocketmq/store/consumequeue storePathIndex=/data/rocketmq/store/index storeCheckpoint=/data/rocketmq/store/checkpoint abortFile=/data/rocketmq/store/abort maxMessageSize=65536 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH #发消息线程池数量 #sendMessageThreadPoolNums=128 #拉消息线程池数量 #pullMessageThreadPoolNums=128
服务启动与关闭
function start_rocketMQ(){ echo "start mqnamesrv......" nohup sh /usr/local/rocketmq/bin/mqnamesrv & nohup sh /usr/local/rocketmq/bin/mqbroker -c /usr/local/rocketmq/conf/2m-noslave/broker-a.properties >/dev/null 2>&1 & sleep 2 [ $? -ne 0 ]&& action "start mqnamesrv Success..." /bin/true||action "start mqnamesrv False..." /bin/false } function stop_rocketMQ(){ echo "stop rocketMQ..." sh /usr/local/rocketmq/bin/mqshutdown broker sleep 2 sh /usr/local/rocketmq/bin/mqshutdown namesrv }
10.0.0.3服务器
[root@b ~]# cat /usr/local/rocketmq/conf/2m-noslave/broker-b.properties brokerClusterName=rocketmq-cluster brokerName=broker-b brokerId=0 namesrvAddr=10.0.0.2:9876;10.0.0.3:9876 brokerIP1=10.0.0.3 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=false listenPort=10168 deleteWhen=04 fileReservedTime=48 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=500000 diskMaxUsedSpaceRatio=88 storePathRootDir=/data/rocketmq/store storePathCommitLog=/data/rocketmq/store/commitlog storePathConsumeQueue=/data/rocketmq/store/consumequeue storePathIndex=/data/rocketmq/store/index storeCheckpoint=/data/rocketmq/store/checkpoint abortFile=/data/rocketmq/store/abort maxMessageSize=65536 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH #发消息线程池数量 #sendMessageThreadPoolNums=128 #拉消息线程池数量 #pullMessageThreadPoolNums=128
启动与关闭
function start_rocketMQ(){ echo "start mqnamesrv......" nohup sh /usr/local/rocketmq/bin/mqnamesrv & nohup sh /usr/local/rocketmq/bin/mqbroker -c /usr/local/rocketmq/conf/2m-noslave/broker-b.properties >/dev/null 2>&1 & sleep 2 [ $? -ne 0 ]&& action "start mqnamesrv Success..." /bin/true||action "start mqnamesrv False..." /bin/false } function stop_rocketMQ(){ echo "stop rocketMQ..." sh /usr/local/rocketmq/bin/mqshutdown broker sleep 2 sh /usr/local/rocketmq/bin/mqshutdown namesrv }