Docker部署RocketMQ双主双从模式(在一台机子上部署)
结构图
Broker 常用配置参数
以下属性仅做说明使用
1 | #所属集群名字 |
获取相关镜像
创建持久化目录
rocketmq
1 | # 创建 NameServer 持久化目录 |
rocketmq_2
1 | # 创建 NameServer 持久化目录 |
修改 Broker 配置文件
rocketmq/broker/broker.conf
1 | brokerClusterName = DefaultCluster |
rocketmq/broker-slave/broker.conf
1 | brokerClusterName = DefaultCluster |
rocketmq_2/broker/broker.conf
1 | brokerClusterName = DefaultCluster |
rocketmq_2/broker-slave/broker.conf
1 | brokerClusterName = DefaultCluster |
启动NameServer
rocketmq
1 | docker run -d -p 9876:9876 -v /usr/local/docker/rocketmq/namesrv/logs:/root/logs -v /usr/local/docker/rocketmq/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq sh mqnamesrv |
rocketmq_2
1 | docker run -d -p 9877:9876 -v /usr/local/docker/rocketmq_2/namesrv/logs:/root/logs -v /usr/local/docker/rocketmq_2/namesrv/store:/root/store --name rmqnamesrv_2 -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq sh mqnamesrv |
启动Broker
rocketmq master-a
1 | docker run -d -p 10909:10909 -p 10911:10911 -p 10912:10912 -v /usr/local/docker/rocketmq/broker/logs:/root/logs -v /usr/local/docker/rocketmq/broker/store:/root/store -v /usr/local/docker/rocketmq/broker/broker.conf:/opt/rocketmq/conf/broker.conf --name rmqbroker-master --link rmqnamesrv:namesrv -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq/conf/broker.conf |
rocketmq_2 slave-a
1 | docker run -d -p 11909:11909 -p 11911:11911 -p 11912:11912 -v /usr/local/docker/rocketmq_2/broker-slave/logs:/root/logs -v /usr/local/docker/rocketmq_2/broker-slave/store:/root/store -v /usr/local/docker/rocketmq_2/broker-slave/broker.conf:/opt/rocketmq/conf/broker.conf --name rmqbroker_2-slave --link rmqnamesrv_2:namesrv -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq/conf/broker.conf |
ocketmq_2 master-b
1 | docker run -d -p 12909:10909 -p 12911:10911 -p 12912:10912 -v /usr/local/docker/rocketmq_2/broker/logs:/root/logs -v /usr/local/docker/rocketmq_2/broker/store:/root/store -v /usr/local/docker/rocketmq_2/broker/broker.conf:/opt/rocketmq/conf/broker.conf --name rmqbroker_2-master --link rmqnamesrv_2:namesrv -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq/conf/broker.conf |
rocketmq slave-b
1 | docker run -d -p 13909:11909 -p 13911:11911 -p 13912:11912 -v /usr/local/docker/rocketmq/broker-slave/logs:/root/logs -v /usr/local/docker/rocketmq/broker-slave/store:/root/store -v /usr/local/docker/rocketmq/broker-slave/broker.conf:/opt/rocketmq/conf/broker.conf --name rmqbroker-slave --link rmqnamesrv:namesrv -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq/conf/broker.conf |
启动控制台
1 | docker run -d -p 8083:8080 -e "JAVA_OPTS=-Drocketmq.config.namesrvAddr=192.168.198.200:9876;192.168.198.200:9877 -Drocketmq.config.isVIPChannel=false" --name rocketmq-console-ng styletang/rocketmq-console-ng |