RocketMQ基于jdk17的win安装。
1、修改runbroker.cmd、runserver.cmd、tools.cmd三个启动脚本,如下:
runbroker.cmd
@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.
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"
rem 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% -XX:+UseZGC"
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xlog:gc:%USERPROFILE%\mq_gc.log"
rem 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"
rem set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
rem set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib;%JAVA_HOME%\jre\lib\ext"
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
"%JAVA%" %JAVA_OPT% %*
runserver.cmd
@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.
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"
rem 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% -XX:+UseZGC"
set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xlog:gc:"%USERPROFILE%\rmq_srv_gc.log""
set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
rem set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib;%JAVA_HOME%\jre\lib\ext"
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
"%JAVA%" %JAVA_OPT% %*
tools.cmd
@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.
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 -Xms1g -Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
rem set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs="%BASE_DIR%\lib";"%JAVA_HOME%\jre\lib\ext";"%JAVA_HOME%\lib\ext""
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
"%JAVA%" %JAVA_OPT% %*
2、设置win的环境变量 ROCKETMQ_HOME、NAMESRV_ADDR,因为jdk17删除了jre模块,使用classpath方式进行加载。将rocketMQ的lib依赖,一个一个怼进去。因为包很多,win的环境变量值长度限制,分了两个变量进行拼接。RCTMQ_LIB、RCTMQ_LIB_EXT,然后将这两变量,放到CLASSPATH后。
ROCKETMQ_HOME
D:\rocketmq-4.9.2
image.png
NAMESRV_ADDR
localhost:9876
image.png
RCTMQ_LIB
D:\rocketmq-4.9.2\lib\annotations-13.0.jar;D:\rocketmq-4.9.2\lib\commons-beanutils-1.9.4.jar;D:\rocketmq-4.9.2\lib\commons-cli-1.2.jar;D:\rocketmq-4.9.2\lib\commons-codec-1.9.jar;D:\rocketmq-4.9.2\lib\commons-collections-3.2.2.jar;D:\rocketmq-4.9.2\lib\commons-digester-2.1.jar;D:\rocketmq-4.9.2\lib\commons-lang3-3.4.jar;D:\rocketmq-4.9.2\lib\commons-logging-1.2.jar;D:\rocketmq-4.9.2\lib\commons-validator-1.7.jar;D:\rocketmq-4.9.2\lib\dledger-0.2.2.jar;D:\rocketmq-4.9.2\lib\fastjson-1.2.76.jar;D:\rocketmq-4.9.2\lib\gson-2.8.6.jar;D:\rocketmq-4.9.2\lib\guava-19.0.jar;D:\rocketmq-4.9.2\lib\jaeger-thrift-1.6.0.jar;D:\rocketmq-4.9.2\lib\jaeger-tracerresolver-1.6.0.jar;D:\rocketmq-4.9.2\lib\javassist-3.20.0-GA.jar;D:\rocketmq-4.9.2\lib\javax.annotation-api-1.3.2.jar;D:\rocketmq-4.9.2\lib\jcommander-1.72.jar;D:\rocketmq-4.9.2\lib\jna-4.2.2.jar;D:\rocketmq-4.9.2\lib\kotlin-stdlib-1.4.10.jar;D:\rocketmq-4.9.2\lib\kotlin-stdlib-common-1.4.0.jar;D:\rocketmq-4.9.2\lib\libthrift-0.14.1.jar;D:\rocketmq-4.9.2\lib\logback-classic-1.0.13.jar;D:\rocketmq-4.9.2\lib\logback-core-1.0.13.jar;D:\rocketmq-4.9.2\lib\netty-all-4.1.65.Final.jar;D:\rocketmq-4.9.2\lib\okhttp-4.9.0.jar;D:\rocketmq-4.9.2\lib\okio-2.8.0.jar;D:\rocketmq-4.9.2\lib\openmessaging-api-0.3.1-alpha.jar;D:\rocketmq-4.9.2\lib\opentracing-noop-0.33.0.jar;D:\rocketmq-4.9.2\lib\opentracing-tracerresolver-0.1.8.jar;D:\rocketmq-4.9.2\lib\opentracing-util-0.33.0.jar;D:\rocketmq-4.9.2\lib\rocketmq-acl-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-broker-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-client-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-common-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-example-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-filter-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-logging-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-namesrv-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-openmessaging-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-remoting-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-srvutil-4.9.2.jar;D:\rocketmq-4.9.2\lib\rocketmq-store-4.9.2.jar;
image.png
RCTMQ_LIB_EXT
D:\rocketmq-4.9.2\lib\rocketmq-tools-4.9.2.jar;D:\rocketmq-4.9.2\lib\slf4j-api-1.7.7.jar;D:\rocketmq-4.9.2\lib\snakeyaml-1.19.jar;D:\rocketmq-4.9.2\lib\tomcat-annotations-api-8.5.46.jar;D:\rocketmq-4.9.2\lib\tomcat-embed-core-8.5.46.jar;
image.png
最后将RCTMQ_LIB、RCTMQ_LIB_EXT放到CLASSPATH后面
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%RCTMQ_LIB%;%RCTMQ_LIB_EXT%;
image.png
3、启动rocketMQ。先启动bin目录下的mqnamesrv.cmd,再启动mqbroker.cmd
mqbroker.cmd启动命令:
mqbroker.cmd -n localhost:9876 autoCreateTopicEnable=true &
image.png
image.png
网友评论