rocketmq-4.4.0从零单排(详细参数与配置)

rocketmq采用netty作为底层通信框架,其中具体技术细节如下:

1、通信协议

rocketmq通信协议采用netty作为底层通信框架,协议格式采用自定义方式实现。具体协议如下:


rocketmq协议格式

(4个字节的数据包长度与4个字节的头长度,这个包长与头长怎么会一样?感觉可以再优化下)

2、通信加密

rocketmq采用netty链接时可以使用netty 的sslContext方式加密传输,不过需要加相关启动参数上(-Dkey=value),启动参数如下(省略-D):

tls.server.mode=disabled (不加密传输) / permissive (默认) / enforcing   (当然了,如果没有检测到证书路径也不会选择加密传输)

tls.server.certPath=xxx

tls.server.keyPath=xxx

tls.server.trustCertPath=xxx

以上三个均是证书路径,不过是服务端的,客户端也有,客户端如下:

tls.client.certPath=xxx

tls.client.keyPath=xxx

tls.client.trustCertPath=xxx

3、rocketmq-netty默认线程数量

rocketmq采用主从线程模型

thread-acceptor : 1

thread-boss : 3

thread-worker : 8

4、rocketmq可配参数


rocketmq组件配置架构图

1)netty-server-config参数

listenPort=8888

serverWorkerThreads=8 (这是worker线程)

serverCallbackExecutorThreads=0

serverSelectorThreads=3 (这是boss线程)

serverOnewaySemaphoreValue=256

serverAsyncSemaphoreValue=64

serverChannelMaxIdleTimeSeconds=120(默认空闲2分钟断掉)

serverSocketSndBufSize=65535

serverSocketRcvBufSize=65535

serverPooledByteBufAllocatorEnable=true(是否使用内存池,默认使用)

useEpollNativeSelector=false(是否采用netty自己实现的EpollLoopGroup)

2)  netty-client-config参数

clientWorkerThreads =4

clientCallbackExecutorThreads=核心数量

clientOnewaySemaphoreValue = 65535

clientAsyncSemaphoreValue = 65535

connectTimeoutMillis =3000

channelNotActiveInterval=1000 *60

clientChannelMaxIdleTimeSeconds=120

clientSocketSndBufSize = 65535

clientSocketRcvBufSize = 65535

clientPooledByteBufAllocatorEnable=false

clientCloseSocketIfTimeout=false

useTLS=false

3)nameserver-config参数

rocketmq.home.dir=xxx(这是启动参数,not properties)

user.home=xxx(启动参数,存放kvConfig.json、namesrv.properties)

productEnvName=center(默认生产环境名称)

orderMessageEnable=false(有序消息可用性)

4)  broker-config参数

aclEnable=false

adminBrokerThreadPoolNums=16

autoCreateSubscriptionGroup=true

autoCreateTopicEnable=true

brokerClusterName=DefaultCluster

brokerFastFailureEnable=true

brokerId=0

brokerIP1=localhost

brokerIP2=localhost

brokerName=localhost

brokerPermission=4 | 2 (read | write)

brokerTopicEnable=true

clientManagerThreadPoolQueueCapacity=1000000

clientManageThreadPoolNums=32

clusterTopicEnable=true

commercialBaseCount=1

commercialBigCount=1

commercialEnable=true

commercialTimerCount=1

commercialTransCount=1

compressedRegister=false

consumerFallbehindThreshold=1024L *1024 *1024 *16

consumerManagerThreadPoolQueueCapacity=1000000

consumerManageThreadPoolNums=32

defaultTopicQueueNums=8

disableConsumeIfConsumerReadSlowly=false

enableCalcFilterBitMap=false

enablePropertyFilter=false

endTransactionPoolQueueCapacity=100000

endTransactionThreadPoolNums=8 + 核心数量 *2

expectConsumerNumUseFilter=32

fetchNamesrvAddrByAddressServer=false

filterDataCleanTimeSpan=24 *3600 *1000

filterServerNums=0

filterSupportRetry=false

flushConsumerOffsetHistoryInterval=1000 *60

flushConsumerOffsetInterval=1000 *5

forceRegister=true

heartbeatThreadPoolNums=Math.min(32, 核心数量)

heartbeatThreadPoolQueueCapacity=50000

highSpeedMode=false

longPollingEnable=true

maxDelayTime=40

maxErrorRateOfBloomFilter=20

messageStorePlugIn=""

msgTraceTopicName=RMQ_SYS_TRACE_TOPIC

namesrvAddr=localhost:8080;localhost:8080

notifyConsumerIdsChangedEnable=true

pullMessageThreadPoolNums=16 + 核心数量 *2

pullThreadPoolQueueCapacity=100000

queryMessageThreadPoolNums=8 + 核心数量

queryThreadPoolQueueCapacity=20000

regionId=DefaultRegion

registerBrokerTimeoutMills=6000

registerNameServerPeriod=1000 *30

rejectTransactionMessage=false

rocketmqHome=你的环境变量-ROCKETMQ_HOME

sendMessageThreadPoolNums=1

sendThreadPoolQueueCapacity=10000

shortPollingTimeMills=1000

slaveReadEnable=false

startAcceptSendRequestTimeStamp=0

traceOn=true

traceTopicEnable=false

transactionCheckInterval=60 *1000

transactionCheckMax=15

transactionTimeOut=6 *1000

transferMsgByHeap=true

waitTimeMillsInHeartbeatQueue=31 *1000

waitTimeMillsInPullQueue=5 *1000

waitTimeMillsInSendQueue=200

waitTimeMillsInTransactionQueue=3 *1000

5) message-store-config

accessMessageInMemoryMaxRatio=40

bitMapLengthConsumeQueueExt=64

brokerRole=ASYNC_MASTER

checkCRCOnRecover=true

cleanFileForciblyEnable=true

cleanResourceInterval=10000

commitCommitLogLeastPages=4

commitCommitLogThoroughInterval=200

commitIntervalCommitLog=200

debugLockEnable=false

defaultQueryMaxNum=32

deleteCommitLogFilesInterval=100

deleteConsumeQueueFilesInterval=100

deleteWhen="04" // When to delete,default is at 4 am

destroyMapedFileIntervalForcibly=1000 *120

diskFallRecorded=true

diskMaxUsedSpaceRatio=75

duplicationEnable=false

enableConsumeQueueExt=false

fastFailIfNoBufferInStorePool=false

fileReservedTime=72

flushCommitLogLeastPages=4

flushCommitLogThoroughInterval=1000 *10

flushCommitLogTimed=false

flushConsumeQueueLeastPages=2

flushConsumeQueueThoroughInterval=1000 *60

flushDelayOffsetInterval=1000 *10

flushDiskType=ASYNC_FLUSH

flushIntervalCommitLog=500

flushIntervalConsumeQueue=1000

flushLeastPagesWhenWarmMapedFile=1024 /4 *16

haHousekeepingInterval=1000 *20

haListenPort=10912

haSendHeartbeatInterval=1000 *5

haSlaveFallbehindMax=1024 *1024 *256

haTransferBatchSize=1024 *32

mapedFileSizeCommitLog=1024 *1024 *1024

mappedFileSizeConsumeQueueExt=48 *1024 *1024

maxHashSlotNum=5000000

maxIndexNum=5000000 *4

maxMessageSize=1024 *1024 *4

maxMsgsNumBatch=64

maxTransferBytesOnMessageInDisk=1024 *64

maxTransferBytesOnMessageInMemory=1024 *256

maxTransferCountOnMessageInDisk=8

maxTransferCountOnMessageInMemory=32

messageDelayLevel=1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h

messageIndexEnable=true

messageIndexSafe=false

offsetCheckInSlave=false

osPageCacheBusyTimeOutMills=1000

putMsgIndexHightWater=600000

redeleteHangedFileInterval=1000 *120

storePathCommitLog=...

storePathRootDir=...

syncFlushTimeout=1000 *5

transientStorePoolEnable=false

transientStorePoolSize=5

useReentrantLockWhenPutMessage=false

warmMapedFileEnable=false

5 特殊参数

broker可以动态调整nameserver地址,频率是每2分钟以http的请求方式获取nameserver地址然后更新,这样可以增加系统高可用。热备broker链接nameserver需要启动参数,非配置文件,启动参数如下:

-Drocketmq.namesrv.domain=jmenv.tbsite.net

-Drocketmq.namesrv.domain.subgroup=nsaddr

默认 jmenv.tbsite.net:8080/rocketmq/nsaddr

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,589评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,615评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,933评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,976评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,999评论 6 393
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,775评论 1 307
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,474评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,359评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,854评论 1 317
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,007评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,146评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,826评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,484评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,029评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,153评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,420评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,107评论 2 356

推荐阅读更多精彩内容