一、RocketMQ单机
RocketMQ官网: https://rocketmq.apache.org/docs/quick-start/ https://archive.apache.org/dist/rocketmq/4.9.2/rocketmq-all-4.9.2-bin-release.zip
1.1 环境准备
#1)查看linux服务器操作系统
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.53.1.el7.x86_64 #1 SMP Fri Jan 14 13:59:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
#2)创建业务用于安装及区别于root权限
[root@localhost ~]# useradd contentuser
[root@localhost ~]# passwd contentuser
Changing password for user contentuser
passwd: all authentication tokens updated successfully.
3)创建中间件目录文件夹修改文件权限(本地虚拟机装的jdk已经用了root,学习测试暂时就不规范了)
[root@localhost huawei]# mkdir rocketmq
[root@localhost huawei]# chown contentuser:contentuser rocketmq
#4)准备java环境,安装jdk(jdk之前已经root权限安装过了,后续操作统一用root)
1.2 单机服务安装
#5) 准备rocketmq安装包(此处准备目前apache最新稳定版4.9.2,安装简单,建议装最新稳定版)
#https://archive.apache.org/dist/rocketmq/4.9.2/rocketmq-all-4.9.2-bin-release.zip
#6)将zip包解压后上传至环境(解压后上传)
#7)将rocketmq的bin目录配置环境变量中
[contentuser@localhost rocketmq]$ vi ~/.bash_profile
PATH=
R
O
C
K
E
T
M
Q
H
O
M
E
/
b
i
n
:
ROCKETMQ_HOME/bin:
ROCKETMQH?OME/bin:PATH:
H
O
M
E
/
.
l
o
c
a
l
/
b
i
n
:
HOME/.local/bin:
HOME/.local/bin:HOME/bin export ROCKET_HOME=/opt/huawei/rocketmq/bin Export PATH
:wq!
[contentuser@localhost rocketmq]$ source ~/.bash_profil
#8)修改启动配置,将java虚拟机内存调小(默认初始化内存需要4g)
[root@localhost bin]# vi runserver.sh
原值:
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m
修改后:(-Xmx:最大可用内存、-Xms:初始内存、-Xmn:年轻代大小)
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m
1.3 单机服务启动
#9)mqnamesrv 和nohup.out 需要调高文件执行权限
[root@localhost bin]# chmod 777 mqnamesrv
#10)启动服务
nohup bin/mqnamesrv &
启动成功:
OpenJDK 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 OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. The Name Server boot success. serializeType=JSON
插曲:因为修改runserver.sh时,将最大元空间的值320m,丢了m改成了320,所以2次启动都因为初始化元空间不足,启动失败。
二、RocketMQ集群安装
后补
|