Rocketmq installation and configuration process

Time:2021-7-28

Official website

Official website:http://rocketmq.apache.org

Download the source package:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.8.0/rocketmq-all-4.8.0-source-release.zip

Github:https://github.com/apache/rocketmq

Linux+JDK1.8

Server configuration

  1. Configure the JDK environment in the server and upload the compressed package to / usr / local for decompression
tar -zxvf jdk-8u231-linux-x64.tar.gz /usr/local
  1. Configure environment variables
vim /etc/profile


#Insert content
export JAVA_HOME=/usr/local/jdk1.8.0_231
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH


#Immediate effect
source /etc/profile
  1. Enter the rocketmq home directory on windows and compile the project using Maven
mvn -Prelease-all -DskipTests clean install -U

After compilation, find the compressed package in this folder

D:\config\apache-maven-3.6.2\Repository\org\apache\rocketmq\rocketmq-distribution\4.3.2

  1. Upload the compiled compressed package to the Linux system and decompress it
#Create rocketmq directory
mkdir /usr/local/rocketmq

#Unzip the rocketmq package
tar -zxvf rocketmq-distribution-4.3.2.tar.gz -C /usr/local/rocketmq
  1. Run rocketmq
#Enter the / usr / local / rocketmq / bin directory
cd /usr/local/rocketmq/bin

#Modify the startup parameters of the configuration files runserver.sh and runbroker.sh
#JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m"


#Execute mqnamesrv
./mqnamesrv

#Execute runbroker
./mqbroker -n localhost:9876

Compiling and installing the rocketmq console console

download

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

Chinese guide

https://github.com/apache/rocketmq-externals/blob/master/rocketmq-console/doc/1_0_0/UserGuide_CN.md

Upload to the server and unzip
compile

Enter the rocketmq console directory

Execute compilation

mvn clean package -Dmaven.test.skip=true

start-up
After successful compilation, execute rocketmq-console-ng-1.0.1.jar in the rocketmq-console / target directory

When starting, add the nameserver address directly or edit application.properties to add properties

java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr=127.0.0.1:9876

At compile time, the package could not find the prompt 502 error on the mirror

reason:Bad network or Maven warehouse server error

Try again, or change to another image warehouse

Send failure prompt connect to null failed

./tools.sh org.apache.rocketmq.example.quickstart.Producer
22:49:02.470 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
java.lang.IllegalStateException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to
null failed

reason:hear nothing ofnameserverWhere?

staytoolsAdd to script

export NAMESRV_ADDR=localhost:9876

Cannot allocate memory failed to start broker

reason:JVM startup initialization memory allocation is larger than physical memory

[[email protected] bin]# ./mqbroker -n localhost:9876
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_pid1997.log

Modify the JVM parameters in the startup script

runbroker.sh broker

runserver.sh nameserver

The default values are very large. You can reduce them

JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=100m"

The broker is started successfully, but the prompt: failed to obtain the host name

[[email protected] bin]# ./mqbroker -n localhost:9876
22:30:42.307 [main] ERROR RocketmqCommon - Failed to obtain the host name
java.net.UnknownHostException: node-113b: node-113b: No address associated with hostname
	at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[na:1.8.0_181]
	at org.apache.rocketmq.common.BrokerConfig.localHostName(BrokerConfig.java:189) [rocketmq-common-4.6
.1.jar:4.6.1]	at org.apache.rocketmq.common.BrokerConfig.(BrokerConfig.java:38) [rocketmq-common-4.6.1.jar:4
.6.1]	at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:110) [rocketmq
-broker-4.6.1.jar:4.6.1]	at org.apache.rocketmq.broker.BrokerStartup.main(BrokerStartup.java:58) [rocketmq-broker-4.6.1.jar:4
.6.1]Caused by: java.net.UnknownHostException: node-113b: No address associated with hostname
	at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_181]
	at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_181]
	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_181]
	at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_181]
	... 4 common frames omitted
The broker[DEFAULT_BROKER, 192.168.150.213:10911] boot success. serializeType=JSON and name server is localh
ost:9876

reason:Unable to resolve the current host name

Just add a map to hosts

192.168.150.213 node-113b