模式: 多Master多Slave模式,异步复制;
每个 Master 配置一个 Slave,有多对Master-Slave,HA 采用异步复制方式,主备有短暂消息延迟,毫秒级。
优点:即使磁盘损坏,消息丢失的非常少,且消息实时性不会受影响,因为 Master 宕机后,消费者仍然可以从 Slave 消费,此过程对应用透明。不需要人工干预。性能同多 Master 模式几乎一样。
缺点:Master 宕机,磁盘损坏情况,会丢失少量消息。
RocketMQ 网络部署图:
环境准备:CentOS_6.5_x64
IP 主机名 功能
172.17.34.150 LCB-T-rocketmq_nameserver nameserver
172.17.34.151 rocketmq_master01 master01
172.17.34.152 rocketmq_slave01 slave01
172.17.34.153 rocketmq_master02 master02
172.17.34.154 rocketmq_slave02 slave02
一、安装jdk,配置环境变量
二、安装rocketmq
# tar -zxf alibaba-rocketmq-3.2.6.tar.gz -C /usr/local/
# cd /usr/local/
# ln -s /usr/local/alibaba-rocketmq /usr/local/rocketmq
# cd rocketmq/
三、启动路径/usr/local/rocketmq
1、先启动 NameServer,机器 IP 为:172.17.34.150:9876
授权:chmod a+x bin/mqnamesrv
启动:nohup ./bin/mqnamesrv >/var/log/ns.log &
查看日志:tailf /var/log/ns.log
2、启动 Master01
cd /usr/local/rocketmq
chmod a+x bin/mqbroker
nohup ./bin/mqbroker -n 172.17.34.150:9876 -c ./conf/2m-2s-async/broker-a.properties >/var/log/mq.log &
tailf /var/log/ns.log
3、启动Master02
chmod a+x bin/mqbroker
nohup ./bin/mqbroker -n 172.17.34.150:9876 -c ./conf/2m-2s-async/broker-a.properties >/var/log/mq.log &
tailf /var/log/mq.log
4、启动 Slave01
chmod a+x bin/mqbroker
nohup ./bin/mqbroker -n 172.17.34.150:9876 -c ./conf/2m-2s-async/broker-a-s.properties >/var/log/mq.log &
tailf /var/log/mq.log
5、启动 Slave02
chmod a+x bin/mqbroker
nohup ./bin/mqbroker -n 172.17.34.150:9876 -c ./conf/2m-2s-async/broker-b-s.properties >/var/log/mq.log &
tailf /var/log/mq.log
四、查看启动端口
#netstat -tunpl |grep 9876
tcp 0 0 :::9876 :::* LISTEN 1303/java
五、关闭nameserver或broker
#sh ./mqshutdown
Useage: mqshutdown broker | namesrv
#sh mqshutdown broker
#sh mqshutdown namesrv