RocketMQ【1】linux安装配置Rocketmq(单机版)
RocketMQ【2】Rocketmq控制台安装启动(单机版)
即使磁盘损坏,消息丢失的非常少,且消息实时性不会受影响,同时Master宕机后,消费者仍然可以从Slave消费,而且此过程对应用透明,不需要人工干预,性能同多Master模式几乎一样;
Master宕机,磁盘损坏情况下会丢失少量消息。一般需要在消费端或者定时进行消息确认。
机器名称 | 机器ip | 主备 | 端口 |
---|---|---|---|
MQ1 | 192.168.3.106 | master1 | 11910 |
MQ2 | 192.168.3.107 | slave2 | 11911 |
MQ1 | 192.168.3.106 | master2 | 11910 |
MQ2 | 192.168.3.107 | slave1 | 11911 |
在mq的安装目录下,conf/2m-2s-async/
文件下下,有以下配置文件。
-rw-r–r-- 1 root root 969 3月 5 20:02 broker-a.properties
-rw-r–r-- 1 root root 1194 3月 5 20:34 broker-a-s.properties
-rw-r–r-- 1 root root 979 3月 5 20:34 broker-b.properties
-rw-r–r-- 1 root root 922 6月 20 2022 broker-b-s.properties
需要配置master节点的nameserver地址,将brocker注册到namserver。
在192.168.3.106
机器配置broker-a.properties
文件,添加以下内容
namesrvAddr=192.168.3.106,192.168.3.107
在192.168.3.107
机器配置broker-b.properties
文件,添加以下内容
namesrvAddr=192.168.3.106,192.168.3.107
需要配置slave的端口和文件的存储位置,不然会和master抢占,同意需要配置nameserver。
在192.168.3.106
机器配置broker-b-s.properties
文件,添加以下内容
namesrvAddr=192.168.3.106:9876;192.168.3.107:9876
listenPort=11911
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/index
storeCheckpoint=~/store-s/checkpoint
abortFile=~/store-s/abort
在192.168.3.107
机器配置broker-a-s.properties
文件,添加以下内容
namesrvAddr=192.168.3.106:9876;192.168.3.107:9876
listenPort=11911
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/index
storeCheckpoint=~/store-s/checkpoint
abortFile=~/store-s/abort
两台机器同时执行
nohup sh bin/mqnamesrv &
MQ1执行
nohup sh bin/mqnamesrv -c conf/2m-2s-async/broker-a.properties &
MQ2执行
nohup sh bin/mqnamesrv -c conf/2m-2s-async/broker-b.properties &
nohup sh bin/mqnamesrv -c conf/2m-2s-async/broker-b-s.properties &
MQ2执行
nohup sh bin/mqnamesrv -c conf/2m-2s-async/broker-a-s.properties &
这里初步描述如何启动控制台,其他内容