Linux分布式消息队列RocketMQ部署与监控--双Master

环境准备:CentOS_6.5_x64

IP: 192.168.0.249   dbTest249    Master1
IP:    192.168.0.251      webTest251      Master2

下载 alibaba-rocketmq 软件

https://github.com/alibaba/RocketMQ/releases

一、安装rocketmq

# tar zxf alibaba-rocketmq-3.2.4-beta1.tar.gz -C /usr/local/
# cd /usr/local/
# ln -s /usr/local/alibaba-rocketmq /usr/local/rocketmq
# cd rocketmq/

二、配置主从

1、分别在249、251上编辑配置文件

# hostname 
# vim conf/2m-noslave/broker-a.properties



#####################Master1服务器配置文件#####################    
brokerClusterName=FusionCluster    
brokerName=broker-a    
brokerId=0    
namesrvAddr=dbTest249:9876;webTest251:9876    
deleteWhen=04    
fileReservedTime=120    

brokerRole=ASYNC_MASTER    
flushDiskType=ASYNC_FLUSH    
sstorePathRootDir=/data/rocketmq/store    
storePathCommitLog=/data/rocketmq/store/commitlog

#####################Master2服务器配置文件#####################    
brokerClusterName=FusionCluster    
brokerName=broker-b    
brokerId=1    
namesrvAddr=dbTest249:9876;webTest251:9876    
deleteWhen=04    
fileReservedTime=120    

brokerRole=ASYNC_MASTER    
flushDiskType=ASYNC_FLUSH    
listenPort=10911 
sstorePathRootDir=/data/rocketmq/store    
storePathCommitLog=/data/rocketmq/store/commitlog

2、编辑JAVA内存块

# vim bin/runbroker.sh

如果服务器内存不够,可以修改runserver.sh脚本(mqnamesrv文件中通过runserver.sh脚本调用Name Server的主函数com.alibaba.rocketmq.namesrv.NamesrvStartup启动Name Server)中的JAVA_OPT_1参数
[plain] view plaincopy在CODE上查看代码片派生到我的代码片

1 JAVA_OPT_1="-server -Xms512m -Xmx1g -XX:PermSize=128m -XX:MaxPermSize=320m"

3、创建数据目录

# mkdir -p /data/rocketmq/store/commitlog
# mkdir /data/logs
# cd conf/
# sed -i 's#${user.home}#/data#g' *.xml      //将conf目录下所有xml文件中的${user.home}替换成/data,进入rocketmq/conf目录下执行该命令

4、启动RocketMQ

# cd ../bin/
# nohup sh mqnamesrv >/var/log/ns.log &
# nohup sh mqbroker -c ../conf/2m-noslave/broker-a.properties > /var/log/mq.log 2>&1 &

5、查看启动日志

# tail -f /var/log/ns.log 
# tail -f /var/log/mq.log

6、查看启动端口

# netstat -tunpl
# jps
# kill -9 22596
# kill -9 22564
# kill -9 9967
# netstat -tunpl
# netstat -tunpl |grep java

7、关闭RocketMQ

# sh mqshutdown

1 Useage: mqshutdown broker | namesrv

# sh mqshutdown broker
# sh mqshutdown namesrv

8、再次启动

# nohup sh mqnamesrv >/var/log/ns.log &
# nohup sh mqbroker -c ../conf/2m-noslave/broker-a.properties > /var/log/mq.log 2>&1 &

9、验证状态

# jps

添加新评论