docker-compose部署三组主从节点
作者:互联网
A、broker节点部署
1、所有的目录结构
.
├── conf
│ ├── broker-a-m-1.conf
│ ├── broker-a-s-1.conf
│ ├── broker-a-s-2.conf
│ ├── broker-b-m-1.conf
│ ├── broker-b-s-1.conf
│ ├── broker-b-s-2.conf
│ ├── broker-c-m-1.conf
│ ├── broker-c-s-1.conf
│ └── broker-c-s-2.conf
├── data
│ ├── broker-a-m-1
│ │ ├── data
│ │ │ ├── commitlog
│ │ │ │ ├── 00000000000000000000
│ │ │ │ └── 00000000001073741824
│ │ │ └── dledger_store
│ │ │ ├── abort
│ │ │ ├── checkpoint
│ │ │ ├── config
│ │ │ │ ├── consumerFilter.json
│ │ │ │ ├── consumerFilter.json.bak
│ │ │ │ ├── consumerOffset.json
│ │ │ │ ├── consumerOffset.json.bak
│ │ │ │ ├── delayOffset.json
│ │ │ │ ├── delayOffset.json.bak
│ │ │ │ ├── subscriptionGroup.json
│ │ │ │ ├── subscriptionGroup.json.bak
│ │ │ │ ├── topics.json
│ │ │ │ └── topics.json.bak
│ │ │ ├── consumequeue
│ │ │ │ ├── otc_wallet_transaction_topic
│ │ │ │ │ ├── 0
│ │ │ │ │ │ └── 00000000000000000000
│ │ │ │ │ ├── 1
│ │ │ │ │ │ └── 00000000000000000000
│ │ │ │ │ ├── 2
│ │ │ │ │ │ └── 00000000000000000000
│ │ │ │ │ └── 3
│ │ │ │ │ └── 00000000000000000000
│ │ │ │ ├── otc_withdraw_transaction_topic
│ │ │ │ │ ├── 0
│ │ │ │ │ │ └── 00000000000000000000
│ │ │ │ │ ├── 1
│ │ │ │ │ │ └── 00000000000000000000
│ │ │ │ │ └── 2
│ │ │ │ │ └── 00000000000000000000
│ │ │ │ └── RMQ_SYS_TRACE_TOPIC
│ │ │ │ ├── 0
│ │ │ │ │ └── 00000000000000000000
│ │ │ │ ├── 1
│ │ │ │ │ └── 00000000000000000000
│ │ │ │ ├── 2
│ │ │ │ │ └── 00000000000000000000
│ │ │ │ └── 3
│ │ │ │ └── 00000000000000000000
│ │ │ ├── index
│ │ │ │ └── 20211230141800368
│ │ │ └── lock
│ │ └── log
│ │ └── rocketmqlogs
│ │ ├── broker_default.log
│ │ ├── broker.log
│ │ ├── commercial.log
│ │ ├── filter.log
│ │ ├── lock.log
│ │ ├── otherdays
│ │ │ ├── remoting.1.log.gz
│ │ │ ├── remoting.2.log.gz
│ │ │ ├── stats.1.log.gz
│ │ │ ├── store.1.log.gz
│ │ │ ├── transaction.1.log.gz
│ │ │ ├── watermark.10.log.gz
│ │ │ ├── watermark.1.log.gz
│ │ │ ├── watermark.2.log.gz
│ │ │ ├── watermark.3.log.gz
│ │ │ ├── watermark.4.log.gz
│ │ │ ├── watermark.5.log.gz
│ │ │ ├── watermark.6.log.gz
│ │ │ ├── watermark.7.log.gz
│ │ │ ├── watermark.8.log.gz
│ │ │ └── watermark.9.log.gz
│ │ ├── protection.log
│ │ ├── remoting.log
│ │ ├── stats.log
│ │ ├── storeerror.log
│ │ ├── store.log
│ │ ├── transaction.log
│ │ └── watermark.log
│ ├── broker-b-s-2
│ │ ├── data
│ │ │ └── dledger_store
│ │ │ ├── abort
│ │ │ ├── checkpoint
│ │ │ ├── config
│ │ │ │ ├── consumerFilter.json
│ │ │ │ ├── consumerFilter.json.bak
│ │ │ │ ├── consumerOffset.json
│ │ │ │ ├── consumerOffset.json.bak
│ │ │ │ ├── delayOffset.json
│ │ │ │ ├── delayOffset.json.bak
│ │ │ │ ├── subscriptionGroup.json
│ │ │ │ ├── subscriptionGroup.json.bak
│ │ │ │ ├── topics.json
│ │ │ │ └── topics.json.bak
│ │ │ └── lock
│ │ └── log
│ │ └── rocketmqlogs
│ │ ├── broker_default.log
│ │ ├── broker.log
│ │ ├── commercial.log
│ │ ├── filter.log
│ │ ├── lock.log
│ │ ├── otherdays
│ │ │ ├── remoting.1.log.gz
│ │ │ ├── remoting.2.log.gz
│ │ │ ├── store.1.log.gz
│ │ │ ├── watermark.10.log.gz
│ │ │ ├── watermark.1.log.gz
│ │ │ ├── watermark.2.log.gz
│ │ │ ├── watermark.3.log.gz
│ │ │ ├── watermark.4.log.gz
│ │ │ ├── watermark.5.log.gz
│ │ │ ├── watermark.6.log.gz
│ │ │ ├── watermark.7.log.gz
│ │ │ ├── watermark.8.log.gz
│ │ │ └── watermark.9.log.gz
│ │ ├── protection.log
│ │ ├── remoting.log
│ │ ├── stats.log
│ │ ├── storeerror.log
│ │ ├── store.log
│ │ ├── transaction.log
│ │ └── watermark.log
│ ├── broker-c-s-1
│ │ ├── data
│ │ │ └── dledger_store
│ │ │ ├── abort
│ │ │ ├── checkpoint
│ │ │ ├── config
│ │ │ │ ├── consumerFilter.json
│ │ │ │ ├── consumerFilter.json.bak
│ │ │ │ ├── consumerOffset.json
│ │ │ │ ├── consumerOffset.json.bak
│ │ │ │ ├── delayOffset.json
│ │ │ │ ├── delayOffset.json.bak
│ │ │ │ ├── subscriptionGroup.json
│ │ │ │ ├── subscriptionGroup.json.bak
│ │ │ │ ├── topics.json
│ │ │ │ └── topics.json.bak
│ │ │ └── lock
│ │ └── log
│ │ └── rocketmqlogs
│ │ ├── broker_default.log
│ │ ├── broker.log
│ │ ├── commercial.log
│ │ ├── filter.log
│ │ ├── lock.log
│ │ ├── otherdays
│ │ │ ├── remoting.1.log.gz
│ │ │ ├── remoting.2.log.gz
│ │ │ ├── store.1.log.gz
│ │ │ ├── watermark.10.log.gz
│ │ │ ├── watermark.1.log.gz
│ │ │ ├── watermark.2.log.gz
│ │ │ ├── watermark.3.log.gz
│ │ │ ├── watermark.4.log.gz
│ │ │ ├── watermark.5.log.gz
│ │ │ ├── watermark.6.log.gz
│ │ │ ├── watermark.7.log.gz
│ │ │ ├── watermark.8.log.gz
│ │ │ └── watermark.9.log.gz
│ │ ├── protection.log
│ │ ├── remoting.log
│ │ ├── stats.log
│ │ ├── storeerror.log
│ │ ├── store.log
│ │ ├── transaction.log
│ │ └── watermark.log
│ └── namesrv
│ ├── data
│ └── log
│ └── rocketmqlogs
│ ├── namesrv_default.log
│ ├── namesrv.log
│ └── otherdays
│ ├── namesrv.1.log.gz
│ ├── namesrv.2.log.gz
│ ├── namesrv.3.log.gz
│ └── namesrv.4.log.gz
└── docker-compose.yaml
2、配置broker配置文件
1)主机一
a、编写broker docker-compose配置文件
[root@blockdb-192-168-7-61 rocketmq-cluster]# cat docker-compose.yaml
version: '3.5'
services:
namesrv:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: namesrv
restart: always
ports:
- 9876:9876
environment:
#内存分配
JAVA_OPT_EXT: "-server -Xms1g -Xmx1g"
volumes:
- ./data/namesrv/log:/root/logs
- ./data/namesrv/data:/root/store
command: sh mqnamesrv
networks:
rocketmq:
aliases:
- rmqnamesrv
broker-a-m-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-a-m-1
links:
- namesrv:namesrv
ports:
- 10909:10909
- 10911:10911
- 40911:40911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-a-m-1/log:/root/logs
- ./data/broker-a-m-1/data:/root/store
- ./conf/broker-a-m-1.conf:/opt/rocketmq-4.4.0/conf/broker-a-m-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-a-m-1.conf
networks:
rocketmq:
aliases:
- broker-a-m-1
broker-b-s-2:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-b-s-2
links:
- namesrv:namesrv
ports:
- 11909:11909
- 11911:11911
- 41911:41911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-b-s-2/log:/root/logs
- ./data/broker-b-s-2/data:/root/store
- ./conf/broker-b-s-2.conf:/opt/rocketmq-4.4.0/conf/broker-b-s-2.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-b-s-2.conf
networks:
rocketmq:
aliases:
- broker-b-s-2
broker-c-s-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-c-s-1
links:
- namesrv:namesrv
ports:
- 12909:12909
- 12911:12911
- 42911:42911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv1:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-c-s-1/log:/root/logs
- ./data/broker-c-s-1/data:/root/store
- ./conf/broker-c-s-1.conf:/opt/rocketmq-4.4.0/conf/broker-c-s-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-c-s-1.conf
networks:
rocketmq:
aliases:
- broker-c-s-1
networks:
rocketmq:
name: rocketmq
driver: bridge
b、编写conf配置文件
master-a-1
[root@blockdb-192-168-7-61 rocketmq-cluster]# cat conf/broker-a-m-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
brokerIP1=192.168.7.61
brokerIP2=192.168.7.61
brokerIP3=192.168.7.61
namesrvAddr=192.168.7.61:9876;192.168.7.62:9876;192.168.7.63:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-a
dLegerPeers=n0-192.168.7.61:40911;n1-192.168.7.62:40911;n2-192.168.7.63:40911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n0
slaver-b-s-2
[root@blockdb-192-168-7-61 rocketmq-cluster]# cat conf/broker-b-s-2.conf
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=2
brokerIP1=192.168.7.61
brokerIP2=192.168.7.61
brokerIP3=192.168.7.61
namesrvAddr=192.168.7.62:9876;192.168.7.63:9876;192.168.7.61:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=11911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-b
dLegerPeers=n0-192.168.7.62:41911;n1-192.168.7.63:41911;n2-192.168.7.61:41911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n2
slaver-c-s-1
[root@blockdb-192-168-7-61 rocketmq-cluster]# cat conf/broker-c-s-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-c
brokerId=1
brokerIP1=192.168.7.61
brokerIP2=192.168.7.61
brokerIP3=192.168.7.61
namesrvAddr=192.168.7.63:9876;192.168.7.61:9876;192.168.7.62:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=12911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-c
dLegerPeers=n0-192.168.7.63:42911;n1-192.168.7.61:42911;n2-192.168.7.62:42911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n1
2)主机二
a、配置docker-compose配置文件
[root@blockdb-192-168-7-62 rocketmq-cluster]# cat docker-compose.yaml
version: '3.5'
services:
namesrv:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: namesrv
restart: always
ports:
- 9876:9876
environment:
#内存分配
JAVA_OPT_EXT: "-server -Xms1g -Xmx1g"
volumes:
- ./data/namesrv/log:/root/logs
- ./data/namesrv/data:/root/store
command: sh mqnamesrv
networks:
rocketmq:
aliases:
- rmqnamesrv
broker-b-m-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-b-m-1
links:
- namesrv:namesrv
ports:
- 11909:11909
- 11911:11911
- 41911:41911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-b-m-1/log:/root/logs
- ./data/broker-b-m-1/data:/root/store
- ./conf/broker-b-m-1.conf:/opt/rocketmq-4.4.0/conf/broker-b-m-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-b-m-1.conf
networks:
rocketmq:
aliases:
- broker-b-m-1
broker-c-s-2:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-c-s-2
links:
- namesrv:namesrv
ports:
- 12909:12909
- 12911:12911
- 42911:42911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-c-s-2/log:/root/logs
- ./data/broker-c-s-2/data:/root/store
- ./conf/broker-c-s-2.conf:/opt/rocketmq-4.4.0/conf/broker-c-s-2.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-c-s-2.conf
networks:
rocketmq:
aliases:
- broker-c-s-2
broker-a-s-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-a-s-1
links:
- namesrv:namesrv
ports:
- 10909:10909
- 10911:10911
- 40911:40911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-a-s-1/log:/root/logs
- ./data/broker-a-s-1/data:/root/store
- ./conf/broker-a-s-1.conf:/opt/rocketmq-4.4.0/conf/broker-a-s-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-a-s-1.conf
networks:
rocketmq:
aliases:
- broker-a-s-1
networks:
rocketmq:
name: rocketmq
driver: bridge
b、配置broker conf配置文件
master-b-1
[root@blockdb-192-168-7-62 rocketmq-cluster]# cat conf/broker-b-m-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
brokerIP1=192.168.7.62
brokerIP2=192.168.7.62
brokerIP3=192.168.7.62
namesrvAddr=192.168.7.62:9876;192.168.7.63:9876;192.168.7.61:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=11911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-b
dLegerPeers=n0-192.168.7.62:41911;n1-192.168.7.63:41911;n2-192.168.7.61:41911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n0
slaver-c-s-2
[root@blockdb-192-168-7-62 rocketmq-cluster]# cat conf/broker-c-s-2.conf
brokerClusterName=DefaultCluster
brokerName=broker-c
brokerId=2
brokerIP1=192.168.7.62
brokerIP2=192.168.7.62
brokerIP3=192.168.7.62
namesrvAddr=192.168.7.63:9876;192.168.7.61:9876;192.168.7.62:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=12911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-c
dLegerPeers=n0-192.168.7.63:42911;n1-192.168.7.61:42911;n2-192.168.7.62:42911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n2
slaver-a-s-1
[root@blockdb-192-168-7-62 rocketmq-cluster]# cat conf/broker-a-s-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
brokerIP1=192.168.7.62
brokerIP2=192.168.7.62
brokerIP3=192.168.7.62
namesrvAddr=192.168.7.61:9876;192.168.7.62:9876;192.168.7.63:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=10911
deleteWhen=04
fileReservedTime=48
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-a
dLegerPeers=n0-192.168.7.61:40911;n1-192.168.7.62:40911;n2-192.168.7.63:40911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n1
3)主机三
a、配置编写docker-compose配置文件
[root@blockdb-192-168-7-63 rocketmq-cluster]# cat docker-compose.yaml
version: '3.5'
services:
namesrv:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: namesrv
restart: always
ports:
- 9876:9876
environment:
#内存分配
JAVA_OPT_EXT: "-server -Xms1g -Xmx1g"
volumes:
- ./data/namesrv/log:/root/logs
- ./data/namesrv/data:/root/store
command: sh mqnamesrv
networks:
rocketmq:
aliases:
- rmqnamesrv
broker-c-m-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-c-m-1
links:
- namesrv:namesrv
ports:
- 12909:12909
- 12911:12911
- 42911:42911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-c-m-1/log:/root/logs
- ./data/broker-c-m-1/data:/root/store
- ./conf/broker-c-m-1.conf:/opt/rocketmq-4.4.0/conf/broker-c-m-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-c-m-1.conf
networks:
rocketmq:
aliases:
- broker-c-m-1
broker-a-s-2:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-a-s-2
links:
- namesrv:namesrv
ports:
- 10909:10909
- 10911:10911
- 40911:40911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-a-s-2/log:/root/logs
- ./data/broker-a-s-2/data:/root/store
- ./conf/broker-a-s-2.conf:/opt/rocketmq-4.4.0/conf/broker-a-s-2.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-a-s-2.conf
networks:
rocketmq:
aliases:
- broker-a-s-2
broker-b-s-1:
image: harbor-test.aitdcoin.com/library/rocketmq:4.4.0
container_name: broker-b-s-1
links:
- namesrv:namesrv
ports:
- 11909:11909
- 11911:11911
- 41911:41911
environment:
TZ: Asia/Shanghai
NAMESRV_ADDR: "namesrv1:9876"
JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
volumes:
- ./data/broker-b-s-1/log:/root/logs
- ./data/broker-b-s-1/data:/root/store
- ./conf/broker-b-s-1.conf:/opt/rocketmq-4.4.0/conf/broker-b-s-1.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker-b-s-1.conf
networks:
rocketmq:
aliases:
- broker-b-s-1
networks:
rocketmq:
name: rocketmq
driver: bridge
b、配置conf配置文件
master-c-m-1
[root@blockdb-192-168-7-63 rocketmq-cluster]# cat conf/broker-c-m-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-c
brokerId=0
brokerIP1=192.168.7.63
brokerIP2=192.168.7.63
brokerIP1=192.168.7.63
namesrvAddr=192.168.7.63:9876;192.168.7.61:9876;192.168.7.62:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=12911
deleteWhen=04
fileReservedTime=24
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-c
dLegerPeers=n0-192.168.7.63:42911;n1-192.168.7.61:42911;n2-192.168.7.62:42911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n0
slaver-a-s-2
[root@blockdb-192-168-7-63 rocketmq-cluster]# cat conf/broker-a-s-2.conf
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=2
brokerIP1=192.168.7.63
brokerIP2=192.168.7.63
brokerIP2=192.168.7.63
namesrvAddr=192.168.7.61:9876;192.168.7.62:9876;192.168.7.63:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=10911
deleteWhen=04
fileReservedTime=48
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-a
dLegerPeers=n0-192.168.7.61:40911;n1-192.168.7.62:40911;n2-192.168.7.63:40911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n2
slaver-b-s-1
[root@blockdb-192-168-7-63 rocketmq-cluster]# cat conf/broker-b-s-1.conf
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
brokerIP1=192.168.7.63
brokerIP2=192.168.7.63
brokerIP3=192.168.7.63
namesrvAddr=192.168.7.62:9876;192.168.7.63:9876;192.168.7.61:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=false
autoCreateSubscriptionGroup=false
listenPort=11911
deleteWhen=04
fileReservedTime=48
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=75%
maxMessageSize=65536
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
# 与 dledger 相关的属性
enableDLegerCommitLog=true
dLegerGroup=broker-b
dLegerPeers=n0-192.168.7.62:41911;n1-192.168.7.63:41911;n2-192.168.7.61:41911
storePathRootDir=/root/store/dledger_store
dLegerSelfId=n1
3、启动docker-compose服务
单台机器上都执行启动命令
[root@blockdb-192-168-7-62 rocketmq-cluster]# docker-compose up -d
4、查看服务启动容器
[root@blockdb-192-168-7-61 rocketmq-cluster]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
broker-a-m-1 sh mqbroker -c /opt/rocket ... Up 0.0.0.0:10909->10909/tcp,:::10909->10909/tcp, 0.0.0.0:10911->10911/tcp,:::10911->10911/tcp, 0.0.0.0:40911->40911/tcp,:::40911->40911/tcp, 9876/tcp
broker-b-s-2 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:11909->11909/tcp,:::11909->11909/tcp, 0.0.0.0:11911->11911/tcp,:::11911->11911/tcp, 0.0.0.0:41911->41911/tcp,:::41911->41911/tcp, 9876/tcp
broker-c-s-1 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:12909->12909/tcp,:::12909->12909/tcp, 0.0.0.0:12911->12911/tcp,:::12911->12911/tcp, 0.0.0.0:42911->42911/tcp,:::42911->42911/tcp, 9876/tcp
namesrv sh mqnamesrv Up 10909/tcp, 10911/tcp, 0.0.0.0:9876->9876/tcp,:::9876->9876/tcp
[root@blockdb-192-168-7-62 rocketmq-cluster]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
broker-a-s-1 sh mqbroker -c /opt/rocket ... Up 0.0.0.0:10909->10909/tcp,:::10909->10909/tcp, 0.0.0.0:10911->10911/tcp,:::10911->10911/tcp, 0.0.0.0:40911->40911/tcp,:::40911->40911/tcp, 9876/tcp
broker-b-m-1 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:11909->11909/tcp,:::11909->11909/tcp, 0.0.0.0:11911->11911/tcp,:::11911->11911/tcp, 0.0.0.0:41911->41911/tcp,:::41911->41911/tcp, 9876/tcp
broker-c-s-2 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:12909->12909/tcp,:::12909->12909/tcp, 0.0.0.0:12911->12911/tcp,:::12911->12911/tcp, 0.0.0.0:42911->42911/tcp,:::42911->42911/tcp, 9876/tcp
namesrv sh mqnamesrv Up 10909/tcp, 10911/tcp, 0.0.0.0:9876->9876/tcp,:::9876->9876/tcp
[root@blockdb-192-168-7-63 rocketmq-cluster]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
broker-a-s-2 sh mqbroker -c /opt/rocket ... Up 0.0.0.0:10909->10909/tcp,:::10909->10909/tcp, 0.0.0.0:10911->10911/tcp,:::10911->10911/tcp, 0.0.0.0:40911->40911/tcp,:::40911->40911/tcp, 9876/tcp
broker-b-s-1 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:11909->11909/tcp,:::11909->11909/tcp, 0.0.0.0:11911->11911/tcp,:::11911->11911/tcp, 0.0.0.0:41911->41911/tcp,:::41911->41911/tcp, 9876/tcp
broker-c-m-1 sh mqbroker -c /opt/rocket ... Up 10909/tcp, 10911/tcp, 0.0.0.0:12909->12909/tcp,:::12909->12909/tcp, 0.0.0.0:12911->12911/tcp,:::12911->12911/tcp, 0.0.0.0:42911->42911/tcp,:::42911->42911/tcp, 9876/tcp
namesrv sh mqnamesrv Up 10909/tcp, 10911/tcp, 0.0.0.0:9876->9876/tcp,:::9876->9876/tcp
此时我们集群部署完毕
B、部署控制台
1、目录结构
[root@blockdb-192-168-7-61 rocketmq-console]# tree
.
├── console
│ └── logs
│ └── consolelogs
│ ├── rocketmq-console-2022-01-13.0.log
│ └── rocketmq-console.log
└── docker-compose.yaml
3 directories, 3 files
2、编写docker-compose配置文件
[root@blockdb-192-168-7-61 rocketmq-console]# cat docker-compose.yaml
version: '3.5'
services:
rmqconsole:
image: harbor-test.aitdcoin.com/library/rocketmq-console-ng:1.0.0
container_name: rocketmq-console
restart: always
ports:
- 18181:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- ./console/logs:/root/logs
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=192.168.7.61:9876;192.168.7.62:9876;192.168.7.63:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
3、启动docker-compose
启动命令
[root@blockdb-192-168-7-61 rocketmq-console]# docker-compose up -d
4、查看服务启动情况
[root@blockdb-192-168-7-61 rocketmq-console]# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------------
rocketmq-console sh -c java $JAVA_OPTS -jar ... Up 0.0.0.0:18181->8080/tcp,:::18181->8080/tcp
5、web控制台界面查看集群运行情况
web访问地址:http://192.168.7.61:18181/#/
1)ops列表
2)、cluster集群列表
标签:compose,log,broker,tcp,192.168,conf,docker,三组,rocketmq 来源: https://blog.csdn.net/baidu_38432732/article/details/122673423