Tag Archives: MQ already started

Lock failed, MQ already started [How to Solve]

preface

Just contacted rocketmq and used it on the win10 platform. There are too many things that you forget how to use. Now record these things

 

 

Check several questions

How to start mqbroker

Direct start

$mqpath> bin\mqbroker.cmd conf\you_special_config.properties

Use the start command

$mqpath> bin\mqbroker.cmd conf\you_special_config.properties

There is no essential difference between the two startup methods, but using the start command will reopen a CMD page for the program, which is more convenient

Use action item or not: - C

$mqpath> bin\mqbroker.cmd -h
usage: mqbroker [-c <arg>] [-h] [-m] [-n <arg>] [-p]
 -c,--configFile <arg>       Broker config properties file
 -h,--help                   Print help
 -m,--printImportantConfig   Print important config item
 -n,--namesrvAddr <arg>      Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876
 -p,--printConfigItem        Print all config item
"Broker starts OK"

With operation item

With operation items, you can use some custom configurations

Generally, in the cluster, you need to bring operation items and use your own configuration

No action items

Without action items, some configurations of the default configuration are used

In this case, start two brokers , and basically report lock failed and MQ ready started in the second broker

Because the same default configuration is used (starting only one broker is not affected)

Use a different profile

Different configurations meet the most basic requirements

brokername different

brokerid different

listenport different

storepathrootdir different

Same configuration

Similar to the case of without operation item , it will cause lock failed and MQ ready started

 

 

Solution:

Use the start command

Use action items - C

Use a different profile

The final start command is:

$mqpath> start bin\mqbroker.cmd -c conf\my-2m2s-sync\broker-b.properties

$mqpath> start bin\mqbroker.cmd -c conf\my-2m2s-sync\broker-a-s.properties

 

 

Sample configuration

Host: configuration of two brokers on 192.168.0.123

Broker-a.properties (a node master configuration file)

namesrvAddr=192.168.0.123:9876; 192.168.0.124:9876
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
listenPort=10911
storePathRootDir=D:/workfile/logs/rocketmqlogs/store-a

broker-b-s.properties (b节点从配置文件)

namesrvAddr=192.168.0.123:9876; 192.168.0.124:9876
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
listenPort=11011
storePathRootDir=D:/workfile/logs/rocketmqlogs/store-b

 

Host: configuration of two brokers on 192.168.0.124

Broker-b.properties (B node master configuration file)

namesrvAddr=192.168.0.123:9876; 192.168.0.124:9876
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
listenPort=10911
storePathRootDir=D:/workfile/logs/rocketmqlogs/store-b

broker-a-s.properties (a node from the profile)

namesrvAddr=192.168.0.123:9876; 192.168.0.124:9876
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
listenPort=11011
storePathRootDir=D:/workfile/logs/rocketmqlogs/store-a