设为首页 加入收藏

TOP

说说MQ之RocketMQ(三)(一)
2018-10-12 12:08:04 】 浏览:269
Tags:说说 RocketMQ

RocketMQ 的主备模式

按之前所说,只有 RocketMQ 的多主多从异步复制是可以生产使用的,因此只在这个场景下测试。另外,消息采用 Push 顺序模式消费。

假设集群采用2主2备的模式,需要启动4个 Broker,配置文件如下,

brokerName=broker-a
brokerId=0
listenPort=10911
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-a-async
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-a-async/commitlog
brokerRole=ASYNC_MASTER
brokerName=broker-a
brokerId=1
listenPort=10921
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-a-async-slave
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-a-async-slave/commitlog
brokerRole=SLAVE
brokerName=broker-b
brokerId=0
listenPort=20911
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-b-async
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-b-async/commitlog
brokerRole=ASYNC_MASTER
brokerRole=ASYNC_MASTER
brokerName=broker-b
brokerId=1
listenPort=20921
storePathRootDir=/home/arnes/alibaba-rocketmq/data/store-b-async-slave
storePathCommitLog=/home/arnes/alibaba-rocketmq/data/store-b-async-slave/commitlog
brokerRole=SLAVE

另外,每个机构共通的配置项如下,

brokerClusterName=DefaultCluster
brokerIP1=192.168.232.23
namesrvAddr=192.168.232.23:9876
deleteWhen=04
fileReservedTime=120
flushDiskType=ASYNC_FLUSH

其他设置均采用默认。启动 NameServer 和所有 Broker,并试运行一下 Producer,然后看一下 TestTopic1 当前的情况,

$ sh mqadmin topicRoute -n 192.168.232.23:9876 -t TopicTest1
{
        "brokerDatas":[
                {
                        "brokerAddrs":{0:"192.168.232.23:20911",1:"192.168.232.23:20921"
                        },
                        "brokerName":"broker-b"
                },
                {
                        "brokerAddrs":{0:"192.168.232.23:10911",1:"192.168.232.23:10921"
                        },
                        "brokerName":"broker-a"
                }
        ],
        "filterServerTable":{},
        "queueDatas":[
                {
                        "brokerName":"broker-a",
                        "perm":6,
                        "readQueueNums":4,
                        "topicSynFlag":0,
                        "writeQueueNums":4
                },
                {
                        "brokerName":"broker-b",
                        "perm":6,
                        "readQueueNums":4,
                        "topicSynFlag":0,
                        "writeQueueNums":4
                }
        ]
}

可见,TestTopic1 在2个 Broker 上,且每个 Broker 备机也在运行。下面开始主备切换的实验,分别启动 Consumer 和 Producer 进程,消息采用 Pull 顺序模式消费。在消息发送接收过程中,使用 kill -9 停掉 broker-a 的主进程,模拟突然宕机。此时,TestTopic1 的状态如下,

$ sh mqadmin topicRoute -n 192.168.232.23:9876 -t TopicTest1
{
        "brokerDatas":[
                {
                        "brokerAddrs":{0:"192.168.232.23:20911",1:"192.168.232.23:20921"
                        },
                        "brokerName":"broker-b"
                },
                {
                        "brokerAddrs":{1:"192.168.232.23:10921"
                        },
                        "brokerName":"broker-a"
                }
        ],
        "filterServerTable":{},
        "queueDatas":[
                {
                        "brokerName":"broker-a",
                        "perm":6,
                        "readQueueNums":4,
                        "topicSynFlag":0,
                        "writeQueueNums":4
                },
                {
                        "brokerName":"broker-b",
                        "perm":6,
                        "readQueueNums":4,
                        "topicSynFlag":0,
                        "writeQueueNums":4
                }
        ]
}

bro
编程开发网

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/15/15
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Kafka Controller Redesign方案 下一篇说说MQ之RocketMQ(二)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

最新文章

热门文章

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目

array(4) { ["type"]=> int(8) ["message"]=> string(24) "Undefined variable: jobs" ["file"]=> string(32) "/mnt/wp/cppentry/do/bencandy.php" ["line"]=> int(214) }