作者:355301_01c00c | 来源:互联网 | 2023-08-11 14:19
部署Broketrmq集群通过docker-compose形式部署首先创建broker配置文件,配置文件如下:brokerClusterName DefaultCluster
部署Broketrmq集群
通过docker-compose形式部署
brokerClusterName = DefaultCluster #集群名brokerName = broker-a #node名,集群内唯一brokerId = 0 #配置节点是主还是从,0为主,1为从deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = SYNC_FLUSH
listenPort = 10911
namesrvAddr=10.228.83.120:9876 #配置namesrvAddr注册中心地址autoCreateTopicEnable=true #配置是否自动创建 TopicautoCreateSubscriptiOnGroup=true #配置是否自动创建 SubscriptionGroup 订阅组storePathRootDir=/home/rocketmq/store #配置数据存储位置,持久化使用storePathCommitLog=/home/rocketmq/store/commitlog #配置日志存储位置brokerIP1=10.228.83.120 #配置主机IP地址
配置文件参考
- 创建yml文件,
vim docker-compose.yml
,配置文件如下:
version: '2'services:
namesrv:
image: rocketmqinc/rocketmq container_name: rmqnamesrv ports:
- 9876:9876
volumes:
- /opt/namesrv/logs:/home/rocketmq/logs - /opt/namesrv/store:/home/rocketmq/store command: sh mqnamesrv broker:
image: rocketmqinc/rocketmq container_name: rmqbroker ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- /opt/rocketmq/logs:/home/rocketmq/logs - /opt/rocketmq/store:/home/rocketmq/store - /opt/rocketmq/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf command: sh mqbroker -n rmqnamesrv:9876 autoCreateTopicEnable=true -c ../conf/broker.conf &
depends_on:
- namesrv environment:
- JAVA_HOME=/usr/lib/jvm/jre console:
image: styletang/rocketmq-console-ng container_name: rocketmq-console-ng ports:
- 8087:8080
depends_on:
- namesrv environment:
- JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=rmqnamesrv:9876
- Dcom.rocketmq.sendMessageWithVIPChannel=false
console 可不部署,就是一个可视化的web界面。可作为集群是否部署成功的一个参考,如下:
参考之前docker-compose.yml
配置,创建相关broker文件夹
参考之前broker
配置,创建broker配置文件
参考之前docker-compose.yml
配置,编写docker run
命令,命令样例如下:
docker run -itd --name rmqbroker_d --privileged -p 10929:10909 -p 10931:10911 -p 10932:10912 -v /opt/rocketmq_c/logs:/home/rocketmq/logs -v /opt/rocketmq_c/store:/home/rocketmq/store -v /opt/rocketmq_c/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf -e "JAVA_OPT_EXT=-server -Xms2048m -Xmx2048m -Xmn2048m" rocketmqinc/rocketmq sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
-e "JAVA_OPT_EXT=-server -Xms2048m -Xmx2048m -Xmn2048m"
此参数待考证可不加,与同主机添加的不同就是网络模式指定的不同
- 参考之前
docker-compose.yml
配置,创建相关broker文件夹 - 参考之前
broker
配置,创建broker配置文件 - 参考之前
docker-compose.yml
配置,编写docker run
命令,命令样例如下:
结束!!!
参考链接
参考一
参考二
参考三
参考四
参考五