1.下载RocketMQ安装包
https://rocketmq.apache.org/download/
2.在/usr/local/ 目录下创建rocketMQ文件夹,传入下载的tar.gz包
cd usr/local/
mkdir rocketMQ
pwd
显示为:/usr/local/rocketMQ
3.解压RocketMQ
[root@ls rocketMQ]# unzip rocketmq-all-5.0.0-bin-release.zip
4.配置rocketMQ环境变量
我的rocketMQ路径为:
/usr/local/rocketMQ/rocketmq-all-5.0.0-bin-release
编辑环境变量
vim /etc/profile
添加配置
export ROCKET_MQ=/usr/local/rocketmq-all-5.0.0-ALPHA-bin-release/
export PATH=$PATH:$ROCKET_MQ/bin
使新配置生效
source /etc/profile
4.我的linux服务器大小有限。启动前 修改rocketMQ占用的内存大小
4.1进入rocketMQ中bin目录,修改runbroker.sh 文件
cd /usr/local/rocketMQ/rocketmq-all-5.0.0-bin-release/bin
vim runbroker.sh
原始数值:
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=16g"
调整后:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=128m"
4.2进入rocketMQ中bin目录,修改runserver.sh 文件
原始数值
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
调整后:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
### 启动NameServer
cd /usr/local/rocketMQ/rocketmq-all-5.0.0-bin-release/bin && nohup sh mqnamesrv &
### 启动broker
cd /usr/local/rocketMQ/rocketmq-all-5.0.0-bin-release/bin && nohup sh mqbroker -c conf/broker.conf &
# 或
nohup sh mqbroker -n localhost:9876 &
通过jps 查看运行情况
[root@ls bin]# jps
11201 NamesrvStartup
11601 BrokerStartup
11716 Jps
4030 nacos-server.jar