RocketMQ
To prepare
The virtual machine
centos7
jdk8u281
Download address
The RocketMQ installation version is affected by the JRE environment. The relationship is shown in the following table (from the official version).
Version | Client | Broker | NameServer |
---|---|---|---|
4.0.0 – incubating | > = 1.7 | > = 1.8 | > = 1.8 |
4.1.0 – incubating | > = 1.6 | > = 1.8 | > = 1.8 |
4.2.0 | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.3. | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.4. | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.5. | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.6. | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.7. | > = 1.6 | > = 1.8 | > = 1.8 |
X 4.8. | > = 1.6 | > = 1.8 | > = 1.8 |
website
Download address
Installation steps
Uninstall the openjdk delivered with centos7
# query system is installed JDK RPM - qa | grep JavaCopy the code
These three can not be deleted
RPM -e --nodeps java-1.8.0-openJDK -headless-1.8.0.275.b01-0.el7_0.x86_64 RPM -e --nodeps java-1.8.0-openJDK -headless-1.8.0.275.b01-0.el7_0.x86_64Copy the code
The installationJava
jdk
# # download address https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html to upload the installation package /usr/local/jdk-8u281-linux-x64.tar.gz /usr/local/jdk-8u281-linux-x64.tar Export JAVA_HOME=/usr/local/ JDK export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH # Effective environment variables source /etc/profile # Check whether the installation is successful java -versionCopy the code
Install rocketMQ
# download using wget or download files can be uploaded to the server wget https://mirrors.bfsu.edu.cn/apache/rocketmq/4.8.0/rocketmq-all-4.8.0-bin-release.zip # Unzip rocketmq-all-4.8.0-bin-release rocketmq: rocketmq-all-4.8.0-bin-release rocketmq: rocketmq-all-4.8.0-bin-release rocketmq: rocketmq-all-4.8.0-bin-release rocketmq: rocketmq-all-4.8.0-bin-release rocketmqCopy the code
Start the command
mqnamesrv
# start mqNAMesrv./mqnamesrvCopy the code
# background start mqnamesrv nohup. / mqnamesrv > / dev/null > & 1 & # 2 check the ps - ef | grep mqnamesrvCopy the code
mqbroker
Mqbroker -n 192.168.94.129:9876 autoCreateTopicEnable=trueCopy the code
/mqbroker -n 192.168.94.129:9876 autoCreateTopicEnable=true > /dev/null 2>&1 &Copy the code
The problem
The startup failed due to insufficient memory. Procedure
Reason: RocketMQ is configured for production environment by default, and the JVM memory size is set to a large value, which may not be as large for learning test environment, so you need to adjust the default value
To resolve the problem, go to runserver.sh and runbroker.sh and modify the following:
JAVA_OPT= "${JAVA_OPT} -server-xMS256m -XMx256m -xmn125m -xx :MetaspaceSize=128m -xx :MaxMetaspaceSize=320m"Copy the code
Modify the runserver then executes. Sh
JAVA_OPT="${JAVA_OPT} -server -xms4g -xmx4g-xmn2g -xx :MetaspaceSize=128m -xx :MaxMetaspaceSize=320m" # -xmx256m: set the maximum available memory of the JVM to 256m. # -xMS3550m: Set JVM drive to 3550M. This value can be set to the same as -xmx to avoid the JVM reallocation of memory after each garbage collection. Total JVM memory size = young generation size + Old generation size + persistent generation size. The permanent generation has a fixed size of 64m, so increasing the young generation will reduce the size of the old generation. This value has a significant impact on system performance. Sun officially recommends setting it to 3/8 of the entire heap. JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"Copy the code
Modify runbroker. Sh
JAVA_OPT="${JAVA_OPT} -server-xms8g -xmx8g-xmn4g JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"Copy the code
Restart mqnamesrv
Restart mqbroker
Note: reference to official documents, very detailed reference
TODO writes here for now and will continue to add more