Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RocketMQ4.5.1 two-master and two-slave cluster deployment

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

10.40.58.5

10.40.58.6

Download the installation package

Https://rocketmq.apache.org/release_notes/release-notes-4.5.1/

Unzip rocketmq-all-4.5.1-bin-release.zip-d / data/

Rocketmq is written by java, so after configuring the jdk and mvn environments, use the

Export JAVA_HOME=/usr/java/jdk1.8.0_131

Export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Export M3_HOME=/usr/local/maven3

Export PATH=$JAVA_HOME/bin:$M3_HOME/bin:$PATH

Create persistent storage directories on servers 5 and 6, respectively (the following 5pc6 represents the servers above)

Msater directory settings

Mkdir / data/rocketmq-2m2s/store

Mkdir / data/rocketmq-2m2s/store/commitlog

Mkdir / data/rocketmq-2m2s/store/consumequeue

Mkdir / data/rocketmq-2m2s/store/index

Slave directory settings

Mkdir / data/rocketmq-2m2s/store-s

Mkdir / data/rocketmq-2m2s/store-s/commitlog

Mkdir / data/rocketmq-2m2s/store-s/consumequeue

Mkdir / data/rocketmq-2m2s/store-s/index

RocketMQ profile

5 Server configuration

Vi / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties

Vi / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties

6 Server configuration

Vi / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties

Vi / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties

5 Server broker-a.properties profile

Cat / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties

# name of the cluster to which it belongs

BrokerClusterName=rocketmq-cluster

# broker name. Note that different configuration files are filled in differently here.

BrokerName=broker-a

# 0 means Master, > 0 means Slave

BrokerId=0

# nameServer address, semicolon division

NamesrvAddr=10.40.58.5:9876;10.40.58.6:9876

# when sending messages, automatically create topic for which the server does not exist. The number of queues created by default

DefaultTopicQueueNums=4

# whether to allow Broker to automatically create Topic. It is recommended to enable it offline and disable it online.

AutoCreateTopicEnable=false

# whether to allow Broker to automatically create subscription groups. It is recommended to enable them offline and disable them online.

AutoCreateSubscriptionGroup=false

# listening port of Broker external service

ListenPort=10911

HaListenPort=10912

# time to delete files. Default is 4: 00 a.m.

DeleteWhen=04

# File retention time. Default is 48 hours.

FileReservedTime=18

# commitLog the default size of each file is 1G

MapedFileSizeCommitLog=1073741824

# ConsumeQueue saves 30W files by default, which can be adjusted according to the business situation.

MapedFileSizeConsumeQueue=300000

# destroyMapedFileIntervalForcibly=120000

# redeleteHangedFileInterval=120000

# detect physical file disk space

DiskMaxUsedSpaceRatio=88

# Storage path

StorePathRootDir=/data/rocketmq-2m2s/store

# commitLog storage path

StorePathCommitLog=/data/rocketmq-2m2s/store/commitlog

# consumption queue storage path

StorePathConsumeQueue=/data/rocketmq-2m2s/store/consumequeue

# Storage path of message index

StorePathIndex=/data/rocketmq-2m2s/store/index

# checkpoint file storage path

StoreCheckpoint=/data/rocketmq-2m2s/store/checkpoint

# abort file storage path

AbortFile=/data/rocketmq-2m2s/store/abort

# restricted message size

MaxMessageSize=65536

# flushCommitLogLeastPages=4

# flushConsumeQueueLeastPages=2

# flushCommitLogThoroughInterval=10000

# flushConsumeQueueThoroughInterval=60000

# the role of Broker

#-ASYNC_MASTER asynchronous replication Master

#-SYNC_MASTER synchronous double write Master

#-SLAVE

BrokerRole=SYNC_MASTER

# disk swiping method

#-ASYNC_FLUSH asynchronous flash drive

#-SYNC_FLUSH synchronous flash disk

FlushDiskType=ASYNC_FLUSH

# checkTransactionMessageEnable=false

# number of thread pools for sending messages

SendMessageThreadPoolNums=128

# number of pull message thread pools

PullMessageThreadPoolNums=128

# Open the lock

UseReentrantLockWhenPutMessage=true

WaitTimeMillsInSendQueue=3000

# it is mandatory to specify a native IP, which needs to be modified according to each machine. The official introduction can be empty, and the system automatically recognizes it by default, but the IP address may be read incorrectly when there are multiple network cards.

BrokerIP1=10.40.58.5

6 Server broker-a-s.properties profile

Cat / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties

# name of the cluster to which it belongs

BrokerClusterName=rocketmq-cluster

# broker name. Note that different configuration files are filled in differently here.

BrokerName=broker-a

# 0 means Master, > 0 means Slave

BrokerId=1

# nameServer address, semicolon division

NamesrvAddr=10.40.58.5:9876;10.40.58.6:9876

# when sending messages, automatically create topic for which the server does not exist. The number of queues created by default

DefaultTopicQueueNums=4

# whether to allow Broker to automatically create Topic. It is recommended to enable it offline and disable it online.

AutoCreateTopicEnable=false

# whether to allow Broker to automatically create subscription groups. It is recommended to enable them offline and disable them online.

AutoCreateSubscriptionGroup=false

# listening port of Broker external service

ListenPort=10923

HaListenPort=10924

# time to delete files. Default is 4: 00 a.m.

DeleteWhen=04

# File retention time. Default is 48 hours.

FileReservedTime=18

# commitLog the default size of each file is 1G

MapedFileSizeCommitLog=1073741824

# ConsumeQueue saves 30W files by default, which can be adjusted according to the business situation.

MapedFileSizeConsumeQueue=300000

# destroyMapedFileIntervalForcibly=120000

# redeleteHangedFileInterval=120000

# detect physical file disk space

DiskMaxUsedSpaceRatio=88

# Storage path

StorePathRootDir=/data/rocketmq-2m2s/store-s

# commitLog storage path

StorePathCommitLog=/data/rocketmq-2m2s/store-s/commitlog

# consumption queue storage path

StorePathConsumeQueue=/data/rocketmq-2m2s/store-s/consumequeue

# Storage path of message index

StorePathIndex=/data/rocketmq-2m2s/store-s/index

# checkpoint file storage path

StoreCheckpoint=/data/rocketmq-2m2s/store-s/checkpoint

# abort file storage path

AbortFile=/data/rocketmq-2m2s/store-s/abort

# restricted message size

MaxMessageSize=65536

# flushCommitLogLeastPages=4

# flushConsumeQueueLeastPages=2

# flushConsumeQueueLeastPages=2#flushCommitLogThoroughInterval=10000

# flushConsumeQueueThoroughInterval=60000

# the role of Broker

#-ASYNC_MASTER asynchronous replication Master

#-SYNC_MASTER synchronous double write Master

#-SLAVE

BrokerRole=SLAVE

# disk swiping method

#-ASYNC_FLUSH asynchronous flash drive

#-SYNC_FLUSH synchronous flash disk

FlushDiskType=ASYNC_FLUSH

# checkTransactionMessageEnable=false

# number of thread pools for sending messages

SendMessageThreadPoolNums=128

# number of pull message thread pools

PullMessageThreadPoolNums=128

# Open the lock

UseReentrantLockWhenPutMessage=true

WaitTimeMillsInSendQueue=3000

# it is mandatory to specify a native IP, which needs to be modified according to each machine. The official introduction can be empty, and the system automatically recognizes it by default, but the IP address may be read incorrectly when there are multiple network cards.

BrokerIP1=10.40.58.6

6 Server broker-b.properties profile

Cat / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties

# name of the cluster to which it belongs

BrokerClusterName=rocketmq-cluster

# broker name. Note that different configuration files are filled in differently here.

BrokerName=broker-b

# 0 means Master, > 0 means Slave

BrokerId=0

# nameServer address, semicolon division

NamesrvAddr=10.40.58.6:9876;10.40.58.5:9876

# when sending messages, automatically create topic for which the server does not exist. The number of queues created by default

DefaultTopicQueueNums=4

# whether to allow Broker to automatically create Topic. It is recommended to enable it offline and disable it online.

AutoCreateTopicEnable=false

# whether to allow Broker to automatically create subscription groups. It is recommended to enable them offline and disable them online.

AutoCreateSubscriptionGroup=false

# listening port of Broker external service

ListenPort=10911

HaListenPort=10912

# time to delete files. Default is 4: 00 a.m.

DeleteWhen=04

# File retention time. Default is 48 hours.

FileReservedTime=18

# commitLog the default size of each file is 1G

MapedFileSizeCommitLog=1073741824

# ConsumeQueue saves 30W files by default, which can be adjusted according to the business situation.

MapedFileSizeConsumeQueue=300000

# destroyMapedFileIntervalForcibly=120000

# redeleteHangedFileInterval=120000

# detect physical file disk space

DiskMaxUsedSpaceRatio=88

# Storage path

StorePathRootDir=/data/rocketmq-2m2s/store

# commitLog storage path

StorePathCommitLog=/data/rocketmq-2m2s/store/commitlog

# consumption queue storage path

StorePathConsumeQueue=/data/rocketmq-2m2s/store/consumequeue

# Storage path of message index

StorePathIndex=/data/rocketmq-2m2s/store/index

# checkpoint file storage path

StoreCheckpoint=/data/rocketmq-2m2s/store/checkpoint

# abort file storage path

AbortFile=/data/rocketmq-2m2s/store/abort

# restricted message size

MaxMessageSize=65536

# flushCommitLogLeastPages=4

# flushConsumeQueueLeastPages=2

# flushCommitLogThoroughInterval=10000

# flushConsumeQueueThoroughInterval=60000

# the role of Broker

#-ASYNC_MASTER asynchronous replication Master

#-SYNC_MASTER synchronous double write Master

#-SLAVE

BrokerRole=SYNC_MASTER

# disk swiping method

#-ASYNC_FLUSH asynchronous flash drive

#-SYNC_FLUSH synchronous flash disk

FlushDiskType=ASYNC_FLUSH

# checkTransactionMessageEnable=false

# number of thread pools for sending messages

SendMessageThreadPoolNums=128

# number of pull message thread pools

PullMessageThreadPoolNums=128

# Open the lock

UseReentrantLockWhenPutMessage=true

WaitTimeMillsInSendQueue=3000

# it is mandatory to specify a native IP, which needs to be modified according to each machine. The official introduction can be empty, and the system automatically recognizes it by default, but the IP address may be read incorrectly when there are multiple network cards.

BrokerIP1=10.40.58.6

5 Server broker-b-s.properties profile

Cat / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties

# name of the cluster to which it belongs

BrokerClusterName=rocketmq-cluster

# broker name. Note that different configuration files are filled in differently here.

BrokerName=broker-b

# 0 means Master, > 0 means Slave

BrokerId=1

# nameServer address, semicolon division

NamesrvAddr=10.40.58.6:9876;10.40.58.5:9876

# when sending messages, automatically create topic for which the server does not exist. The number of queues created by default

DefaultTopicQueueNums=4

# whether to allow Broker to automatically create Topic. It is recommended to enable it offline and disable it online.

AutoCreateTopicEnable=false

# whether to allow Broker to automatically create subscription groups. It is recommended to enable them offline and disable them online.

AutoCreateSubscriptionGroup=false

# listening port of Broker external service

ListenPort=10923

HaListenPort=10924

# time to delete files. Default is 4: 00 a.m.

DeleteWhen=04

# File retention time. Default is 48 hours.

FileReservedTime=18

# commitLog the default size of each file is 1G

MapedFileSizeCommitLog=1073741824

# ConsumeQueue saves 30W files by default, which can be adjusted according to the business situation.

MapedFileSizeConsumeQueue=300000

# destroyMapedFileIntervalForcibly=120000

# redeleteHangedFileInterval=120000

# detect physical file disk space

DiskMaxUsedSpaceRatio=88

# Storage path

StorePathRootDir=/data/rocketmq-2m2s/store-s

# commitLog storage path

StorePathCommitLog=/data/rocketmq-2m2s/store-s/commitlog

# consumption queue storage path

StorePathConsumeQueue=/data/rocketmq-2m2s/store-s/consumequeue

# Storage path of message index

StorePathIndex=/data/rocketmq-2m2s/store-s/index

# checkpoint file storage path

StoreCheckpoint=/data/rocketmq-2m2s/store-s/checkpoint

# abort file storage path

AbortFile=/data/rocketmq-2m2s/store-s/abort

# restricted message size

MaxMessageSize=65536

# flushCommitLogLeastPages=4

# flushConsumeQueueLeastPages=2

# flushCommitLogThoroughInterval=10000

# flushConsumeQueueThoroughInterval=60000

# the role of Broker

#-ASYNC_MASTER asynchronous replication Master

#-SYNC_MASTER synchronous double write Master

#-SLAVE

BrokerRole=SLAVE

# disk swiping method

#-ASYNC_FLUSH asynchronous flash drive

#-SYNC_FLUSH synchronous flash disk

FlushDiskType=ASYNC_FLUSH

# checkTransactionMessageEnable=false

# number of thread pools for sending messages

SendMessageThreadPoolNums=128

# number of pull message thread pools

PullMessageThreadPoolNums=128

# Open the lock

UseReentrantLockWhenPutMessage=true

WaitTimeMillsInSendQueue=3000

# it is mandatory to specify a native IP, which needs to be modified according to each machine. The official introduction can be empty, and the system automatically recognizes it by default, but the IP address may be read incorrectly when there are multiple network cards.

BrokerIP1=10.40.58.5

Note: in the above configuration file [# whether Broker is allowed to create Topic automatically, it is recommended to enable it offline and disable autoCreateTopicEnable=false online

# whether to allow Broker to automatically create subscription groups. It is recommended to enable it offline and disable autoCreateSubscriptionGroup=false online] disable topic and subscription groups and create them automatically. So before using the Java-API call, be sure to manually create the Topic and consumer subscription groups, otherwise the consumer side cannot get the message.

Modify log configuration file

Cd / data/rocketmq-all-4.5.1-bin-release/conf

Vi logback_namesrv.xml

Vi logback_namesrv.xml

Mkdir / data/logs

Modify rocketmq startup script

Modify jvm memory size appropriately

Vi / data/rocketmq-all-4.5.1-bin-release/bin/runbroker.sh

Vi / data/rocketmq-all-4.5.1-bin-release/bin/runserver.sh

Vi / data/rocketmq-all-4.5.1-bin-release/bin/tools.sh

Startup parameter setting

The RocketMQ startup files are located in the / data/rocketmq-all-4.5.1-bin-release/bin/ directory, and the nameserver startup files in Linux are: mqnamesrv,broker startup files are: mqbroker,mqnamesrv and mqbroker startup files call runserver.sh and runbroker.sh respectively.

File, these two files set the startup memory of nameserver and broker respectively. At present, the memory startup parameters are nameserver startup memory 4G, maximum memory 4G, new generation 2G scene broker startup memory 8G, maximum memory 8G, new generation 4G. (modify it according to your own needs)

Start Nameserver

Start the Nameserver of 5 and 6 respectively

Cd / data/rocketmq-all-4.5.1-bin-release/bin/

Nohup sh mqnamesrv &

Start Broker: cd / data/rocketmq-all-4.5.1-bin-release/bin/

Start Master on 5:

Nohup sh mqbroker-c / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a.properties &

Start Master on 6:

Nohup sh mqbroker-c / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b.properties &

Start Slave on 5:

Nohup sh mqbroker-c / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-b-s.properties &

Start Slave on 6:

Nohup sh mqbroker-c / data/rocketmq-all-4.5.1-bin-release/conf/2m-2s-async/broker-a-s.properties &

Now that Nameserver and Broker are started, you can use the jobs command to view the running process. Here is the relevant shutdown on the server side, that is, under the bin directory:

Sh mqshutdown namesrv

Sh mqshutdown broke

Deployment of RocketMQ monitoring platform

Download:

Git address: https://github.com/apache/rocketmq-externals/tree/release-rocketmq-console-1.0.0

Or https://pan.baidu.com/s/1Y4fzVc2r30jtIVpvYZocWA password: vj2y

Unzip rocketmq-externals-release-rocketmq-console-1.0.0.zip

Cd rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/src/main/resources/

Vi application.properties

Compile the source code (requires a maven environment)

Cd / root/rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/

Mvn clean package-Dmaven.test.skip=true (if you have a stuck one, you can download the corresponding jar and put it in this directory before continuing to compile.)

Start the service

Cd / root/rocketmq-externals-release-rocketmq-console-1.0.0/rocketmq-console/target

Java-jar rocketmq-console-ng-1.0.0.jar &

Access the management interface

Browser input: 10.40.58.5 8080 / enter display monitoring interface

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report