安装
[图片上传失败...(image-671e7e-1598427691641)]
rocketmq 镜像
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n6" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull apacherocketmq/rocketmq:4.5.0</pre>
broker
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n8" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull apacherocketmq/rocketmq:4.5.0</pre>
控制台
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n10" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull styletang/rocketmq-console-ng</pre>
docker-compose.yml
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="yaml" cid="n12" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">version: '3'
services:
namesrv:
image: apacherocketmq/rocketmq:4.5.0
container_name: rmqnamesrv
重启模式
restart: always
hostname: 你的ip
ports:
- 9876:9876
volumes: - ./data/namesrv/logs:/home/rocketmq/logs
command: sh mqnamesrv
enviroment:
TZ: Asia/Shanghai
broker:
image: apacherocketmq/rocketmq:4.5.0
hostname: 119.23.190.71
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes: - ./data/broker/logs:/home/rocketmq/logs
- ./data/broker/store:/home/rocketmq/store
- ./conf/broker.conf:/home/rocketmq/rocketmq-4.5.0/conf/broker.conf
command: sh mqbroker -n namesrv:9876 -c ../conf/broker.conf
depends_on: - namesrv
console:
image: styletang/rocketmq-console-ng
container_name: rocketmq-console-ng1
hostname: 你的ip
ports: - 8087:8080
depends_on: - namesrv
environment: - JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=你的ip:9876
- Dcom.rocketmq.sendMessageWithVIPChannel=false </pre>
broker.conf
<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n14" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">brokerClusterName = DefaultCluster # 设置broker的名字
brokerName = broker-a
master 0 slave用其他的
brokerId = 0
清理消息的时间
deleteWhen = 04
文件保留时长 默认48小时
fileReservedTime = 48
异步复制 SYNC_MASTER 同步复制
brokerRole = ASYNC_MASTER
刷盘策略 ASTNC_FLUSH 异步
SYNC_FLUSH 同步刷盘
flushDiskType = ASYNC_FLUSH
这个需要设置成 云主机 IP
brokerIP1 = 你的ip
listenProt= 10911
对外服务的端口 可以不设置</pre>
说明
这里需要注意 rocketmq broker 与 rokcetmq-console 都需要与 rokcetmq nameserver连接。使用 docker-compose 之后,上面三个 docker 容器将会一起编排,可以直接使用容器名代替容器 ip,如这里 nameserver 容器名 rmqnamesrv。
配置完成之后,运行 docker-compose up 启动三个容器,启动成功后,访问 ip:8087,查看 mq 外部控制台,如果可以看到以下信息
RocketMQ Broker 暴露的地址和端口(10909,10911)是基于容器的,会导致我们开发机无法连接,从而引发 org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout
异常
解决方案是在 broker.conf
配置文件中增加 brokerIP1=宿主机IP
即可