RocketMQ 4.5.1 building a dual master and dual slave asynchronous replication environment

Basic environment

Operating system: CentOS7

Example: 192.168.63.129192.168.63.130192.168.63.131192.168.63.132

Java: jdk-8u191-linux-x64.tar.gz

Install JDK

First, unload the system

 

[root@localhost soft]# rpm -qa|grep java
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64
tzdata-java-2018e-3.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
[root@localhost soft]# rpm -e java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64 --nodeps
[root@localhost soft]# rpm -e java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64 --nodeps
[root@localhost soft]# 

Enter the directory where your JDK installation package is located, and then install JDK

# Create a directory to store
[root@localhost soft]# mkdir /usr/local/java
# Extract to this directory
[root@localhost soft]# tar -xvf jdk-8u191-linux-x64.tar.gz -C /usr/local/java/

 

After decompression, enter the directory and you can see

The following configuration environment variables

[root@localhost java]# vim /etc/profile

Add the following

# java
export JAVA_HOME=/usr/local/java/jdk1.8.0_191
export JRE_HOME=/usr/local/java/jdk1.8.0_191/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

As follows

Refresh and verify

[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
[root@localhost java]# 

 

Install RocketMQ

 

First upload it to the server, and I will upload it to the / soft folder. Then decompress

# decompression
[root@localhost soft]# unzip rocketmq-all-4.5.1-bin-release.zip -d /usr/local/
# Enter the unzip directory
[root@localhost soft]# cd /usr/local/
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 3 root root  26 May 26 18:39 java
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
drwx------. 6 root root 103 Mar 29 17:37 rocketmq-all-4.5.0-bin-release
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root  49 May 10 07:44 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 src
# Change your name [root@localhost local]#
mv rocketmq-all-4.5.1-bin-release/ rocketmq [root@localhost local]# ll total 0 drwxr-xr-x. 2 root root 6 Apr 11 2018 bin drwxr-xr-x. 2 root root 6 Apr 11 2018 etc drwxr-xr-x. 2 root root 6 Apr 11 2018 games drwxr-xr-x. 2 root root 6 Apr 11 2018 include drwxr-xr-x. 3 root root 26 May 26 18:39 java drwxr-xr-x. 2 root root 6 Apr 11 2018 lib drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64 drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec drwx------. 6 root root 103 Mar 29 17:37 rocketmq drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin drwxr-xr-x. 5 root root 49 May 10 07:44 share drwxr-xr-x. 2 root root 6 Apr 11 2018 src

 

Enter the profile directory and modify the profile (the profile modified by the four machines is different, note the name)

[root@localhost local]# cd rocketmq/conf/2m-2s-async/
# 129 node
[root@localhost 2m-2s-async]# vim broker-a.properties
# 130 node
[root@localhost 2m-2s-async]# vim broker-a-s.properties
# 131 node
[root@localhost 2m-2s-async]# vim broker-b.properties
# 132 node
[root@localhost 2m-2s-async]# vim broker-b-s.properties

Add the following contents (the contents of the four machines are the same, but the modified files are different)

listenPort=10911
namesrvAddr=192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876
mapedFileSizeCommitLog=1073741824
storePathRootDir=/usr/local/rocketmq/store
storePathCommitLog=/usr/local/rocketmq/store/commitlog
storePathConsumerQueue=/usr/local/rocketmq/store/consumequeue
storePathIndex=/usr/local/rocketmq/store/index

 

As shown in the picture:

Then create a new store related directory (four machines are the same)

[root@localhost 2m-2s-async]# mkdir /usr/local/rocketmq/store
[root@localhost 2m-2s-async]# mkdir /usr/local/rocketmq/store/commitlog
[root@localhost 2m-2s-async]# mkdir /usr/local/rocketmq/store/consumequeue
[root@localhost 2m-2s-async]# mkdir /usr/local/rocketmq/store/index

 

Open firewall port

[root@localhost 2m-2s-async]# firewall-cmd --zone=public --add-port=10911/tcp --permanent
success
[root@localhost 2m-2s-async]# firewall-cmd --zone=public --add-port=9876/tcp --permanent
success
[root@localhost 2m-2s-async]# systemctl restart firewalld

 

Enter bin directory and prepare to start nameserver. The start is successful.

[root@localhost 2m-2s-async]# cd /usr/local/rocketmq/bin/
[root@localhost bin]# ./mqnamesrv &
[1] 59673
[root@localhost bin]# Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON

[root@localhost bin]# 

 

Now start broker

[root@localhost bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a.properties &
[2] 59731
[root@localhost bin]# Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/rocketmq/bin/hs_err_pid59738.log

[2]+  Exit 1                  ./mqbroker

 

Error reported, out of memory. After all, the test setup has only 1G memory. Modify runbroker.sh

[root@localhost bin]# vim runbroker.sh

Amend here

Change to - xms256m - xmn128m

Save closed, restart.

 

# 129
[root@localhost bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a.properties &
[3] 61454
[2]   Exit 143                ./mqbroker
[root@localhost bin]# The broker[broker-a, 192.168.63.129:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 130
[root@localhost bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-a-s.properties &
[3] 60359
[2]   Exit 143                ./mqbroker
[root@localhost bin]# The broker[broker-a, 192.168.63.130:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 131
[root@localhost bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-b.properties &
[3] 60224
[2]   Exit 143                ./mqbroker
[root@localhost bin]# The broker[broker-b, 192.168.63.131:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

# 132
[root@localhost bin]# ./mqbroker -c /usr/local/rocketmq/conf/2m-2s-async/broker-b-s.properties &
[3] 60310
[2]   Exit 143                ./mqbroker
[root@localhost bin]# The broker[broker-b, 192.168.63.132:10911] boot success. serializeType=JSON and name server is 192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876

 

After all of them are started successfully, install a control console.

Management console

Four servers are needed to open port 10909.

[root@localhost bin]# firewall-cmd --zone=public --add-port=10909/tcp --permanent
success
[root@localhost bin]# systemctl restart firewalld

=====

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

After downloading, enter the rocketmq console directory to execute the packing command

mvn clean package -Dmaven.test.skip=true

 

 

Enter the target directory and execute the command to start.

java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr='192.168.63.129:9876;192.168.63.130:9876;192.168.63.131:9876;192.168.63.132:9876'

 

Visit http://localhost:8080/#/cluster

 

 

Shut down NameServer and Broker

[root@localhost bin]# ./mqshutdown namesrv
The mqnamesrv(59705) is running...
Send shutdown request to mqnamesrv(59705) OK
[root@localhost bin]# ./mqshutdown broker
The mqbroker(60366) is running...
Send shutdown request to mqbroker(60366) OK
[1]-  Exit 143                ./mqnamesrv

Tags: PHP Java vim JDK JSON

Posted on Mon, 04 Nov 2019 10:54:46 -0800 by grilldan