介绍 RocketMQ的多Master多Slave的模式在Linux服务器部署案例进行详细的说明。
部署步骤 主机环境:
Nameserver1 + Master1 + Master2-Slave:192.168.40.100
Nameserver2 + Master2 + Master1-Slave:192.168.40.101
系统环境:
64位JDK 1.8+;
Maven 3.6.x;
git;
操作步骤:
全部安装jdk
全部安装maven
全部安装RocketMQ,修改配置
安装web管理服务
jdk安装 jdk安装跳转
maven安装 maven安装跳转
RocketMQ分布式安装 下载
RocketMQ安装参考 两台主机按文档安装
创建数据目录
在192.168.40.100操作
1 2 3 4 mkdir -p /data/rocketmq/data/{commitlog,consumequeue,index} mkdir -p /data/rocketmq/datas/{commitlog,consumequeue,index}
在192.168.40.101操作
1 2 3 4 mkdir -p /data/rocketmq/data/{commitlog,consumequeue,index} mkdir -p /data/rocketmq/datas/{commitlog,consumequeue,index}
修改配置文件
在192.168.40.100操作
1 2 vim /data/rocketmq/conf/2m-2s-async/broker-a.properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 brokerClusterName=rocketmq-cluster brokerName=broker-a brokerId=0 namesrvAddr=192.168.40.100:9876;192.168.40.101:9876 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true listenPort=10911 haListenPort=10912 deleteWhen=04 fileReservedTime=18 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=300000 diskMaxUsedSpaceRatio=88 storePathRootDir=/mnt/rocketmq-all-4.6.0-bin-release/data storePathCommitLog=/mnt/rocketmq-all-4.6.0-bin-release/data/commitlog storePathConsumeQueue=/mnt/rocketmq-all-4.6.0-bin-release/data/consumequeue storePathIndex=/mnt/rocketmq-all-4.6.0-bin-release/data/index storeCheckpoint=/mnt/rocketmq-all-4.6.0-bin-release/data/checkpoint abortFile=/mnt/rocketmq-all-4.6.0-bin-release/data/abort maxMessageSize=65536 brokerRole=SYNC_MASTER flushDiskType=ASYNC_FLUSH brokerIP1=192.168.40.100
1 2 vim /data/rocketmq/conf/2m-2s-async/broker-b-s.properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 brokerClusterName=rocketmq-cluster brokerName=broker-b brokerId=1 namesrvAddr=192.168.40.100:9876;192.168.40.101:9876 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true listenPort=10923 haListenPort=10924 deleteWhen=04 fileReservedTime=18 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=300000 diskMaxUsedSpaceRatio=88 storePathRootDir=/mnt/rocketmq-all-4.6.0-bin-release/datas storePathCommitLog=/mnt/rocketmq-all-4.6.0-bin-release/datas/commitlog storePathConsumeQueue=/mnt/rocketmq-all-4.6.0-bin-release/datas/consumequeue storePathIndex=/mnt/rocketmq-all-4.6.0-bin-release/datas/index storeCheckpoint=/mnt/rocketmq-all-4.6.0-bin-release/datas/checkpoint abortFile=/mnt/rocketmq-all-4.6.0-bin-release/datas/abort maxMessageSize=65536 brokerRole=SLAVE flushDiskType=ASYNC_FLUSH brokerIP1=192.168.40.100
在192.168.40.101操作
1 2 vim /data/rocketmq/conf/2m-2s-async/broker-b.properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 brokerClusterName=rocketmq-cluster brokerName=broker-b brokerId=0 namesrvAddr=192.168.40.100:9876;192.168.40.101:9876 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true listenPort=10911 haListenPort=10912 deleteWhen=04 fileReservedTime=18 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=300000 diskMaxUsedSpaceRatio=88 storePathRootDir=/mnt/rocketmq-all-4.6.0-bin-release/data storePathCommitLog=/mnt/rocketmq-all-4.6.0-bin-release/data/commitlog storePathConsumeQueue=/mnt/rocketmq-all-4.6.0-bin-release/data/consumequeue storePathIndex=/mnt/rocketmq-all-4.6.0-bin-release/data/index storeCheckpoint=/mnt/rocketmq-all-4.6.0-bin-release/data/checkpoint abortFile=/mnt/rocketmq-all-4.6.0-bin-release/data/abort maxMessageSize=65536 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH brokerIP1=192.168.40.101
1 2 vim /data/rocketmq/conf/2m-2s-async/broker-b.properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 brokerClusterName=rocketmq-cluster brokerName=broker-a brokerId=1 namesrvAddr=192.168.40.100:9876;192.168.40.101:9876 defaultTopicQueueNums=4 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true listenPort=10923 haListenPort=10924 deleteWhen=04 fileReservedTime=18 mapedFileSizeCommitLog=1073741824 mapedFileSizeConsumeQueue=300000 diskMaxUsedSpaceRatio=88 storePathRootDir=/mnt/rocketmq-all-4.6.0-bin-release/datas storePathCommitLog=/mnt/rocketmq-all-4.6.0-bin-release/datas/commitlog storePathConsumeQueue=/mnt/rocketmq-all-4.6.0-bin-release/datas/consumequeue storePathIndex=/mnt/rocketmq-all-4.6.0-bin-release/datas/index storeCheckpoint=/mnt/rocketmq-all-4.6.0-bin-release/datas/checkpoint abortFile=/mnt/rocketmq-all-4.6.0-bin-release/datas/abort maxMessageSize=65536 brokerRole=SLAVE flushDiskType=ASYNC_FLUSH brokerIP1=192.168.40.101
启动Nameserver
在192.168.40.100操作
1 2 cd /data/rocketmq/ nohup sh bin/mqnamesrv &
在192.168.40.101操作
1 2 cd /data/rocketmq/ nohup sh bin/mqnamesrv &
启动Broker
在192.168.40.100操作
1 2 3 cd /data/rocketmq/bin sh mqbroker -c /data/rocketmq/conf/2m-2s-async/broker-a.properties sh mqbroker -c /data/rocketmq/conf/2m-2s-async/broker-b-s.properties
在192.168.40.101操作
1 2 3 cd /data/rocketmq/bin sh mqbroker -c /data/rocketmq/conf/2m-2s-async/broker-a-s.properties sh mqbroker -c /data/rocketmq/conf/2m-2s-async/broker-b.properties
RocketMQ监控平台部署 下载
在192.168.40.100操作
1 2 3 yum -y install gitcd /opt git clone https://github.com/apache/rocketmq-externals.git
配置
1 2 3 cd rocketmq-externals/rocketmq-console/src/main/resources/ vim application.properties
1 rocketmq.config.namesrvAddr=192.168.40.100:9876;192.168.40.101:9876
编译
1 mvn clean package -Dmaven.test.skip=true
运行
1 2 cd /opt/rocketmq-externals-master/rocketmq-console/target java -jar target/rocketmq-console-ng-1.0.1.jar
访问
1 curl http://192.168.40.100:8080/
在监控平台查看:集群选项,即可看到集群信息。