rocketmq local debugging environment of those things build

The last article, we have introduced rocketmq cluster environment to build, but in the source of learning, we need to locate local and debugging problems to find, after all, convenient locally, today to talk about how to source local debugging

Download compiled

Rocketmq source for learning part, of course, we must first go to the official network will download to a local source, I use here it is version 4.5.2 downloaded from github Shangguan online:

https://github.com/apache/rocketmq

rocketmq Version: 4.5.2

Use clean install compiled here the best skip the test, or else too slow


Compilation 1

Compilation 2

Start the local deployment debugging environment after the completion of the translation

Single point configuration

Local start-up and the same cluster are two major deployment order, start namesrv restart broker, before I have explained before startup script, if you have the impression, then, mainly related to two categories as follows entrance, find the corresponding startup class:

  • namesrv: org.apache.rocketmq.namesrv.NamesrvStartup
  • broker: org.apache.rocketmq.broker.BrokerStartup

NamesrvStartup

BrokerStartup

Before the next start in the conf distribution, broker.conf, logback_broker.xml, logback_namesrv.xml placed in the corresponding local folder, I've put the E: \ rocketmq under conf, add parameters to load at startup \

Since the beginning of the program user.home most default addresses are set, we need to make changes here broker.conf file parameters amended as follows:

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH

#nameServer 地址 分号分割
namesrvAddr=127.0.0.1:9876
#存储路径
storePathRootDir=E:\\rocketmq\\store
#commitLog 存储路径
storePathCommitLog=E:\\rocketmq\\store\\commitlog
消费队列存储路径
storePathConsumeQueue=E:\\rocketmq\\store\\consumequeue
消息索引|存储路径
storePathindex=E:\\rocketmq\\store\\index
#checkpoint 文件存储路径
storeCheckpoint=E:\\rocketmq\\store\\checkpoint
#abort 文件存储路径
abortFile=E:\\rocketmq\\store\\abort

Also note that no spaces, spaces will cause the file path is incorrect, not start!

logback file must also be modified in order to distinguish namesrv and broker log, with two folders

Logback_namesrv.xml the modifications: $ {user.home} Review of E: / rocketmq / namesrvlog

Logback_broker.xml the modifications: $ {user.home} Review of E: / rocketmq / brokerlog

Thus the basic configuration environment has been ready

单点环境启动

设置ROCKETMQ_HOME环境变量,让应用找到配置文件,不设置则报错(源码部分可看出来),另外设置时一定要注意不要有空格,有空格也报错,如下:


Start error

idea中设置环境变量:


Start error

启动namesrv服务:


namesrv start

继续启动broker,同样设置环境变量ROCKETMQ_HOME,然后BrokerStartup run启动下,可以看到报错,已经指定了ROCKETMQ_HOME怎么还报这个?因为未指定broker.conf配置文件,在集群部署的时候脚本后面参数这里也是有这个的,这里指定:

-c E:\rocketmq\conf\broker.conf


broker configuration

broker started

这里需要注意如果未配置namesrv也会启动成功,此时未连接namesrv,最好去看下log日志确认下是否连接成功

日志部分可去查看brokerlog\logs\rocketmqlogs和namesrvlog\logs\rocketmqlogs的日志内容,如启动有问题控制台看不出来,可以在这里查看详细的启动日志信息,或调整日志配置文件等级查看更详细的内容

接下来通过org.apache.rocketmq.example.quickstart包快速启动生产者和消费者来进行本地测试,设置namesrv地址,producer.setNamesrvAddr("127.0.0.1:9876"),启动生产者org.apache.rocketmq.example.quickstart.Producer


producer start

消费者同样设置namesrv地址,consumer.setNamesrvAddr("127.0.0.1:9876"),启动消费者org.apache.rocketmq.example.quickstart.Consumer


consumer launch

console

为了本地观察的方便,将console也进行本地启动,便于本地调试观察,源码地址为:

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

I will create a new source in the local module, code import, convenient local start


console module

Also add the startup configuration namesrv Address:


console configuration

After starting the browser to access port 8080 success


console launch

At this point Single point be set up is completed, after learning the source code debugging can be carried out on the basis of

Dual master configuration environment

Not a slave to build a clustered environment, directly to local debugging double master like, first modify the configuration file, the file is placed in E: \ rocketmq \ conf \ 2m below:

broker-a profile:

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#Broker 对外服务的监听端口
listenPort=10911
#nameServer 地址 分号分割
namesrvAddr=127.0.0.1:9876
#存储路径
storePathRootDir=E:\\rocketmq\\2m\\store-a
#commitLog 存储路径
storePathCommitLog=E:\\rocketmq\\2m\\store-a\\commitlog
消费队列存储路径
storePathConsumeQueue=E:\\rocketmq\\2m\\store-a\\consumequeue
消息索引|存储路径
storePathindex=E:\\rocketmq\\2m\\store-a\\index
#checkpoint 文件存储路径
storeCheckpoint=E:\\rocketmq\\2m\\store-a\\checkpoint
#abort 文件存储路径
abortFile=E:\\rocketmq\\2m\\store-a\\abort

broker-b configuration file:

brokerClusterName = DefaultCluster
brokerName = broker-b
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#Broker 对外服务的监听端口
listenPort=10921
#nameServer 地址 分号分割
namesrvAddr=127.0.0.1:9876
#存储路径
storePathRootDir=E:\\rocketmq\\2m\\store-b
#commitLog 存储路径
storePathCommitLog=E:\\rocketmq\\2m\\store-b\\commitlog
消费队列存储路径
storePathConsumeQueue=E:\\rocketmq\\2m\\store-b\\consumequeue
消息索引|存储路径
storePathindex=E:\\rocketmq\\2m\\store-b\\index
#checkpoint 文件存储路径
storeCheckpoint=E:\\rocketmq\\2m\\store-b\\checkpoint
#abort 文件存储路径
abortFile=E:\\rocketmq\\2m\\store-b\\abort

Note the different configurations in which the write port to avoid conflicts

Log lower part own reference Single point configuration, not described herein, may not be provided directly to start, where to start the broker-a

-c E:\rocketmq\conf\2m\broker-a.conf


broker-a start

The same way to start the broker-b, next check the log no error can also be observed that the cluster deployed successfully in the console


console cluster information

to sum up

This paper mainly for local debugging environment to build be a description itself is not complicated, everything should go try it yourself, maybe the middle will be a variety of problems, but it will be solved after more profound impression it

If you have questions please point out above, I will verify promptly corrected, thank you

Guess you like

Origin www.cnblogs.com/freeorange/p/12080747.html
Recommended