Rocketmq选型

Rocket是一个专业的队列服务,性能优于Rabbitmq,优势是性能和并发,源于Kafka的扩展版,增强了数据的可靠性。

Rocketmq的队列类型

普通队列,广播队列、顺序队列,分区顺序

2、同步机制

Rocketmq使用主从同步模式,同步分为同步和异步模式,这和mysql类似。

3、Rocketmq管理命令

rocketmq也可以通过web管理,坑中有说

创建topic

bin/mqadmin updateTopic -n '192.168.1.64:9876;192.168.1.107:9876' -c DefaultCluster -t tt -w 5 -r 5 -o=true   #-o=true是有序队列

Rocketmq坑

1、rocketmq 在本地搭建环境启动时,内存溢出报了内存错误:

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.

解决方法:修改bin/runbroker.sh,bin/runserver.sh

-server -Xms1g -Xmx1g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m

内存大的虚拟机没问题,像我这渣渣笔记本,得节省点啊!

2、Rocketmq管理web

https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console

下载安装Console项目

Rocketmq的普通队列、顺序队列、分区顺序队列、广播消息实现、事务队列

https://www.jianshu.com/p/3afd610a8f7d

https://www.jianshu.com/p/790d6bc4a1c1

https://www.jianshu.com/p/53324ea2df92

我遇到的坑

阿里云上面买的RocketMq和开源版本的Rocketmq的sdk不同,有着兼容问题。我们有一个自己机房和阿里的共用运行的服务,这时候发现只能在阿里机房上布,而在本地机房看来只能再写一套抽象层了,这非常不友好。使用了阿里的 Rocketmq也就意味着你的程序移植不到其它云或服务器上了。

slave 修改:

1、内存优化

bin/runbroker.sh MaxDirectMemorySize =15g  改成1g

2、host解析失败

在rocketmq的主从是通过获取hostname然后解析host到ip上进行互相访问的,所以需要将各机器的hosts增加解析

192.168.1.102       localhost.ceontsPHP

192.168.1.101       localhost.bobby

hostname可以通过各服务器的/etc/hostsname查看

rocket会报错:rocketmq Failed to obtain the host name

3、锁文件冲突原因

因为rocketmq设计一个用户运行一个示例,一个用户锁定了一个用户store存储目录,所以在一起运行会冲突,提示:Lock failed,MQ already startedz

解决方法是每个示例使用一个用户

broker.conf 指定 storePathRootDir目录

4、端口会冲突

不同broker需使用不同端口,如果不是root用户,端口号应该是1024+

一个broker不仅仅使用你指定的listenPort,上下最好空几个,比如指定1081端口,他还占用了1079 1081 1082

5、配置文件坑

我直接拿官方配置文件2m-2s-async下的配置,不行,没有提示,就是执行clusterList时,没有集群,这很坑,然后我自己建配置文件成功

bin/mqbroker -c /root/rocketmq/release/conf/2m-2s-async/broker-a-s.properties > a.log 2>&1

bin/mqadmin clusterList -n centos:9876

bin/mqadmin updateTopic -n 'centos:9876' -c mycluster -t tt -w 5 -r 5 -o=true

# broker a

namesrvAddr=centos:9876

brokerIP1=192.168.56.101

brokerName=broker-a

brokerClusterName=mycluster

brokerId=0

listenPort=1081

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

rejectTransactionMessage=false

fetchNamesrvAddrByAddressServer=false

storePathRootDir=/root/storeA

storePathCommitLog=/root/store/commitlog

flushIntervalCommitLog=500

commitIntervalCommitLog=200

flushCommitLogTimed=false

deleteWhen=04

fileReservedTime=48

maxTransferBytesOnMessageInMemory=262144

maxTransferCountOnMessageInMemory=32

maxTransferBytesOnMessageInDisk=65536

maxTransferCountOnMessageInDisk=8

accessMessageInMemoryMaxRatio=40

messageIndexEnable=true

messageIndexSafe=false

haMasterAddress=

brokerRole=ASYNC_MASTER

flushDiskType=ASYNC_FLUSH

cleanFileForciblyEnable=true

transientStorePoolEnable=false

#broker a-s

namesrvAddr=centos:9876

brokerIP1=192.168.56.102

brokerName=broker-a

brokerClusterName=mycluster

brokerId=1

listenPort=1091

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

rejectTransactionMessage=false

fetchNamesrvAddrByAddressServer=false

storePathRootDir=/root/storeAs

storePathCommitLog=/root/store/commitlog

flushIntervalCommitLog=500

commitIntervalCommitLog=200

flushCommitLogTimed=false

deleteWhen=04

fileReservedTime=48

maxTransferBytesOnMessageInMemory=262144

maxTransferCountOnMessageInMemory=32

maxTransferBytesOnMessageInDisk=65536

maxTransferCountOnMessageInDisk=8

accessMessageInMemoryMaxRatio=40

messageIndexEnable=true

messageIndexSafe=false

haMasterAddress=

brokerRole=SLAVE

flushDiskType=ASYNC_FLUSH

cleanFileForciblyEnable=true

transientStorePoolEnable=false

#broker b

namesrvAddr=centos:9876

brokerIP1=192.168.56.101

brokerName=broker-b

brokerClusterName=mycluster

brokerId=0

listenPort=1085

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

rejectTransactionMessage=false

fetchNamesrvAddrByAddressServer=false

storePathRootDir=/root/storeB

storePathCommitLog=/root/store/commitlog

flushIntervalCommitLog=500

commitIntervalCommitLog=200

flushCommitLogTimed=false

deleteWhen=04

fileReservedTime=48

maxTransferBytesOnMessageInMemory=262144

maxTransferCountOnMessageInMemory=32

maxTransferBytesOnMessageInDisk=65536

maxTransferCountOnMessageInDisk=8

accessMessageInMemoryMaxRatio=40

messageIndexEnable=true

messageIndexSafe=false

haMasterAddress=

brokerRole=ASYNC_MASTER

flushDiskType=ASYNC_FLUSH

cleanFileForciblyEnable=true

transientStorePoolEnable=false

#broker b-s

namesrvAddr=centos:9876

brokerIP1=192.168.56.102

brokerName=broker-b

brokerClusterName=mycluster

brokerId=1

listenPort=1095

autoCreateTopicEnable=true

autoCreateSubscriptionGroup=true

rejectTransactionMessage=false

fetchNamesrvAddrByAddressServer=false

storePathRootDir=/root/storeBs

storePathCommitLog=/root/store/commitlog

flushIntervalCommitLog=500

commitIntervalCommitLog=200

flushCommitLogTimed=false

deleteWhen=04

fileReservedTime=48

maxTransferBytesOnMessageInMemory=262144

maxTransferCountOnMessageInMemory=32

maxTransferBytesOnMessageInDisk=65536

maxTransferCountOnMessageInDisk=8

accessMessageInMemoryMaxRatio=40

messageIndexEnable=true

messageIndexSafe=false

haMasterAddress=

brokerRole=SLAVE

flushDiskType=ASYNC_FLUSH

cleanFileForciblyEnable=true

transientStorePoolEnable=false

rocketmq sdk使用newFixThreadPool线程池用于获取server中的数据(线程数获取的cpu核心数),拿到消息后,submit 给->ThreadPoolExecutor线程池进行执行消费,执行消费可以指定最大线程数和最小线程数。

rocketmq多消费端是需要通过tag指定的,如果你想和使用rabbitmq一样使用,可能会疯,百度搜出来的鸡八狗屁文章,根本狗屁不通。

rocketmq 存储结构:
https://blog.csdn.net/mr253727942/article/details/55805876

IO调度方式:

https://www.cnblogs.com/cobbliu/p/5389556.html

rocketmq 记的更多相关文章

  1. RocketMQ初入门踩坑记

    本文主要是讲在Centos中安装RocketMQ并做简单的示例.如果你按照本文安装100%是可以成功的,如果按照阿里官方的说明,那只能呵呵了~ 安装 官方地址为:https://rocketmq.ap ...

  2. 记一次RocketMQ源码导入IDEA过程

    首先,下载源码,可以官网下载source包,也可以从GitHub上直接拉下来导入IDEA.如果是官网下载的source zip包,直接作为当前project的module导入,这里不赘述太多,只强调一 ...

  3. RocketMQ踩坑记

    一.前言 现在的主流消息队列基本都是kafka.RabbitMQ和RocketMQ,只有了解各自的优缺点才能在不同的场景选择合适的MQ,对比图如下: MQ对比图 本篇文章主要介绍我自己在跑官方demo ...

  4. 记一次 RocketMQ broker 因内存不足导致的启动失败

    原创:西狩 编写日期 / 修订日期:2020-01-12 / 2020-01-12 版权声明:本文为博主原创文章,遵循 CC BY-SA-4.0 版权协议,转载请附上原文出处链接和本声明. 背景 该小 ...

  5. rocketmq搭建趟坑记

    这个坑对小白来讲可能要趟很久才能过,我就是这样~~明明很简单的配置,搞了半天 我用的是rocketmq4.1.0,配置了jvm参数,都能正常启动,且能在线上运行demo,但是线下就是连不上 在conf ...

  6. RocketMQ采坑记

    先来一篇解释比较多的实例 https://www.cnblogs.com/super-d2/p/4154541.html No route info of this topic, PushTopic ...

  7. RocketMQ原理解析-Producer

    producer  producer 1.启动流程 Producer如何感知要发送消息的broker即brokerAddrTable中的值是怎么获得的, 1. 发送消息的时候指定会指定topic,如果 ...

  8. rocketmq 发送时异常:system busy 和 broker busy 解决方案

    记一次 rocketmq 使用时的异常. 这里就不说什么rocketmq 源码啥的了,因为没看过.网上一搜这两个异常 大部分都是什么源码解读,也没说出现后的解决办法(蓝瘦香菇). 大量测试发现: 1. ...

  9. rocketmq (一)运行原理以及使用问题

    使用消息中间件可以解决高并发,那是因为消息中间件可以将消息缓存到队列之中. 但是 当消息 过多的时候,几万,几十万...消息中间件也可能会宕机,所以我们可以对消息中间件进行集群,在之前的activem ...

随机推荐

  1. 【HLSDK系列】怎么增加一种新实体

    你平常肯定接触到很多比如 info_player_start hostage info_target 之类的实体,这里就解释一下怎么创建一种新的实体. 首先建立一个新的 .h 文件(当然你写在现有的文 ...

  2. 【CF438E】The Child and Binary Tree(多项式运算,生成函数)

    [CF438E]The Child and Binary Tree(多项式运算,生成函数) 题面 有一个大小为\(n\)的集合\(S\) 问所有点权都在集合中,并且点权之和分别为\([0,m]\)的二 ...

  3. Yii2 控制器单独向view(layout)传值

    Yii2,layout中使用Controller的值,Controller向layout传值的两种方式. yii2中在通过Controller向layout中传值,layout中访问Controlle ...

  4. java根据系统生成临时文件

    createTempFile 会根据当前系统,自动找系统的临时文件目录,在此目录下生成临时文件

  5. selenium - webdriver - 截图方法get_screenshot_as_file()

    WebDriver提供了截图函数get_screenshot_as_file()来截取当前窗口. from selenium import webdriver from time import sle ...

  6. centos7安装python-pip(转)

    好久没更新博客了............. 来一发................ 在使用centos7的软件包管理程序yum安装python-pip的时候会报一下错误: No package pyt ...

  7. bzoj 1053

    代码: //本题要求不超过n的因子最多的最小的数,我们知道因子的个数可以有素因子的指数得出,题目限制n是2e9,我们可以排除掉一些情况然后暴力 //对于一个数必然是因子越小他的因子数越多,所以枚举最小 ...

  8. zabbix 监控 Esxi

    一.下载模板 http://www.zabbix.org/wiki/Zabbix_Templates 我这边ESXI 版本是6.0的,但是模板只有5,也可以用 二.添加模板 配置 ---> 模板 ...

  9. Tensorflow实现学习率衰减

    Tensorflow实现学习率衰减 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 Deeplearning AI Andrew Ng Tensorflow1.2 API 学习率衰减 ...

  10. JS中的匿名函数自执行、函数声明与函数表达式

    先看一段jQuery源码中匿名函数自执行的例子: (function( window, undefined ) { // jquery code })(window); 另外一种常见的写法: +fun ...