环境:两台服务器(虚拟机)
1、下载RocktMQ
rocketmq-all-5.3.0-bin-release.zip
2、上传服务器后,解压安装包
unzip rocketmq-all-5.3.0-bin-release.zip
3、进入到bin目录,修改jvm参数(结合服务器的配置去修改)
cd /opt/rocketmq-all-5.3.0-bin-release/bin
4、修改runbroker.sh
vi runbroker.sh
5、修改runserver.sh
6、修改rocketmqOS1配置文件
配置文件位置:要修改的配置文件在rocketMQ解压目录的 conf/2m-2s-async目录中。
修改broker-a.properties ,将该配置文件内容修改为如下:
# 指定整个broker集群的名称,或者说是RocketMQ集群的名称
brokerClusterName=DefaultCluster
# 指定master-slave集群的名称。一个RocketMQ集群可以包含多个master-slave集群
brokerName=broker-a
# master的brokerId为0
brokerId=0
# 指定删除消息存储过期文件的时间为凌晨4点
deleteWhen=04
# 指定未发生更新的消息存储文件的保留时长为48小时,48小时后过期,将会被删除
fileReservedTime=48
# 指定当前broker为异步复制master
brokerRole=ASYNC_MASTER
# 指定刷盘策略为异步刷盘
flushDiskType=ASYNC_FLUSH
# 下列是新添加(复制标黑字体)
namesrvAddr=10.2.10.100:9876;10.2.10.102:9876
修改broker-b-s.properties,将该配置文件内容修改为如下:
brokerClusterName=DefaultCluster
# 指定这是另外一个master-slave集群
brokerName=broker-b
# slave的brokerId为非0
brokerId=1
deleteWhen=04
fileReservedTime=48
# 指定当前broker为slave
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
##下列是新添加的(复制标黑字体)
namesrvAddr=10.2.10.100:9876;10.2.10.102:9876
# 指定Broker对外提供服务的端口,即Broker与producer与consumer通信的端口。默认10911。由于当前主机同时充当着#master1与slave2,而前面的master1使用的是默认端口。这里需要将这两个端口加以区分,以区分出master1与slave2
listenPort=11911
# 指定消息存储相关的路径。默认路径为~/store目录。由于当前主机同时充当着master1与slave2,master1使用的是默认路
#径,这里就需要再指定一个不同路径
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/index
storeCheckpoint=~/store-s/checkpoint
abortFile=~/store-s/abort
7、修改rocketmqOS2配置文件
修改broker-b.properties:将该配置文件内容修改为如下:
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
#下列是新添加的(复制标黑字体)
namesrvAddr=10.2.10.100:9876;10.2.10.102:9876
修改broker-a-s.properties:将该配置文件内容修改为如下:
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=SLAVE
flushDiskType=ASYNC_FLUSH
#下列是新添加的(复制标黑字体)
namesrvAddr=10.2.10.100:9876;10.2.10.102:9876
listenPort=11911
storePathRootDir=~/store-s
storePathCommitLog=~/store-s/commitlog
storePathConsumeQueue=~/store-s/consumequeue
storePathIndex=~/store-s/index
storeCheckpoint=~/store-s/checkpoint
abortFile=~/store-s/abort
8、启动服务
8.1 启动NameServer集群
分别启动rocketmqOS1与rocketmqOS2两个主机中的NameServer。启动命令完全相同。
nohup sh bin/mqnamesrv &
查看日志
tail -f ~/logs/rocketmqlogs/namesrv.log
8.2 启动两个Master
分别启动rocketmqOS1与rocketmqOS2两个主机中的brokermaster。注意,它们指定所要加载的配置文件是不同的。
# rocketmqOS1
nohup sh /usr/local/rocketmq-all-5.1.3-bin-release/bin/mqbroker -c /usr/local/rocketmq-all-5.1.3-bin-release/conf/2m-2s-async/broker-a.properties&
tail -f ~/logs/rocketmqlogs/broker.log
# rocketmqOS2
nohup sh /usr/local/rocketmq-all-5.1.3-bin-release/bin/mqbroker -c /usr/local/rocketmq-all-5.1.3-bin-release/conf/2m-2s-async/broker-b.properties&
tail -f ~/logs/rocketmqlogs/broker.log
8.3 启动两个Slave
分别启动rocketmqOS1与rocketmqOS2两个主机中的brokerslave。注意,它们指定所要加载的配置文件是不同的。
# rocketmqOS1
nohup sh /usr/local/rocketmq-all-5.1.3-bin-release/bin/mqbroker -c /usr/local/rocketmq-all-5.1.3-bin-release/conf/2m-2s-async/broker-b-s.properties&
tail -f ~/logs/rocketmqlogs/broker.log
# rocketmqOS2
nohup sh /usr/local/rocketmq-all-5.1.3-bin-release/bin/mqbroker -c /usr/local/rocketmq-all-5.1.3-bin-release/conf/2m-2s-async/broker-a-s.properties&
tail -f ~/logs/rocketmqlogs/broker.log
9、停服务
关闭namesrv服务:sh bin/mqshutdown namesrv
关闭broker服务 :sh bin/mqshutdown broke
标签:bin,kylin,配置文件,v10,broker,双主双,rocketmq,release,store From: https://blog.csdn.net/zsb706496992/article/details/143506537