RocketMQ集群部署及配置

Ⅰ.RocketMQ

https://rocketmq.incubator.apache.org/ ,吐槽官方的get started以及没有相关的配置说明。还得去扒拉未捐赠之前的资料。

Ⅱ.安装启动

默认安装目录:/opt/apache-rocketmq-all/,进入安装目录bin目录

1. 启动NameServer

1
# nohup sh mqnamesrv &

2. 启动Broker并指定Name Server

1
# nohup sh mqbroker -n localhost:9876 &

Ⅲ.集群部署

机器:10.0.9.221、10.0.9.222。集群才用多Master、多Slave的同步模式。
221:BrokerA、SlaveB;222:BrokerB、SlaveA

1. 修改配置文件

  1. 修改/conf/2m-2s-sync/broker-a-s.properties,增加:

    1
    2
    3
    4
    # 默认监听10911,还有个haListenPort默认为listenPort+1;
    listenPort=10921
    brokerIP1=10.0.9.222 # (222上多网卡)
    brokerIP2=10.0.9.222 # (222上多网卡)
  2. 修改/conf/2m-2s-sync/broker-b-s.properties ,增加:

    1
    2
    # 默认监听10911,还有个haListenPort默认为listenPort+1;
    listenPort=10921
  3. 修改/conf/2m-2s-sync/broker-b.properties,增加:

    1
    2
    brokerIP1=10.0.9.222  # (222上多网卡)
    brokerIP2=10.0.9.222 # (222上多网卡)

2. 分别启动机器上的NameServer

1
# nohup sh mqnamesrv &

3. 启动221 Broker

1
2
3
nohup sh mqbroker -c ../conf/2m-2s-sync/broker-a.properties -n "10.0.9.221:9876;10.0.9.222:9876" &

nohup sh mqbroker -c ../conf/2m-2s-sync/broker-b-s.properties -n "10.0.9.221:9876;10.0.9.222:9876" &

4. 启动222 Broker

nohup sh mqbroker -c ../conf/2m-2s-sync/broker-b.properties -n “10.0.9.221:9876;10.0.9.222:9876” &

nohup sh mqbroker -c ../conf/2m-2s-sync/broker-a-s.properties -n “10.0.9.221:9876;10.0.9.222:9876” &

5. 验证集群

1
2
3
4
5
6
7
[root@weixinapp01 bin]# sh mqadmin clusterlist -n 10.0.9.221:9876
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
DefaultCluster broker-a 0 10.0.9.221:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 416095.39 0.5908
DefaultCluster broker-a 1 10.0.9.222:10921 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 416095.39 0.4097
DefaultCluster broker-b 0 10.0.9.222:10911 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 416095.39 0.4097
DefaultCluster broker-b 1 10.0.9.221:10921 V4_0_0_SNAPSHOT 0.00(0,0ms) 0.00(0,0ms) 0 416095.39 0.5908
[root@weixinapp01 bin]#

Ⅳ.注意事项

1. No route Info of ,TopicTest异常

请检查服务器防火墙,需要开放9876、10911等端口;或直接关闭防火墙

2. 启动Broker异常,nohup.out中,Address In Use异常

每个Broker占用一个端口,如果有多个Broker时,需要修改Broker的listenPort端口,注意与haListenPort的结合。
参数名称为:brokerIP1:listenPort的ip;brokerIP2:haListenPort

3. nohup sh broker时,broker运行正常,但是无法退出命令进程,退出后导致broker关闭异常

-n ip:端口号 时, -n 后面的参数加双引号

打赏一瓶红牛吧,我好有力气继续加油!