对RocketMQ的初步理解

对RocketMQ的初步理解,第1张

对RocketMQ的初步理解

关于对rocketMQ初步学习,我有了一些简单的总结和个人感悟,希望能帮到您。
1、首先,需要了解什么是MQ,即它就是一个消息队列。就是一个消息传递的中间件。
2、MQ作为一个中间件,存在就有必要。即它的作用有三个:①限流削峰,代表是“双十一大购物”活动,将获取到的“很大的”订单信息保存在MQ中,不至于造成处理“拥挤”的现象,即暂存超量的作用。②异步解耦,代表是A系统对B系统的消息传输的时候,如果B系统出现问题,则整个系统将会“瘫痪”,但是在中间加一个MQ,则将同步传输调用变为异步传输调用,大大地保证了整个系统的安全性和提高了整个系统的可维护性。③数据收集和分发,代表就是手机的信息分发。
3、怎么在本地去配置一个RocketMQ
(1) 先下载两个文件(RocketMQ是apache下的项目)
路径:

路径:https://rocketmq.apache.org/release_notes/release-notes-4.9.2/

图示的两个压缩文件,需要解压

(2) 解压完成之后就是对电脑环境变量的配置
变量名:ROCKETMQ_HOME
变量值:F:rocketmq-all-4.9.2-bin-releaserocketmq-4.9.2(解压路径)

(3) 在bin目录写运行cmd命令,或直接cd进到bin目录下

***

启动RocketMQ,必须先启动Name Server,不要关闭窗口,继续启动Broker。
(4) 先启动运行 mqnamesrv.cmd
start mqnamesrv

出现运行成功显示:
如果出现提示VM不够用,后边会有补充说明。
(5) 不要关闭这个窗口,继续启动mqbroker.cmd

start mqbroker.cmd -n 127.0.0.1:9876 autoCreateTopicEnable=true

运行成功显示:

4、 问题说明
(1)RocketMQ NAMESERVER默认分配的jvm参数需要占用较大内存,一般pc没有这么大内存,需要修改小一些
修改的两个文件是

在runserver.cmd中,将2g改为512m即可。

set "JAVA_OPT=%JAVA_OPT% -server -Xms512m -Xmx512m -Xmn512m -XX:metaspaceSize=128m -XX:MaxmetaspaceSize=320m"
@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%binjava.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
set "JAVA=%JAVA_HOME%binjava.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 -Xmn512m -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;%JAVA_HOME%jrelibext"
set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""

"%JAVA%" %JAVA_OPT% %*

在runbroker.cmd中,直接删除15g的那一行就可以正常运行。

@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%binjava.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! & EXIT /B 1
set "JAVA=%JAVA_HOME%binjava.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 -Xms512m -Xmx512m"
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:-UseLargePages -XX:-UseBiasedLocking"
set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%base_DIR%lib;%JAVA_HOME%jrelibext"
set "JAVA_OPT=%JAVA_OPT% -cp %CLASSPATH%"

"%JAVA%" %JAVA_OPT% %*

6、关闭MQ

mqshutdown namesrv
mqshutdown broker


小小的分享就到这里,欢迎指教探讨和留言哦

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5604972.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存