> 技术文档 > RocketMQ两主两从部署搭建

RocketMQ两主两从部署搭建

参考:https://mp.weixin.qq.com/s/W2wfSEqL9I8o78RclXEk_A

acl

vim conf/acl/plain_acl.yml

# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the \"License\"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an \"AS IS\" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.globalWhiteRemoteAddresses: - 127.0.0.1 - 172.17.13.*accounts: - accessKey: xxxxxx secretKey: xxxxxxxxxxxxxxx whiteRemoteAddress: admin: false defaultTopicPerm: PUB|SUB defaultGroupPerm: SUB topicPerms: groupPerms: - accessKey: xxxxxxx secretKey: xxxxxxxxxxxxxxxxx whiteRemoteAddress: 172.17.13.* admin: true

nameserver

每台均执行
vim startNameSrv.sh

cd /app/rocketmq/rocketmq-all-4.9.8-bin-releasenohup bin/mqnamesrv &>/app/rocketmq/startNameSrv.log &

broker

broker-a

vim startBroker.sh

export NAMESRV_ADDR=\'172.17.13.1:9876;172.17.13.2:9876;172.17.13.3:9876;172.17.13.4:9876\'cd /app/rocketmq/rocketmq-all-4.9.8-bin-releasenohup bin/mqbroker -c conf/2m-2s-sync/broker-a.properties &>/app/rocketmq/startBroker.log &

vim rocketmq-all-4.9.8-bin-release/conf/2m-2s-sync/broker-a.properties

# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the \"License\"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an \"AS IS\" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.brokerClusterName=DefaultClusterbrokerName=broker-abrokerId=0deleteWhen=04fileReservedTime=48brokerRole=SYNC_MASTERflushDiskType=ASYNC_FLUSHaclEnable=trueautoCreateTopicEnable=falsemaxMessageSize=4194304enablePropertyFilter=true

broker-b

vim startBroker.sh

export NAMESRV_ADDR=\'172.17.13.1:9876;172.17.13.2:9876;172.17.13.3:9876;172.17.13.4:9876\'cd /app/rocketmq/rocketmq-all-4.9.8-bin-releasenohup bin/mqbroker -c conf/2m-2s-sync/broker-b.properties &>/app/rocketmq/startBroker.log &

vim rocketmq-all-4.9.8-bin-release/conf/2m-2s-sync/broker-b.properties

# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the \"License\"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an \"AS IS\" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.brokerClusterName=DefaultClusterbrokerName=broker-bbrokerId=0deleteWhen=04fileReservedTime=48brokerRole=SYNC_MASTERflushDiskType=ASYNC_FLUSHaclEnable=trueautoCreateTopicEnable=falsemaxMessageSize=4194304enablePropertyFilter=true

broker-a-s

vim startBroker.sh

export NAMESRV_ADDR=\'172.17.13.1:9876;172.17.13.2:9876;172.17.13.3:9876;172.17.13.4:9876\'cd /app/rocketmq/rocketmq-all-4.9.8-bin-releasenohup bin/mqbroker -c conf/2m-2s-sync/broker-a-s.properties &>/app/rocketmq/startBroker.log &

vim rocketmq-all-4.9.8-bin-release/conf/2m-2s-sync/broker-a-s.properties

# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the \"License\"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an \"AS IS\" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.brokerClusterName=DefaultClusterbrokerName=broker-abrokerId=1deleteWhen=04fileReservedTime=48brokerRole=SLAVEflushDiskType=ASYNC_FLUSHaclEnable=trueautoCreateTopicEnable=falsemaxMessageSize=4194304enablePropertyFilter=true

broker-b-s

vim startBroker.sh

export NAMESRV_ADDR=\'172.17.13.1:9876;172.17.13.2:9876;172.17.13.3:9876;172.17.13.4:9876\'cd /app/rocketmq/rocketmq-all-4.9.8-bin-releasenohup bin/mqbroker -c conf/2m-2s-sync/broker-b-s.properties &>/app/rocketmq/startBroker.log &

vim rocketmq-all-4.9.8-bin-release/conf/2m-2s-sync/broker-b-s.properties

# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements. See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the \"License\"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an \"AS IS\" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.brokerClusterName=DefaultClusterbrokerName=broker-bbrokerId=1deleteWhen=04fileReservedTime=48brokerRole=SLAVEflushDiskType=ASYNC_FLUSHaclEnable=trueautoCreateTopicEnable=falsemaxMessageSize=4194304enablePropertyFilter=true

rocketmq-console

https://github.com/apache/rocketmq-externals

cd /app/rocketmqgit clone https://github.com/apache/rocketmq-externals.gitcd rocketmq-externals/rocketmq-console/src/main/resources/

vim application.properties

server.address=0.0.0.0server.port=8086### SSL setting#server.ssl.key-store=classpath:rmqcngkeystore.jks#server.ssl.key-store-password=rocketmq#server.ssl.keyStoreType=PKCS12#server.ssl.keyAlias=rmqcngkey#spring.application.index=truespring.application.name=rocketmq-consolespring.http.encoding.charset=UTF-8spring.http.encoding.enabled=truespring.http.encoding.force=truelogging.level.root=INFOlogging.config=classpath:logback.xml#if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876rocketmq.config.namesrvAddr=#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default truerocketmq.config.isVIPChannel=#rocketmq-console\'s data path:dashboard/monitorrocketmq.config.dataPath=data/rocketmq-console/data#set it false if you don\'t want use dashboard.default truerocketmq.config.enableDashBoardCollect=true#set the message track trace topic if you don\'t want use the default onerocketmq.config.msgTrackTopicName=rocketmq.config.ticketKey=ticket#Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is requiredrocketmq.config.loginRequired=false#set the accessKey and secretKey if you used aclrocketmq.config.accessKey=xxxxxxrocketmq.config.secretKey=xxxxxxxxxxxxxxxxx

编译rocketmq-console

mvn clean package -Dmaven.test.skip=true

编译成功后在target下找到文件:rocketmq-console-ng-*.jar

vim startConsole.sh

export NAMESRV_ADDR=\'172.17.13.1:9876;172.17.13.2:9876;172.17.13.3:9876;172.17.13.4:9876\'cd /app/rocketmqnohup java -jar rocketmq-console-ng-2.0.0-logback.jar &>/app/rocketmq/logs/startConsole.log &