Windows环境下RocketMQ安装时问题
步骤
- 去官网下载运行版本 zip
- 去git上下载管理端
安装问题
RocketMQ的目录和jdk的目录都不能有空格 否则提示找不到主类
无奈我的jdk很早就安装在了program files下面了 担心卸载了重新安装会有一些问题
解决:
在E:\mq\bin 修改 runserver.cmd文件
主要是添加了 set JAVAHOME="%JAVA_HOME%"
最终文件:
@echo off
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 -Xms512m -Xmx512m -Xmn256m -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% %*
在E:\mq\bin 修改 runbroker.cmd文件
最终文件:
@echo off
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%
rem ===========================================================================================
rem JVM Configuration
rem ===========================================================================================
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g"
set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%USERPROFILE%\mq_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
set "JAVA_OPT=%JAVA_OPT% -XX:+AlwaysPreTouch"
set "JAVA_OPT=%JAVA_OPT% -XX:MaxDirectMemorySize=15g"
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
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% %*
本地启动RocketMQ
在E:\mq\bin 输入cmd回车:
//启动namesrv
start mqnamesrv.cmd
//启动broker
start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true
//如果修改了broker namesrv的ip和端口 命令这里也要改
start mqbroker.cmd -n 10.90.28.90:8876 autoCreateTopicEnable=true
//启动了之后 可以自测
tools.cmd org.apache.rocketmq.example.quickstart.Consumer
tools.cmd org.apache.rocketmq.example.quickstart.Producer
修改RocketMQ的默认ip和端口
broker默认端口:
namesrv默认端口:9876
在E:\mq\conf 目录下 修改broker.conf文件
//新增如下配置
# 新增的配置,broker默认端口
namesrvAddr=10.90.28.90:8876
brokerIP1=10.90.28.90
listenPort=8911
启动管理端
- 修改resources下的application.yml文件
port:7000 随便写一个
namesrvAddrs:写你配置的ip和端口 如果没有改过,默认是127.0.0.1:9876 自定了端口后 10.90.28.90:8876
-
定位到pom目录下 输入cmd 回车敲命令:
//1.打包 Mvn clean package -Dmaven.test.skip=true //2.将tartget下面的jar拖到和pom同一级 //3.启动 java -jar rocketmq-dashboard-1.0.1-SNAPSHOT.jar