RocketMQ集群部署文档(2m-2s-async模式)

第一章、安装文件的准备

164bit OS, Linux/Unix/Mac is recommended;

264bit JDK 1.8+;

3Maven 3.2.x

4Git


第二章、集群安装

JDK每台机器都需要安装,mavengit只需要一台安装即可,编译好rocketmq之后使用scp命令拷贝到其他机器。

 

1、安装64jdk配置环境变量

JAVA_HOME=/usr/local/jdk1.8.0_111

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

export PATH JAVA_HOME CLASSPATH

 

2、安装git(可以不安装,安装只是为了下载源码)

yum install git

 

3、使用git下载rocktmq源码,使用maven编译

git clone -b develop https://github.com/apache/incubator-rocketmq.git

cd incubator-rocketmq

mvn -Prelease-all -DskipTests clean install -U

cd distribution/target/

mv apache-rocketmq /data/comm_apps/

 

4、安装maven配置环境变量

MAVEN_HOME=/data/comm_apps/maven

PATH=$MAVEN_HOME/bin:$PATH

export MAVEN_HOME PATH

 

 

5、配置jvm参数

cd /data/comm_apps/apache-rocketmq/bin

 

vim runserver.sh

vim runbroker.sh

RocketMQ集群部署文档(2m-2s-async模式)_第1张图片

 默认内存太大。根据需要修改

 

6、配置rocketMQ环境变量

vim /etc/profile

追加以下内容

NAMESRV_ADDR=192.168.102.32:9876,192.168.102.33:9876,192.168.102.34:9876,192.168.102.35:9876

export NAMESRV_ADDR

ROCKETMQ_HOME=/data/comm_apps/apache-rocketmq

PATH=$ROCKETMQ_HOME/bin:$PATH

export ROCKETMQ_HOME PATH

 

使该配置文件生效:

source /etc/profile

 

7每台依次启动namesrv  

cd /data/comm_apps/apache-rocketmq/bin

nohup sh mqnamesrv &

可以使用jps查看启动结果

 

 

 

 

8、启动broker

安装的集群是2m-2s-async模式

192.168.102.32broker-a

192.168.102.34broker-a-s

192.168.102.33broker-b

192.168.102.35broker-b-s

 

 

(1) 修改配置文件

通过配置文件指定机器的集群和broker归属,比如brokerName一样的属于同一个broker,一个broker只能有一个master,可以有多个slavebrokerId0的为master,其他的为slave

RocketMQ集群部署文档(2m-2s-async模式)_第2张图片


 

对应的配置文件加一行参数如下:

namesrvAddr=192.168.102.32:9876;192.168.102.33:9876;192.168.102.34:9876;192.168.102.35:9876

 

(2)启动命令如下:

192.168.102.32bin目录下执行:

nohup sh mqbroker -c /data/comm_apps/apache-rocketmq/conf/2m-2s-async/broker-a.properties >~/logs/rocketmqlogs/broker.log &

 

192.168.102.34bin目录下执行:

nohup sh mqbroker -c /data/comm_apps/apache-rocketmq/conf/2m-2s-async/broker-a-s.properties >~/logs/rocketmqlogs/broker.log &

 

192.168.102.33bin目录下执行:

nohup sh mqbroker -c /data/comm_apps/apache-rocketmq/conf/2m-2s-async/broker-b.properties >~/logs/rocketmqlogs/broker.log &

 

192.168.102.35bin目录下执行:

nohup sh mqbroker -c /data/comm_apps/apache-rocketmq/conf/2m-2s-async/broker-b-s.properties >~/logs/rocketmqlogs/broker.log &

 

 

 

9. 查看集群是否安装成功

在每台broker机器上选择对应的配置文件启动master,slave,全部启动完成之后,可以在rocketmqbin目录下查看集群情况:

sh mqadmin clusterList -n "192.168.102.32:9876;192.168.102.33:9876;192.168.102.34:9876;192.168.102.35:9876"

 



你可能感兴趣的:(RocketMQ集群部署文档(2m-2s-async模式))