0

我想在我的机器上建立一个rocketmq集群,模式是主从,至于docker-compose

而且我只能同时启动一个经纪人。那就是说当我启动master时,slave退出,反之亦然,一些body可以帮忙吗?

这是我的 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

从代理配置

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 1
deleteWhen = 04
fileReservedTime = 48
listenPort = 10911

brokerRole = SLAVE
flushDiskType = ASYNC_FLUSH

从代理配置

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
listenPort = 10911
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH

当 broker slave 启动时,master 写入日志并退出;

========日志=======

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',
...
4

0 回答 0