Step-by-Step Deployment of a Dual‑Master Dual‑Slave RocketMQ Cluster
This guide details how to set up a high‑availability RocketMQ cluster with two name servers and four brokers across two Linux hosts, covering directory preparation, configuration file edits, service startup commands, and verification of the deployment.
This article provides a complete walkthrough for deploying a RocketMQ cluster in a dual‑master dual‑slave configuration using two servers (192.168.20.40 and 192.168.20.43). The cluster consists of two name‑server instances and four broker instances.
1. Create required directories on each host
On 192.168.20.40:
[root@k8s-master ~]# mkdir /usr/local/rocketmq/store/ [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-a [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-a/commitlog [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-b [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-b/commitlog [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-as [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-as/commitlog [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-bs [root@k8s-master ~]# mkdir /usr/local/rocketmq/store/broker-bs/commitlogOn 192.168.20.43 repeat the same set of mkdir commands (adjusting the host name in the prompt).
2. Edit broker configuration files
Navigate to the configuration directory:
[root@k8s-master 2m-2s-sync]# cd /usr/local/rocketmq/conf/2m-2s-sync/Example broker-a.properties content:
brokerClusterName=rocketmq-cluster brokerName=broker-a brokerId=0 deleteWhen=04 fileReservedTime=48 brokerRole=SYNC_MASTER flushDiskType=ASYNC_FLUSH listenPort=10911 storePathRootDir=/usr/local/rocketmq/store/broker-a storePathCommitLog=/usr/local/rocketmq/store/broker-a/commitlogSimilarly edit broker-a-s.properties , broker-b.properties , and broker-b-s.properties with appropriate brokerId , brokerRole (MASTER or SLAVE), ports, and storage paths as shown in the source.
3. Start the services
Start both name‑servers on each host:
[root@k8s-master bin]# nohup sh mqnamesrv & [root@k8s-node2 bin]# nohup sh mqnamesrv &Start the brokers:
[root@k8s-master bin]# nohup sh mqbroker -n '192.168.20.40:9876;192.168.20.39:9876' -c /usr/local/rocketmq/conf/2m-2s-sync/broker-a.properties & [root@k8s-node2 bin]# nohup sh mqbroker -n '192.168.20.40:9876;192.168.20.39:9876' -c /usr/local/rocketmq/conf/2m-2s-sync/broker-a-s.properties & [root@k8s-node2 bin]# nohup sh mqbroker -n '192.168.20.40:9876;192.168.20.39:9876' -c /usr/local/rocketmq/conf/2m-2s-sync/broker-b.properties & [root@k8s-master bin]# nohup sh mqbroker -n '192.168.20.40:9876;192.168.20.39:9876' -c /usr/local/rocketmq/conf/2m-2s-sync/broker-b-s.properties &Each command returns a background job ID (e.g., [1] 8048 ).
4. Verify the deployment
Check that both name‑servers and all four brokers are running on each machine. The article includes screenshots of ps or monitoring output (images omitted here for brevity).
After confirming the services, the RocketMQ cluster is ready for use.
--- End of guide ---
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.