Rocketmq two main two from asynchronous cluster

1. Install JDK

You need to uninstall the system default OPENJDK first, and install the JDK1.8 64-bit version.

Uninstall open-jdk

rpm -qa|grep java

Check the installation of open jdk.

Use the command

rpm -e –nodeps ***

Uninstall.

Install jdk1.8

tar -zxvf jdk-8u191-linux-x64.tar.gz Unzip JDK

Edit

/ etc/profile

Add configuration at the end

export JAVA_HOME=/work/jdk1.8.0_191
export PATH=$JAVA_HOME/bin:$PATH

Rocketmq cluster building

1. Deployment architecture

We have two nodes

IP is 10.87.134.74, 10.87.134.75, both machines are running NAMESERVER.

Deploy BROKER A MASTER,BROKER B SLAVE on 74

Deploy BROKER A SLAVE, BROKER B on 75 MASTER

share picture

2. Modify the memory configuration

By default, the rocketmq configuration has a relatively large running memory. If the machine memory Some adjustments can be made if it is not enough.

Edit the runbroker.sh file in the bin directory

JAVA_OPT=”${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g”

Edit the bin directory Runserver.sh file

JAVA_OPT=”${JAVA_OPT} -server -Xms1g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”

3. Prepare the cluster configuration file

The master-slave asynchronous mode we installed

After the program is decompressed, there is the following configuration file in the conf

p>

Share a picture

Edit the configuration file of node 74< /p>

Edit the content of broker-a.properties:

brokerClusterName=DefaultCluster

brokerName
=broker-a
brokerId
=0
deleteWhen
=04
fileReservedTime
=48
brokerRole
=ASYNC_MASTER
flushDiskType
=ASYNC_FLUSH

listenPort
=6001
autoCreateTopicEnable
=true
namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-a
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-a/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-a/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-a/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-a/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-a/abort

Edit the content of the broker-bs.properties file

< div class="code">

brokerClusterName=DefaultCluster

brokerName
=broker-b
brokerId
=1
deleteWhen
=04
fileReservedTime
=48
brokerRole
=SLAVE
flushDiskType
=ASYNC_FLUSH

listenPort
=7001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-b
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-b/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-b/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-b/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-b/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-b/abort

Edit 75 configuration file

Edit broker -b.properties file

terName=DefaultCluster

brokerName
=broker-b
brokerId
=0
deleteWhen
=04
fileReservedTime
=48
brokerRole
=ASYNC_MASTER
flushDiskType
=ASYNC_FLUSH

listenPort
=7001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-b
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-b/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-b/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-b/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-b/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-b/abort

Edit the broker-as.properties file

brokerClusterName=DefaultCluster

brokerName
=broker-a
brokerId
=1
deleteWhen
=04
fileReservedTime
=48
brokerRole
=SLAVE
flushDiskType
=ASYNC_FLUSH


listenPort
=6001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>

storePathRootDir
=/work/rocketmq-4.5.1/store/broker-a
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-a/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-a/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-a/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-a/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-a/abort

listenPort: is the port that the broker listens to. 

We need to create the following directory:
store/broker-a
store /broker-a/commitlog
store/broker-a/consumequeue
store/broker-a/index directory

Create broker- a, the directory of broker-b.

4. Start rocketmq and check whether it is correct.

1. Start nameserver
Execute separately on two nodes:
nohup sh /work/rocketmq-4.5.1/bin/mqnamesrv >/work/rocketmq-4.5. 1/logs/mqnamesrv.log 2>&1 &
2. Execute in the following order

   1. Start broker-a (node ​​1)
     nohup sh /work/rocketmq-4.5. 1/bin/mqbroker -c /work/rocketmq-4.5.1/conf/2m2sasync/broker-a.properties> /work/rocketmq-4.5.1/logs/broker-a.log 2>&1 &

  2. Start broker-as (Node 2)
    nohup sh /work/rocketmq-4.5.1/bin/mqbroker -c /work/rocketmq-4.5.1/conf/2m2sasync/broker-as.properties > /work/rocketmq-4.5.1/logs/broker-as.log 2>&1 &

  3. Start broker-b (node ​​2)
    nohup sh /work/rocketmq-4.5. 1/bin/mqbroker -c /work/rocketmq-4.5.1/conf/2m2sasync/broker-b.properties> /work/rocketmq-4.5.1/logs/broker-b.log 2>&1 &

  4. Start broker-bs (node ​​1)
    nohup sh /work/rocketmq-4.5.1/bin/mqbroker -c /work/rocketmq-4.5.1/conf/2m2sasync/broker-bs.properties > /work/rocketmq-4.5.1/logs/broker-bs.log 2>&1 &

3. Check whether the node configuration is correct

Execute the command. /bin/mqadmin clusterList -n 10.87.134.75

   Share a picture

   There are 4 such configuration instructions, That’s it.

5. Notes

Fault 1

The following error is reported when starting the broker.

ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! !!

Solution:

Share Picture

Comment the above three lines and add JAVA_HOME.

brokerClusterName=DefaultCluster

brokerName
=broker-a
brokerId
=0
deleteWhen
=04
fileReservedTime
=48
brokerRole
=ASYNC_MASTER
flushDiskType
=ASYNC_FLUSH

listenPort
=6001
autoCreateTopicEnable
=true
namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-a
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-a/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-a/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-a/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-a/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-a/abort

brokerClusterName=DefaultCluster

brokerName
=broker-b
brokerId
=1
deleteWhen
=04
fileReservedTime
=48
brokerRole
=SLAVE
flushDiskType
=ASYNC_FLUSH

listenPort
=7001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-b
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-b/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-b/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-b/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-b/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-b/abort

terName=DefaultCluster

brokerName
=broker-b
brokerId
=0
deleteWhen
=04
fileReservedTime
=48
brokerRole
=ASYNC_MASTER
flushDiskType
=ASYNC_FLUSH

listenPort
=7001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>
storePathRootDir=/work/rocketmq-4.5.1/store/broker-b
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-b/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-b/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-b/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-b/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-b/abort

brokerClusterName=DefaultCluster

brokerName
=broker-a
brokerId
=1
deleteWhen
=04
fileReservedTime
=48
brokerRole
=SLAVE
flushDiskType
=ASYNC_FLUSH


listenPort
=6001
autoCreateTopicEnable
=true

namesrvAddr
=10.87.134.74:9876;10.87.134.75:9876< /span>

storePathRootDir
=/work/rocketmq-4.5.1/store/broker-a
storePathCommitLog
=/work/rocketmq-4.5.1/store/broker-a/commitlog
storePathConsumeQueue
=/work/rocketmq-4.5.1/store/broker-a/consumequeue
storePathIndex
=/work/rocketmq-4.5.1/store/broker-a/index
storeCheckpoint
=/work/rocketmq-4.5.1/store/broker-a/checkpoint
abortFile
=/work/rocketmq-4.5.1/store/broker-a/abort

Leave a Comment

Your email address will not be published.