Linux安装rocketMq
Linux安装rocketMq
·
搭建一个nameSrv 1主1从结构,
目前使用的是一台服务器;
如果要搭建两主两从的架构可以按照下图搭建.
一 . 安装nameSrv
rocketmq环境需要先配置JDK环境
1.解压安装包并重命名为rocketmq-4.3.0
tar -vxf rocketmq-all-4.3.0-bin-release.tar
mv rocketmq-all-4.3.0-bin-release /myTest/rocketmq/rocketmq-4.3.0
2.更改配置文件
vi /myTest/rocketmq/rocketmq-4.3.0/conf/logback_namesrv.xml #更改namesrv的日志输出目录
将配置文件中所有的${user.home}/logs 更改为 /myTest/rocketmq/logs(你自己的目录)
vi /myTest/rocketmq/rocketmq-4.3.0/bin/runserver.sh #更改启动脚本修改jvm内存大小 调整到合适你服务器的大小
3. 启动namesrv
nohup sh /myTest/rocketmq/rocketmq-4.3.0/bin/mqnamesrv 2>&1 &
二 . 安装broker(主)
同样解压并重命名
tar -vxf rocketmq-all-4.3.0-bin-release.tar
mv rocketmq-all-4.3.0-bin-release /myTest/rocketmq/rocketmq-4.3.0-a-m
更改配置文件
vi /myTest/rocketmq/rocketmq-4.3.0-a-m/conf/logback_broker.xml #更改输出日志目录
vi /myTest/rocketmq/rocketmq-4.3.0-a-m/bin/tools.sh
vi /myTest/rocketmq/rocketmq-4.3.0-a-m/bin/runbroker.sh
#更改参数适合自己的服务器
我的服务器比较小,所以配置的参数都很小
创建数据目录
mkdir -p /myTest/rocketmq/rocketmq-4.3.0-a-m/data/store
mkdir -p /myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/commitlog
mkdir -p /myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/consumequeue
mkdir -p /myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/index
mkdir -p /myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/checkpoint
接下来更改最重要的conf配置文件
vi /myTest/rocketmq/rocketmq-4.3.0-a-m/conf/2m-2s-sync/broker-a.properties
brokerClusterName=rocketmq-cluster
#broker名称
brokerName=broker-a
#0 表示master,>0 表示slave
brokerId=0
brokerRole=SYSC_MASTER
#nameServer地址,分号隔开
namesrvAddr=127.0.0.1:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许broker自动创建topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许broker自动创建订阅组,建议线下开始,线上关闭
autoCreateSubscriptionGroup=true
#broker对外服务的监听端口,
#同一台机器部署多个broker,端口号要不同,且端口号之间要相距大些
listenPort=10911
#删除文件的时间节点,默认凌晨4点
deleteWhen=04
#文件保留时间,默认48小时
fileReservedTime=120
#commitLog每个文件的大小,默认大小1g
mapedFileSizeCommitLog=1073741824
#consumeQueue每个文件默认存30w条,根据自身业务进行调整
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
#检查物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#store存储路径,master与slave目录要不同
#storePathRootDir=/vnum/rocketMQ/rocketmq-4.3.0-a-m/data/store
#commitLog存储路径
#storePathCommitLog= /vnum/rocketMQ/rocketmq-4.3.0-a-m/data/store/commitlog
storePathRootDir=/myTest/rocketmq/rocketmq-4.3.0-a-m/data/store
storePathCommitLog=/myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/commitlog
storePathConsumerQueue=/myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/consumequeue
storePathIndex=/myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/index
storeCheckpoint=/myTest/rocketmq/rocketmq-4.3.0-a-m/data/store/checkpoint
#限制的消息大小
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
#发消息线程池数
sendMessageThreadPoolNums=128
#拉去消息线程池数
pullMessageThreadPoolNums=128
#broker角色:
#ASYSC_MASTER 异步复制master
#SYSC_MASTER 同步复制master
#SLAVE 从
#brokerRole=SYSC_MASTER
#刷盘方式
#ASYNC_FLUSH 异步刷盘
#SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
启动broker
nohup sh /myTest/rocketmq/rocketmq-4.3.0-a-m/bin/mqbroker -c /myTest/rocketmq/rocketmq-4.3.0-a-m/conf/2m-2s-sync/broker-a.properties &
安装broker(从)
所有步骤都跟broker(主)一致.只是配置文件broker-a-s.properties需要更改
broker-a-s.properties
brokerClusterName=rocketmq-cluster
#broker名称 保持跟主一致
brokerName=broker-a
#0 表示master,>0 表示slave
brokerId=1
brokerRole=SLAVE
#nameServer地址,分号隔开
namesrvAddr=127.0.0.1:9876
#在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许broker自动创建topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许broker自动创建订阅组,建议线下开始,线上关闭
autoCreateSubscriptionGroup=true
#broker对外服务的监听端口,
#同一台机器部署多个broker,端口号要不同,且端口号之间要相距大些
listenPort=10811
#删除文件的时间节点,默认凌晨4点
deleteWhen=04
#文件保留时间,默认48小时
fileReservedTime=120
#commitLog每个文件的大小,默认大小1g
mapedFileSizeCommitLog=1073741824
#consumeQueue每个文件默认存30w条,根据自身业务进行调整
mapedFileSizeConsumeQueue=300000
destroyMapedFileInterval=120000
redeleteHangedFileInterval=120000
#检查物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#store存储路径,master与slave目录要不同
#storePathRootDir=/vnum/rocketMQ/rocketmq-4.3.0-a-m/data/store
#commitLog存储路径
#storePathCommitLog= /vnum/rocketMQ/rocketmq-4.3.0-a-m/data/store/commitlog
storePathRootDir=/myTest/rocketmq/rocketmq-4.3.0-a-s/data/store
storePathCommitLog=/myTest/rocketmq/rocketmq-4.3.0-a-s/data/store/commitlog
storePathConsumerQueue=/myTest/rocketmq/rocketmq-4.3.0-a-s/data/store/consumequeue
storePathIndex=/myTest/rocketmq/rocketmq-4.3.0-a-s/data/store/index
storeCheckpoint=/myTest/rocketmq/rocketmq-4.3.0-a-s/data/store/checkpoint
#限制的消息大小
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
checkTransactionMessageEnable=false
#发消息线程池数
sendMessageThreadPoolNums=128
#拉去消息线程池数
pullMessageThreadPoolNums=128
#broker角色:
#ASYSC_MASTER 异步复制master
#SYSC_MASTER 同步复制master
#SLAVE 从
#brokerRole=SYSC_MASTER
#刷盘方式
#ASYNC_FLUSH 异步刷盘
#SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
启动broker(从)
nohup sh /myTest/rocketmq/rocketmq-4.3.0-a-s/bin/mqbroker -c /myTest/rocketmq/rocketmq-4.3.0-a-s/conf/2m-2s-sync/broker-a-s.properties &
查看mq运行情况
./mqadmin clusterList -n 192.168.9.44:9876
更多推荐
已为社区贡献1条内容
所有评论(0)