天天看点

rocketmq-1 集群搭建

1.安裝jdk

2.新建用户rocketmq,在rocketmq下面新建目录,把rocketmq-all-4.9.1-bin-release.zip进行解压

3.最后添加环境变量(包括jdk和rocketmq的环境变量)

vim ~/.bash_profile

============================

export JAVA_HOME=/app/jdk1.8/

PATH=$JAVA_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export ROCKETMQ_HOME=/app/rocketmq/rocketmq-all-4.9.1-bin-release

PATH=$ROCKETMQ_HOME/bin:$JAVA_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export NAMESRV_ADDR='localhost:9876'

========================================

vim bin/runserver.sh(修改jdk参数)

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

vim bin/vi runbroker.sh

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m"

vim conf/broker.conf

autoCreateTopicEnable=true

启动三台机器的namesrv

nohup ./mqbroker &

下面我们搭建2主2从的集群架构模式:

vim /etc/hosts

192.168.25.111 worker1

192.168.25.112 worker2

192.168.25.113 worker3

关闭防火墙

systemctl stop firewalld.service

主要修改2主2从的核心配置如下:

#所属集群名字,名字一样的节点就在同一个集群内

brokerClusterName=rocketmq-cluster

#broker名字,名字一样的节点就是一组主从节点。

brokerName=broker-a

#brokerid,0就表示是Master,>0的都是表示 Slave

brokerId=0

#nameServer地址,分号分割

namesrvAddr=worker1:9876;worker2:9876;worker3:9876

启动work-2的2台broker

nohup ./mqbroker -c ../conf/2m-2s-async/broker-a.properties &

nohup ./mqbroker -c ../conf/2m-2s-async/broker-b-s.properties &

启动work-3的2台broker

nohup ./mqbroker -c ../conf/2m-2s-async/broker-b.properties &

nohup ./mqbroker -c ../conf/2m-2s-async/broker-a-s.properties &

启动好查看集群状态

./mqadmin clusterList

可以看到集群已经搭建成功了

rocketmq-1 集群搭建

下面我们搭建控制台:

将rocketmq-console-ng-1.0.1.jar上传服务器

注意修改application.properies里面的属性:rocketmq.config.namesrvAddr=worker1:9876;worker2:9876;worker3:9876

启动控制台:

nohup java -jar rocketmq-console-ng-1.0.1.jar &

访问:http://192.168.25.111:8080/

可以看到已经成功了:

rocketmq-1 集群搭建