Download and install Maven

The apache-RocketMQ installation needs to be compiled by Maven before it can be started, so first make sure that the Java environment and Maven are installed on the Linux server.

1. Download Maven and unzip it

Maven maven.apache.org/download.cg download address… Find the appropriate Maven version

Wget HTTP: / / http://mirrors.shu.edu.cn/apache/maven/maven-3/3.6.0/source/apache-maven-3.6.0-src.tar.gzCopy the code

Use the command above to download the Maven zip package to the directory you want to install. Decompress the installation package

The tar ZXVF - apache maven - 3.6.0 - SRC. Tar. GzCopy the code

After decompressing, a soft connection can be established to facilitate the configuration of environment variables

Ln -s apache maven - 3.6.0 - SRC. Tar. Gz mavenCopy the code
2. Configure environment variables

Opening a Configuration file

vim /etc/profile
Copy the code

Append environment variables to the end of the file

MAVEN_HOME=/usr/local/maven
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
Copy the code

/usr/local is the directory where you will store Maven

Make the configuration file take effect immediately

source /etc/profile
Copy the code
3. The installation is successful

On the console, enter MVN -v. If the version number is displayed, maven is successfully installed

Download and install RocketMQ

1. Download and decompress Apache-RocketMQ

Github.com/apache/rock… There are several versions of RocketMQ available on this site

Wget HTTP: / / https://github.com/apache/rocketmq/archive/rocketmq-all-4.3.0.tar.gzCopy the code

Create a New RocketMQ folder under /user/local/, download the zip package into this folder, and unzip it

The tar - ZXVF rocketmq - all - 4.3.0. Tar. GzCopy the code

The folder is as follows

2. Compile

To build a project using Maven,

mvn -Prelease-all -DskipTests clean install -U
Copy the code

Begin to compile

If BUILD SUCCESS is displayed at the end, the BUILD has been successfully compiled

3. Configure environment variables
cd distribution/target/apache-rocketmq/
pwd
Copy the code

To record this path, you need to configure to the environment variable to open the configuration file

vim /etc/profile
Copy the code

Add two lines at the end, wq save and exit

export rocketmq=/usr/local/rockemq-source/rocketmq/distribution/target/apache-rocketmq
export PATH=$PATH:$rocketmq/bin
Copy the code

Let the configuration file take effect immediately

source /etc/profile
Copy the code

Creating a Log Folder

mkdir /usr/local/log/rocketmqlogs
Copy the code
4. Start RocketMQ

Activation:

nohup mqnamesrv >/usr/local/log/rocketmqlogs/namesrv.log 2>&1 &  
Copy the code

View logs:

tail -f /user/local/log/rocketmqlogs/namesrv.log
Copy the code

If it starts normally, it will appear

Start the broker service:

nohup mqbroker -n localhost:9876 >/usr/local/log/rocketmqlogs/broker.log 2>&1 &   
Copy the code

View logs:

tail -f /user/local/log/rocketmqlogs/broker.log
Copy the code

If it starts normally, it will appear

But because RocketMQ’s default Java memory configuration is a bit large, the server will report an error if it has less memory

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. Java HotSpot(TM) 64-Bit Server VM warning: MaxNewSize (131072k) is equal to or greater than the entire heap (131072k). A new max generation size of 131008k will be  used.Copy the code

Just modify the configuration of the runserver.sh and runbroker.sh files in the bin directory

JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx256m -Xmn128m"
Copy the code

You should be able to restart the RocketMQ process by running the following command

ps -ef|grep rocketmq
Copy the code

5. Close the
mqshutdown namesrv
mqshutdown broker
Copy the code

3. Build RocketMQ Console

1. Download

RocketMQ is an open source extension of rocketMq-externals, One of the projects in there is the RocketMQ Console and the whole thing is a little bit slow to download, so I’ll just go with the Console branch

2. Configure startup

Import the project, and then configure the configuration file

Configure the server address

Start the project

If the following link failure problem occurs, it may be that your server port is not open, the security group rule configuration is good, it is best to open 9876,10909,10911

java.lang.RuntimeException: org.apache.rocketmq.remoting.exception.RemotingConnectException: 
connect to <x.x.x.x:9876> failed
Copy the code

If the port is open but still reports connect to X.X.X.X :10911 failed, then brokerIP1 needs to be configured. BrokerIP1 starts with a default local IP that may not be remotely accessible.

Create new properties in the RocketMQ directory

Echo "brokerIP1= Extranet IP" > broker.propertiesCopy the code

Close and restart the broker

Mqshutdown broker nohup mqbroker -n localhost: 9876 - c/broker configuration file path. The properties > / usr/local/log/rocketmqlog/broker. The log 2 > &1 &Copy the code

Restart the console project to access the browser