主节点 192.168.0.1 从节点 192.168.0.2
mkdir -p /data/rocketmq
cd /data/rocketmq
cd /data/rocketmq
unzip rocketmq-all-4.8.0-bin-release
mv rocketmq-all-4.8.0-bin-release master
cd /data/rocketmq
unzip rocketmq-all-4.8.0-bin-release
mv rocketmq-all-4.8.0-bin-release slave
编辑rocketmq文件夹下bin目录下的runserver.sh和runbroker.sh脚本
runserver.sh脚本修改内容:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
runbroker.sh脚本修改内容:
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn128m"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=512m"
cd /data/rocketmq/master/conf/2m-2s-async
vim broker-a.properties
#集群名称,主从要一样
brokerClusterName=DefaultCluster
#broker名称,主从要一样,根据BrokerRole来确定谁是主谁是从
brokerName=broker-a
#brokerID 0是主,>0是从
brokerId=0
#删除日志时间为凌晨4点
deleteWhen=04
#文件保留时间48小时
fileReservedTime=48
#主从关系,异步复制
brokerRole=ASYNC_MASTER
#刷盘模式,异步刷盘
flushDiskType=ASYNC_FLUSH
是否允许Broker自动创建topic
autoCreateTopicEnable=true
是否允许Broker自动创建订阅组
autoCreateSubscriptionGroup=true
namesrvAddr地址,分号分割
namesrvAddr=192.168.0.1:9876;192.168.0.2:9876
当前 broker 监听的 IP
brokerIP1=192.168.0.1
存储 commit log 的路径
storePathCommitLog=/data/rocketmq/master/store/commitlog/
存储 consume queue 的路径
storePathConsumerQueue=/data/rocketmq/master/store/consumequeue/
消息索引存储路径
storePathIndex=/data/rocketmq/master/store/index
checkpoint 文件存储路径
storeCheckpoint=/data/rocketmq/master/store/checkpoint
abort 文件存储路径
abortFile=/data/rocketmq/master/store/abort
存储根路径
storePathRootDir=/data/rocketmq/master/store
commit log 的映射文件大小,默认1G
mappedFileSizeCommitLog=1024 * 1024 * 1024
cd /data/rocketmq/slave/conf/2m-2s-async/
vim broker-a-s.properties
#集群名称,主从要一样
brokerClusterName=DefaultCluster
#broker名称,主从要一样,根据BrokerRole来确定谁是主谁是从
brokerName=broker-a
#brokerID 0是主,>0是从
brokerId=1
#删除日志时间为凌晨4点
deleteWhen=04
#文件保留时间48小时
fileReservedTime=48
#角色是从节点
brokerRole=SLAVE
#刷盘模式,异步刷盘
flushDiskType=ASYNC_FLUSH
是否允许Broker自动创建topic
autoCreateTopicEnable=true
是否允许Broker自动创建订阅组
autoCreateSubscriptionGroup=true
namesrvAddr地址,分号分割
namesrvAddr=192.168.0.1:9876;192.168.0.2:9876
当前 broker 监听的 IP
brokerIP1=192.168.0.2
存储 commit log 的路径
storePathCommitLog=/data/rocketmq/slave/store/commitlog/
存储 consume queue 的路径
storePathConsumerQueue=/data/rocketmq/slave/store/consumequeue/
消息索引存储路径
storePathIndex=/data/rocketmq/slave/store/index
checkpoint 文件存储路径
storeCheckpoint=/data/rocketmq/slave/store/checkpoint
abort 文件存储路径
abortFile=/data/rocketmq/slave/store/abort
存储根路径
storePathRootDir=/data/rocketmq/slave/store
commit log 的映射文件大小,默认1G
mappedFileSizeCommitLog=1024 * 1024 * 1024
cd /data/rocketmq/master/bin/
#启动NameServer
nohup sh ./mqnamesrv >/dev/null 2>&1 &
#启动主Broker
nohup sh ./mqbroker -c ../conf/2m-2s-async/broker-a.properties >/dev/null 2>&1 &
cd /data/rocketmq/slave/bin/
#启动NameServer
nohup sh ./mqnamesrv >/dev/null 2>&1 &
#启动主Broker
nohup sh ./mqbroker -c ../conf/2m-2s-async/broker-a-s.properties >/dev/null 2>&1 &