官方下载地址
本次选择目前的全新发布版:4.9.2。下载二进制版的压缩包。
或者直接点击下载
Linux 环境下,使用以下命令下载:
wget https://dlcdn.apache.org/rocketmq/4.9.2/rocketmq-all-4.9.2-bin-release.zip
即你的Java环境变量是否正常。
将从官网下载的压缩包解压到一个指定目录:
我这里使用的目录是:D:\software\rocketmq\rocketmq-4.9.2
然后需要配置环境变量ROCKETMQ_HOME
。如下图所示:
切换到安装目录下的 bin文件下,打开 cmd 命令窗口:
D:\software\rocketmq\rocketmq-4.9.2\bin>start mqnamesrv.cmd
随后可能弹出一个命令窗口,内容如下:
Java HotSpot(TM) Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release Java HotSpot(TM) Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap D:\software\rocketmq\rocketmq-4.9.2\bin>
这个是因为启动时分配的内存太大了。需要修改一下:
在 bin 目录下找runserver.cmd
和runbroker.cmd
,编辑其内容。
若没有出现内存不足之类的问题,就可绕过 3.1和3.2的内容。
找到原文件中配置java内存的位置:
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
手动修改小一点即可。我这里将其修改为:
set "JAVA_OPT=%JAVA_OPT% -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
若没有出现内存不足之类的问题,就可绕过 3.1和3.2的内容。
找到原文件中配置java内存的位置:
set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g"
手动修改小一点即可。我这里将其修改为:
set "JAVA_OPT=%JAVA_OPT% -server -Xms256m -Xmx256m"
最后再次使用命令:start mqnamesrv.cmd
启动即可。
当输出了以下内容时,表示nameserver
启动成功了:
Java HotSpot(TM) Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release Java HotSpot(TM) Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. The Name Server boot success. serializeType=JSON
注意,启动成功后,输出以上信息的命令窗口不能关闭!
切换到bin目录下,新打开一个命令窗口,执行以下命令:
start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true
如果没有成功,出现以下信息:
Invalid maximum direct memory size: -XX:MaxDirectMemorySize=15g The specified size exceeds the maximum representable size. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
需要做以下修改:
编辑runbroker.cmd
将MaxDirectMemorySize
的大小放小,我这里调整为1g
再次启动出现以下信息表示成功了:
The broker[DESKTOP-R7J3BHB, 172.173.173.69:10911] boot success. serializeType=JSON and name server is 127.0.0.1:9876
使用命令mqadmin updateTopic -b 127.0.0.1:10911 -t topicname_fbb360 -n 127.0.0.1:9876
其中10911端口对应的是 broker的端口,topicname_fbb360
是我指定的主题名。
D:\software\rocketmq\rocketmq-4.9.2\bin>mqadmin updateTopic -b 127.0.0.1:10911 -t topicname_fbb360 -n 127.0.0.1:9876 RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.InternalThreadLocalMap). RocketMQLog:WARN Please initialize the logger system properly. create topic to 127.0.0.1:10911 success. TopicConfig [topicName=topicname_fbb360, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]
使用命令:mqadmin topicList -n 127.0.0.1:9876
D:\software\rocketmq\rocketmq-4.9.2\bin>mqadmin topicList -n 127.0.0.1:9876 RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.InternalThreadLocalMap). RocketMQLog:WARN Please initialize the logger system properly. SCHEDULE_TOPIC_XXXX RMQ_SYS_TRANS_HALF_TOPIC DefaultCluster_REPLY_TOPIC BenchmarkTest OFFSET_MOVED_EVENT DESKTOP-R7J3BHB topicname_fbb360 TBW102 SELF_TEST_TOPIC DefaultCluster
// TODO 待补充...
先参考:https://blog.csdn.net/wc1695040842/article/details/99941664