'Building a rocketmq cluster with docker-compose, managing which broker is in control
I want build a rocketmq cluster on my machine, where the mode is master-slave, with docker-compose
And I can only start one broker at the same time. That say when I start master, slave exits. The opposite is also, can some body help?
Here is my docker-compose.yml
version: '2'
services:
namesrv:
image: rocketmqinc/rocketmq:4.5.0-alpine
ports:
- 9876:9876
volumes:
- "/data/namesrv/master/logs:/opt/logs"
- "/data/namesrv/master/store:/opt/store"
environment:
MAX_POSSIBLE_HEAP: 100000000
command: sh mqnamesrv
broker-a-m:
image: rocketmqinc/rocketmq:4.5.0-alpine
ports:
- 10909:10909
- 10911:10911
volumes:
- "/data/broker-a/logs:/opt/logs"
- "/data/broker-a/store:/opt/store"
- "/data/broker-a/conf:/opt/conf"
links:
- namesrv:namesrv
environment:
NAMESRV_ADDR: namesrv:9876
command: sh mqbroker -c /opt/conf/broker.conf
broker-a-s:
image: rocketmqinc/rocketmq:4.5.0-alpine
ports:
- 11909:10909
- 11911:10911
volumes:
- "/data/broker-a-slave/logs:/opt/logs"
- "/data/broker-a-slave/store:/opt/store"
- "/data/broker-a-slave/conf:/opt/conf"
links:
- namesrv:namesrv
environment:
NAMESRV_ADDR: namesrv:9876
command: sh mqbroker -c /opt/conf/broker.conf
slave broker conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 1
deleteWhen = 04
fileReservedTime = 48
listenPort = 10911
brokerRole = SLAVE
flushDiskType = ASYNC_FLUSH
slave broker conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
listenPort = 10911
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
when broker slave starts, the master writes the log and exits;
========log=======
broker-a-m_1 | The broker[broker-a, broker-a-m:10911] boot success. serializeType=JSON and name server is namesrv:9876
broker-a-m_1 | Killed
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('4d69ef2838f4f719e9cbf43c7cfc6d79382d356ecba88b610278eea11b9d0bfd')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('4d69ef2838f4f719e9cbf43c7cfc6d79382d356ecba88b610278eea11b9d0bfd')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/4d69ef2838f4f719e9cbf43c7cfc6d79382d356ecba88b610278eea11b9d0bfd/wait HTTP/1.1" 200 32
compose.cli.verbose_proxy.proxy_callable: docker wait -> {'Error': None, 'StatusCode': 137}
rockermq_broker-a-m_1 exited with code 137
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/4d69ef2838f4f719e9cbf43c7cfc6d79382d356ecba88b610278eea11b9d0bfd/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
'Args': ['mqbroker', '-c', '/opt/conf/broker.conf'],
'Config': {'AttachStderr': False,
'AttachStdin': False,
'AttachStdout': False,
'Cmd': ['sh', 'mqbroker', '-c', '/opt/conf/broker.conf'],
'Domainname': '',
'Entrypoint': None,
'Env': ['NAMESRV_ADDR=namesrv:9876',
'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin',
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|