1. 下载
官方地址:http://rocketmq.apache.org/
2. Windows 下安装
-
解压文件夹 -
配置环境变量 变量名:ROCKETMQ_HOME 变量值:MQ解压路径\MQ文件夹名 eg、ROCKETMQ_HOME=D:\dev\rocketmq-all-4.3.0-bin-release -
修改bin目录下的runbroker.cmd和 runserver.cmd文件 比如把8g 4g 改成512m, 4g 2g改成256m 如果启动报错找不到启动类,把红框中的内容复制替换即可。 @echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
set JAVAHOME="%JAVA_HOME%"
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
set "JAVA=%JAVA_HOME%\bin\java.exe"
setlocal
set BASE_DIR=%~dp0
set BASE_DIR=%BASE_DIR:~0,-1%
for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd
set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
set "JAVA_OPT=%JAVA_OPT% -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:"%USERPROFILE%\rmq_srv_gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib;%JAVAHOME%\jre\lib\ext"
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
"%JAVA%" %JAVA_OPT% %*
-
启动 Cmd命令框执行进入至‘MQ文件夹\bin’下,然后执行‘start mqnamesrv.cmd’,启动NAMESERVER。 成功后会弹出提示框,此框勿关闭。 Cmd命令框执行进入至‘MQ文件夹\bin’下,然后执行‘start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true’,启动BROKER。成功后会弹出提示框,此框勿关闭。
3. CentOS 下安装
-
首先将安装包上传至服务器,然后解压压缩包,改个名字 unzip rocketmq-all-4.9.2-bin-release.zip
mv rocketmq-4.9.2 rocketmq
-
创建数据存储目录 mkdir -p /opt/rocketmq/store/broker-a /opt/rocketmq/store/broker-a/consumequeue /opt/rocketmq/store/broker-a/commitlog /opt/rocketmq/store/broker-a/index
/opt/rocketmq/broker-a/logs
-
修改配置文件 cd /opt/rocketmq/conf
vim broker.conf
增加内容:
listenPort=10911
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
namesrvAddr=localhost:9876
storePathRootDir=/opt/rocketmq/store/broker-a
storePathCommitLog=/opt/rocketmq/store/broker-a/commitlog
storePathConsumeQueue=/opt/rocketmq/store/broker-a/consumequeue
storePathIndex=/opt/rocketmq/store/broker-a/index
storeCheckpoint=/opt/rocketmq/store/broker-a/checkpoint
abortFile=/opt/rocketmq/store/broker-a/abort
在虚拟机中有可能因为内存不够而启动失败 修改bin目录下的runbroker.sh 和 runserver.sh 文件 比如把8g 4g 改成512m, 4g 2g改成256m cd /opt/rocketmq/bin
-
启动 依次启动nameserver和broker 这两个命令可以做成alias nohup sh mqnamesrv &
nohup sh mqbroker -c /opt/rocketmq/conf/broker.conf &
-
查看日志 tail -f ~/logs/rocketmqlogs/namesrv.log
tail -f ~/logs/rocketmqlogs/broker.log
-
关闭服务 在bin目录下 cd /opt/rocketmq/bin
sh mqshutdown namesrv
sh mqshutdown broker
4. RocketMQ web控制台安装
windows和Linux两者都可以安装,都需要下载源码编译使用。
-
首先下载源代码 cd /usr/local/soft
wget https://github.com/apache/rocketmq-externals/archive/master.zip
下载慢可以用复制链接到迅雷里面。或者从百度网盘下载: 链接:https://pan.baidu.com/s/1GrkF793XlgQSAE0h1cQtgA 提取码:mh5i 解压:(百度网盘中的) tar -xvf rocketmq-externals-master.tar
解压出来的文件夹名字: rocketmq-externals-master -
修改配置文件 cd /opt/rocketmq-externals-master/rocketmq-console/src/main/resources/
vim application.properties
修改端口号 server.port=7298
修改name server地址(多个地址用英文分号隔开) rocketmq.config.namesrvAddr=localhost:9876
注意后面改了配置文件要重新打包 -
编译 cd /opt/rocketmq-externals-master/rocketmq-console/
mvn clean package -Dmaven.test.skip=true
-
启动jar cd target
java -jar rocketmq-console-ng-2.0.0.jar
-
访问 浏览器中输入‘127.0.0.1:配置端口’,成功后即可查看。 eg:http://127.0.0.1:7298
|