Install alirocketmq version from scratch on CentOS7: release-4.0.1

Keywords: Operation & Maintenance Maven Apache git JDK

Install alirocketmq version from scratch on CentOS7: release-4.0.1 [pro test ha ha]

Install git

# Update package
$ yum update 
# Install git
$ yum install git
# Verify git installation success
$ git --version
# So git can be installed successfully

Install wget dependency package

# Update package
$ yum install wget
# You can use the wget command after installation

Install jdk

# Log in SSH to the default user path of linux (I use the root user)
# Download JDK: use the download address of the official website: http://www.oracle.com/technetwork/java/javase/downloads/index.html
$ wget http://220.112.193.200/files/9130000004D8B9C4/download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz .
# Transfer to directory to extract
$ cp /root/jdk-8u144-linux-x64.tar.gz /usr/local/
# Toggle directory
$ cd /usr/local
# decompression
$ tar -xvf jdk-8u144-linux-x64.tar.gz
# Create a soft connection to connect the JDK's soft connection to jdk8
$ ln -s jdk-8u144-linux-x64.tar.gz jdk8
# Enter directory change to modify environment variables
$ vi ~/.bash_profile
# Add environment variables at the end as follows
JAVA_HOME=/usr/local/jdk8
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
# Use insert mode, esc + ': wq' to finish editing, and source to finish editing
$ source ~/.bash_profile
# Verify that the jdk installation is successful
$ java -version

Install maven

# Log in SSH to the default user path of linux (I use the root user)
# Download maven:http://maven.apache.org/download.cgi
$ wget http://211.162.127.22/files/2245000004204200/mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz .
# Move to directory to extract
$ cp /root/apache-maven-3.5.0-bin.tar.gz /usr/local/
# Toggle directory
$ cd /usr/local/
# decompression
$ tar -xvf apache-maven-3.5.0-bin.tar.gz
# Create a soft connection (connect the soft connection to the maven project to ensure that apache does not need to change the configuration of environment variables in the future)
$ ln -s apache-maven-3.5.0/ maven
# Enter directory change to modify environment variables
$ vi ~/.bash_profile
# Add environment variables at the end as follows
MAVEN_HOME=/usr/local/maven
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
# Use insert mode, esc + ': wq' to finish editing, and source to finish editing
$ source ~/.bash_profile
# Verify maven installation success
$ mvn -version

Install RocketMQ

Here we use the source code to compile and install. For reference, pull the source code from github to compile, and then use maven to compile

Pulling code and compiling through maven

# Select git code download directory and pull the source code (you can pull the branch of the latest version: release-4.1.0-incoming)
$ git clone -b release-4.1.0-incubating https://github.com/apache/incubator-rocketmq.git
# Switch to file directory
$ cd incubator-rocketmq
# Compile with maven, download the jar package and wait for the compilation to succeed
$ mvn -Prelease-all -DskipTests clean install -U
# Switch to the bin directory of the compiled directory to prepare to start the server
$ cd distribution/target/apache-rocketmq/bin

Start name Server (cluster can be set)

You can modify the jvm configuration with the command vi runserver.sh

# Start the command and stay in memory
$ nohup sh mqnamesrv &
# If you check the startup log, you can see that The Name Server boot success is successful
$ tail -f ~/logs/rocketmqlogs/namesrv.log

Start broker (cluster, master and slave can be set)

You can modify the jvm configuration with the command vi runbroker.sh

# Start the command and stay in memory: note that the ip address should be configured as the ip address of the service to ensure that the address and port can be accessed (official problem)
$ nohup sh mqbroker -n "192.168.1.113:9876" -c ../conf/2m-noslave/broker-a.properties > broker.out &
# When I started, I reported an error because the corresponding runbroker configuration set the memory size of the virtual machine to 4g. I didn't have enough memory, so I changed it to 2g as follows
JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g"
# View startup log
$ tail -f ~/logs/rocketmqlogs/broker.log 

Close RcocketMQ related services

# Stop broker service
$ sh mqshutdown broker
# Customizing the nameserver service
$  sh mqshutdown namesrv

Sending and receiving messages to MQ

# Execute under the bin directory to introduce the server address into the environment variable
$ export NAMESRV_ADDR=192.168.1.113:9876
# Case producer production message implemented by java code
$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
# Using java code to realize case consumer consumption message
$ sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer

Monitoring MQ

# Call command monitoring in bin directory of target
$ sh mqadmin clusterList -n 192.168.1.113:9876

Relevant precautions

The ip addresses in this paper are the corresponding server ip addresses,
Are consumers in Java code process stopped? They have been monitoring consumption

Posted by SCRUBBIE1 on Thu, 12 Dec 2019 08:46:41 -0800