RocketMQ5.1.0 stand-alone installation and startup

System Requirements

insert image description here

download link

Official website download address
insert image description here
The binary package can be run directly after compilation, and the source package needs to be compiled and run.

installation steps

Using the binary package of Community 5.1.0 in the Linux environment as an example, introduce the RocketMQ installation process.

## 解压
 unzip rocketmq-all-5.1.0-bin-release.zip
# 切换到解压的目录
cd  /usr/rocketmq-all-5.1.0-bin-release
# 切换到rocketmq安装目录下的bin目录
cd bin
# 编辑runserver.sh
vim runserver.sh

Modify startup parameters
insert image description here

# 修改runbroker.sh
vim runbroker.sh

Modify startup parameters
insert image description here

RocketMq

Start NameServer

## 启动NameServer
nohup sh bin/mqnamesrv &

Check whether the startup is successful

# 查看日志
cat /root/logs/rocketmqlogs/namesrv.log

insert image description here

Seeing 'The Name Server boot success…' means that the NameServer has started successfully.

Start Broker+Proxy

nohup sh bin/mqbroker -n localhost:9876 --enable-proxy &

Check whether the startup is successful

# 查看日志,是否启动成功
cat /root/logs/rocketmqlogs/proxy.log

insert image description here
"The broker[brokerName,ip:port] boot success...", which indicates that the broker has been successfully started.

Modify tool.sh

Modify tool.sh in the bin directory under the RocketMQ installation directory

cd /usr/rocketmq-all-5.1.0-bin-release/bin

the place need to change
insert image description here

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#===========================================================================================
# Java Environment Setting
#===========================================================================================
error_exit ()
{
    echo "ERROR: $1 !!"
    exit 1
}

find_java_home()
{
    case "`uname`" in
        Darwin)
            JAVA_HOME=$(/usr/libexec/java_home)
        ;;
        *)
            JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
        ;;
    esac
}

find_java_home

[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"

export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=.:${BASE_DIR}/conf:${BASE_DIR}/lib/*:${CLASSPATH}

#===========================================================================================
# JVM Configuration
#===========================================================================================
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"

$JAVA ${JAVA_OPT} "$@"

test message generation

cd /usr/rocketmq-all-5.1.0-bin-release/
export NAMESRV_ADDR=localhost:9876
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer

insert image description here
SendResult [sendStatus=SEND_OK, msgId= … means message

message consumption

cd /usr/rocketmq-all-5.1.0-bin-release/
 sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer

insert image description here

ConsumeMessageThread_%d Receive New Messages: [MessageExt...
means message consumption is successful

shutdown server

# 在RocketMq安装目录下执行以下命令
sh bin/mqshutdown broker

The result after the command is executed
insert image description here

sh bin/mqshutdown namesrv

The result after the command is executed
insert image description here

Guess you like

Origin blog.csdn.net/Java_Fly1/article/details/129312536