一、拉取镜像
docker pull rocketmqinc/rocketmq
二、设置网段
docker network create --driver bridge --subnet=172.10.0.0/16 --gateway=172.10.0.1 rmqnet
firewall-cmd --zone=trusted --add-source=172.10.0.1/16 --permanent
firewall-cmd --reload
三、配置 docker-compose
version: '3.8'
services:
rmqnamesrv:
image: rocketmqinc/rocketmq
container_name: rmqnamesrv
ports:
- 9876:9876
volumes:
- /data/docker/logs/rocketmq:/root/logs
- /data/docker/rocketmq/store:/root/store
command: ./mqnamesrv
networks:
default:
ipv4_address: 172.10.0.14
rmqbroker:
image: rocketmqinc/rocketmq
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- /data/docker/logs/rocketmq:/root/logs
- /data/docker/rocketmq/store:/root/store
- /data/docker/rocketmq/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf
environment:
NAMESRV_ADDR: "172.10.0.14:9876"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: ./mqbroker -c ../conf/broker.conf
depends_on:
- rmqnamesrv
networks:
default:
ipv4_address: 172.10.0.15
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 9999:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=172.10.0.14:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
networks:
default:
ipv4_address: 172.10.0.16
networks:
default:
external:
name: rmqnet
四、设置 broker.conf,
## vi /data/docker/rocketmq/conf/broker.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
autoCreateTopicEnable=true
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1=172.10.0.15
namesrvAddr=172.10.0.14:9876
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
五、启动
# 启动
docker-compose up -d
#进入容器测试
docker exec -it rmqbroker bash
// 生产消息
./tools.sh org.apache.rocketmq.example.quickstart.Producer
// 消费消息
./tools.sh org.apache.rocketmq.example.quickstart.Consumer
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于