两台虚机CentOS7.2, 分别为:192.168.1.11(mq-master-a)和 192.168.1.12(mq-master-b)。
mq-master-a 上部署 a主b从,mq-master-b上部署b主a从,同步双写,异步刷盘,namesrv也分别在这两台机器上启动,
理想场景:生产者发送异步消息,消费者正常消费,topic会在两台broker服务中同步,其中一台broker服务宕掉后,另一台继续接收消息,保证MQ服务集群高可用。
但实测结果:生产者发送异步消息,但topic始终只在一个broker中创建,导致这台broker服务宕掉后,生产者无法继续针对该topic发消息,报错如下:
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic,xxx...
服务启动具体操作如下:
1、先分别启动两台机器上的namesrv服务:
nohup sh ./mqnamesrv -c /usr/local/rocketmq/conf/namesrv.p &
2、再分别启动 mq-master-a 和 mq-master-b 上的 broker-master 服务:
nohup sh ./mqbroker -c /usr/local/rocketmq/conf/broker-master-a.p &
nohup sh ./mqbroker -c /usr/local/rocketmq/conf/broker-master-b.p &
3、最后分别启动 mq-master-a 和 mq-master-b 上的 broker-slave 服务:
nohup sh ./mqbroker -c /usr/local/rocketmq/conf/broker-slave-b.p &
nohup sh ./mqbroker -c /usr/local/rocketmq/conf/broker-slave-a.p &
mq-master-a 和 mq-master-b 上的主从配置如下:
1、192.168.1.11上的 broker-master-a.p 配置:
listenPort=10911
namesrvAddr=192.168.1.11:9876;192.168.1.12:9876
brokerClusterName=mq-cluster
brokerIP1=192.168.1.11
brokerName=broker-a
brokerId=0
defaultTopicQueueNums=1
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=85
storePathRootDir=/usr/local/rocketmq/data/store/master
storePathCommitLog=/usr/local/rocketmq/data/store/master/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
2、192.168.1.11上的 broker-slave-b.p 配置:
listenPort=10950
namesrvAddr=192.168.1.11:9876;192.168.1.12:9876
brokerClusterName=mq-cluster
brokerIP1=192.168.1.11
brokerName=broker-b
brokerId=1
defaultTopicQueueNums=1
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=85
storePathRootDir=/usr/local/rocketmq/data/store/slave
storePathCommitLog=/usr/local/rocketmq/data/store/slave/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
3、192.168.1.12上的 broker-master-b.p 配置:
listenPort=10911
namesrvAddr=192.168.1.11:9876;192.168.1.12:9876
brokerClusterName=mq-cluster
brokerIP1=192.168.1.12
brokerName=broker-b
brokerId=0
defaultTopicQueueNums=1
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=85
storePathRootDir=/usr/local/rocketmq/data/store/master
storePathCommitLog=/usr/local/rocketmq/data/store/master/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
4、192.168.1.12上的 broker-slave-a.p 配置:
listenPort=10950
namesrvAddr=192.168.1.11:9876;192.168.1.12:9876
brokerClusterName=mq-cluster
brokerIP1=192.168.1.12
brokerName=broker-b
brokerId=1
defaultTopicQueueNums=1
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
diskMaxUsedSpaceRatio=85
storePathRootDir=/usr/local/rocketmq/data/store/slave
storePathCommitLog=/usr/local/rocketmq/data/store/slave/commitlog
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
sendMessageThreadPoolNums=128
pullMessageThreadPoolNums=128
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
5、192.168.1.11和192.168.1.12上的 namesrv.p 配置如下:
listenPort=9876
orderMessageEnable=true
useEpollNativeSelector=true