天天看點

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 叢集搭建