一,Rocketmq是什么?

1, RocketMQ是一个队列模型的消息中间件,具有高性能、高可靠、高实时、分布式特点

相比kafka,rocketmq的实时性更强

2,官方网站:
http://rocketmq.apache.org/

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,下载:

从官网找到下载地址后:
[root@localhost rocketmq]# pwd
/usr/local/source/rocketmq
[root@localhost rocketmq]# wget https://mirror.bit.edu.cn/apache/rocketmq/4.7.1/rocketmq-all-4.7.1-bin-release.zip

保存到源安装文件目录

三,解压:

[root@localhost rocketmq]# unzip rocketmq-all-4.7.1-bin-release.zip

移动到安装目录:

[root@localhost rocketmq]# mv rocketmq-all-4.7.1-bin-release /usr/local/soft/

四,配置rocketmq

1,配置conf文件:
[root@localhost rocketmq-all-4.7.1-bin-release]# vi conf/broker.conf
添加两行:
namesrvAddr = 127.0.0.1:9876
autoCreateTopicEnable = true
2,修改runserver.sh启动参数:
[root@localhost rocketmq-all-4.7.1-bin-release]# vi bin/runserver.sh

因为占用内存较多,需要改小,如果内存充足可以不改

原代码:
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
修改为:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”
 
3,修改runbroker.sh启动参数
[root@localhost rocketmq-all-4.7.1-bin-release]# vi bin/runbroker.sh
原代码:
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g" 
修改为:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m"

五,生成启动和关闭的脚本:

[root@localhost rocketmq-all-4.7.1-bin-release]# vi start_namesrv.sh
代码:
nohup sh bin/mqnamesrv &
 
[root@localhost rocketmq-all-4.7.1-bin-release]# vi stop_namesrv.sh
代码:
sh bin/mqshutdown namesrv
[root@localhost rocketmq-all-4.7.1-bin-release]# vi start_broker.sh
代码:
nohup sh bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf &
[root@localhost rocketmq-all-4.7.1-bin-release]# vi stop_broker.sh
代码:
sh bin/mqshutdown broker
给脚本增加执行权限:
[root@localhost rocketmq-all-4.7.1-bin-release]# chmod +x *.sh

六,用java13启动rocketmq4.7.1时的报错:

说明:启动时会出现报错是因为rocketmq针对的jdk版本较低,有一些启动项在新版java上已删除

如果使用低版本的jdk8可以解决,如果不想降低版本则需修改启动项

1,解决启动nameserver时报错:
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Unrecognized VM option 'UseCMSCompactAtFullCollection'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit. 
 解决:
修改bin/runserver.sh
注释掉下面一行:
#JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemar
kEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
修改为:
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB
=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 "
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_srv_gc_%p_%t.log instead.
Unrecognized VM option 'UseGCLogFileRotation'
Error: Could not create the Java Virtual Machine.
解决 :
修改bin/runserver.sh
注释掉下面这一行
#JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_srv_gc_%p_%t.log instead.
-Djava.ext.dirs=/usr/local/soft/jdk-13/jre/lib/ext:/usr/local/soft/rocketmq-all-4.7.1-bin-release/bin/../lib:/usr/local/soft/jdk-13/lib/ext is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
解决:
修改bin/runserver.sh
注释掉下面这一行
#JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"

报错:

[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqnamesrv
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_srv_gc_%p_%t.log instead.
[0.001s][warning][gc] -XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.
[0.009s][info ][gc] Using Concurrent Mark Sweep
错误: 找不到或无法加载主类 org.apache.rocketmq.namesrv.NamesrvStartup
原因: java.lang.ClassNotFoundException: org.apache.rocketmq.namesrv.NamesrvStartup
解决:
修改bin/runserver.sh
注释掉这一行
#export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
修改为:
export CLASSPATH=${BASE_DIR}/lib/rocketmq-namesrv-4.7.1.jar:${BASE_DIR}/lib/*:${BASE_DIR}/conf:${CLASSPATH}:${CLASS_PATH}
2,启动broker时的报错
报错1
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf
[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_broker_gc_%p_%t.log instead.
Unrecognized VM option 'PrintGCDateStamps'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
报错2:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf
[0.004s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_broker_gc_%p_%t.log instead.
Unrecognized VM option 'PrintGCApplicationStoppedTime'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
上面两个报错的解决:
修改bin/runbroker.sh
把下面一行注释掉
#JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCAppli
cationStoppedTime -XX:+PrintAdaptiveSizePolicy”
替换为:
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails"
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf
[0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_broker_gc_%p_%t.log instead.
Unrecognized VM option 'UseGCLogFileRotation'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
解决:
修改bin/runbroker.sh
注释掉下面一行:
#JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf
[0.001s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_broker_gc_%p_%t.log instead.
-Djava.ext.dirs=/usr/local/soft/jdk-13/jre/lib/ext:/usr/local/soft/rocketmq-all-4.7.1-bin-release/bin/../lib:/usr/local/soft/jdk-13/lib/ext is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
解决:
修改bin/runbroker.sh
注释掉下面一行
#JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
报错:
[root@localhost rocketmq-all-4.7.1-bin-release]# bin/mqbroker -c /usr/local/soft/rocketmq-all-4.7.1-bin-release/conf/broker.conf
[0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmq_broker_gc_%p_%t.log instead.
[0.001s][warning][gc] -XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.
[2.073s][info ][gc] Using G1
[2.124s][info ][gc] Periodic GC disabled
错误: 找不到或无法加载主类 org.apache.rocketmq.broker.BrokerStartup
原因: java.lang.ClassNotFoundException: org.apache.rocketmq.broker.BrokerStartup
解决:
修改bin/runbroker.sh
注释掉下面一行
#export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
替换为:
export CLASSPATH=${BASE_DIR}/lib/rocketmq-broker-4.7.1.jar:${BASE_DIR}/lib/*:${BASE_DIR}/conf/:.:${CLASSPATH}:${CLASS_PATH} 

七,启动rocketmq

先启动namesrv
[root@localhost rocketmq-all-4.7.1-bin-release]# ./start_namesrv.sh
[root@localhost rocketmq-all-4.7.1-bin-release]# nohup: 把输出追加到 'nohup.out'
再启动broker
[root@localhost rocketmq-all-4.7.1-bin-release]# ./start_broker.sh
[root@localhost rocketmq-all-4.7.1-bin-release]# nohup: 把输出追加到 'nohup.out'

八,测试安装效果:

1,通过jps查看进程:
[root@localhost rocketmq-all-4.7.1-bin-release]# /usr/local/soft/jdk-13/bin/jps
66026 BrokerStartup
65610 NamesrvStartup
66573 Jps
2,查看rocketmq生成的日志:
[root@localhost rocketmq-all-4.7.1-bin-release]# tail -f ~/logs/rocketmqlogs/broker.log
2020-09-11 15:25:55 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-09-11 15:25:55 INFO brokerOutApi_thread_3 - register broker[0]to name server 127.0.0.1:9876 OK
2020-09-11 15:26:25 INFO brokerOutApi_thread_4 - register broker[0]to name server 127.0.0.1:9876 OK
2020-09-11 15:26:55 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2020-09-11 15:26:55 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-09-11 15:26:55 INFO brokerOutApi_thread_1 - register broker[0]to name server 127.0.0.1:9876 OK
2020-09-11 15:27:25 INFO brokerOutApi_thread_2 - register broker[0]to name server 127.0.0.1:9876 OK
2020-09-11 15:27:55 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2020-09-11 15:27:55 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-09-11 15:27:55 INFO brokerOutApi_thread_3 - register broker[0]to name server 127.0.0.1:9876 OK
3,手动用命令创建topic
[root@localhost rocketmq-all-4.7.1-bin-release]# ./bin/mqadmin updateTopic -t laoliutest -b localhost:10911 -n localhost:9876
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.PlatformDependent0$1 (file:/usr/local/soft/rocketmq-all-4.7.1-bin-release/lib/netty-all-4.0.42.Final.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.PlatformDependent0$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
create topic to localhost:10911 success.
TopicConfig [topicName=laoliutest, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false][root@localhost rocketmq-all-4.7.1-bin-release]#

查看topic列表:

[root@localhost rocketmq-all-4.7.1-bin-release]# ./bin/mqadmin topicList  -n localhost:9876
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.PlatformDependent0$1 (file:/usr/local/soft/rocketmq-all-4.7.1-bin-release/lib/netty-all-4.0.42.Final.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.PlatformDependent0$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
laoliutest
SCHEDULE_TOPIC_XXXX
RMQ_SYS_TRANS_HALF_TOPIC
DefaultCluster_REPLY_TOPIC
BenchmarkTest
OFFSET_MOVED_EVENT
broker-a
TBW102
SELF_TEST_TOPIC
DefaultCluster

可以看到我们已创建的laoliutest这个topic

 

九,查看java的版本:

[root@localhost rocketmq-all-4.7.1-bin-release]# java --version
java 13 2019-09-17
Java(TM) SE Runtime Environment (build 13+33)
Java HotSpot(TM) 64-Bit Server VM (build 13+33, mixed mode, sharing)

十,查看linux的版本:

[root@localhost java]$ cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

linux(centos8):基于java13安装rocketmq-4.7.1(解决jdk不兼容的报错)的更多相关文章

  1. Perl Tk在IC设计中的应用、Windows、Linux平台下的安装-各种错误的摸索解决

    本文转自:自己的微信公众号<集成电路设计及EDA教程> <Perl Tk在IC设计中的应用.Windows.Linux平台下的安装-各种错误的摸索解决> Perl在IC设计中有 ...

  2. 01-路由跳转 安装less this.$router.replace(path) 解决vue/cli3.0语法报错问题

    2==解决vue2.0里面控制台包的一些语法错误. https://www.jianshu.com/p/5e0a1541418b 在build==>webpack.base.conf.j下注释掉 ...

  3. linux(centos8):kubeadm单机安装kubernetes(kubernetes 1.18.3)

    一,kubernetes安装的准备工作: 1,准备工作的各步骤请参见: https://www.cnblogs.com/architectforest/p/13141743.html   2,  ma ...

  4. 【cypress】2. 安装Cypress(windows系统),以及cypress open报错解决。

    安装cypress. 一.操作系统 先确认下你的系统,是否在cypress支持范围之内: macOS 10.9 以上 (仅64-bit) Linux Ubuntu 12.04及以上版本,Fedora ...

  5. 【干货】YUM安装PHP 7版本后,增加phalcon框架的报错解决

    目录 1.yum安装php 7.x版本,此处部署7.3版本 2.安装phalcon框架 2.1.PHP版本依赖关系 2.2.编译phalcon扩展模块 2.3.增加扩展文件 3.部署phalcon遇到 ...

  6. [Python]安装完pip、pygame后,仍然import pygame报错

    按照<python编程从入门到实践>上的教程下载了pygame的whl文件进行安装, 在cmd窗口里import pygame提示无错误,在IDEL里程序也能正常运行, 但是pycharm ...

  7. robotframework安装与运行(ride.py1.7.4.2命令报错)(win10+python3.8.1)

    首先,robotframework必须在python的环境下运行 所以你的电脑里必须有python3.x的环境先. 上古时期的robotframework只支持python2,不过python2都已经 ...

  8. linux(centos8):为prometheus安装grafana(grafana-7.0.3)

    一,grafana的用途 1,grafana是什么? grafana 是用 go 语言编写的开源应用, 它的主要用途是大规模指标数据的可视化展现 它是现在网络架构/应用分析中最流行的时序数据展示工具 ...

  9. Linux 系统基于 Hadoop 安装 Hive

    [注意]安装hive前提是要先安装hadoop集群,并且hive只需要在hadoop的namenode节点集群里安装即可(在所有的namenode上安装),可以不在datanode节点的机器上安装. ...

随机推荐

  1. 《Linux 操作系统》Linux的常用命令操作大全

    前言 在学习命令之前先学习我们该如何去学习linux 命令. 几乎每一个命令都有参数,每个参数的含义是什么,我们一般也不是全部都能记住,所以我们必须有一个可以知道每一个命令下各个参数的含义的方法. 命 ...

  2. 二、loadrunner参数化连接数据库

    2.连接sqlserver数据库.oracle数据库或mysql数据库(只有mysql数据库驱动需要先手动安装) 2.1.新建一个参数,随便设置file还是table类型之类的 2.2.点击Data ...

  3. Linux打包压缩解压工具

    第1章      Linux 打包压缩解压工具一.压缩.解压工具 compress/uncompress gzip/gunzip bzip2/bunzip2/ bzcat xz/unxz/ xzcat ...

  4. redis并发问题2

    转自https://mp.weixin.qq.com/s?__biz=MzI1NDQ3MjQxNA==&mid=2247485464&idx=1&sn=8d690fc6f878 ...

  5. 5.Storm-集群配置及任务提交

  6. 原子类CAS的底层实现

    原子类使用 public class CASDemo { public static void main(String[] args) { AtomicInteger atomicInteger = ...

  7. spring ioc 源码分析之-- beanDefinition的加载过程以及ComponentScan,@componet,@import @Bean等注解解析过程

    背景:我们启动主启动类后,相应的bean就被扫描进来了,原理是啥? 实现该功能的主要核心类就是:ConfigurationClassPostProcessor,我们看看他的继承体系: 它实现了Bean ...

  8. Tomcat学习小记(一)

    1.Tomcat概述 Tomcat 服务器是一个开源的轻量级Web应用服务器,擅长处理动态资源,在中小型系统和并发量小的场合下被普遍使用,是开发和调试Servlet.JSP 程序的首选. Tomcat ...

  9. Python-集合 字典-set dict fronzenset

    集合 set 1. 无序 2. 去重 3. 定义空集 set() numbers = {1, 3, 4, 5, 6, 5, 4, 4, 7, 8} print(numbers) print(numbe ...

  10. 使用maven整合mybatis时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    分析原因是mybatis的映射文件的问题,首先进行分析排查: 1.检查mapper接口和对应的xml文件的包名是否对应 2.检查xml文件的namespace与mapper接口的包名是否对应 3.检查 ...