天天看點

activemq叢集搭建activemq叢集搭建

文章目錄

  • activemq叢集搭建
    • 1.将activemq複制三分
    • 2.修改三個mq的端口
    • 3.localhost名字映射
    • 4.統一brokerName
    • 5.叢集配置
    • 6.修改mq消息端口
    • 7.運作zookeeper叢集和avtivemq叢集
    • 8.測試
    • 9.制造故障

activemq叢集搭建

1.将activemq複制三分

cp -r apache-activemq-5.16.0   activemq8161
cp -r apache-activemq-5.16.0   activemq8162
cp -r apache-activemq-5.16.0   activemq8163
           
activemq叢集搭建activemq叢集搭建

接下來我們将使用activemq8161,activemq8162,activemq8163來基于zookeeper做叢集

2.修改三個mq的端口

(activemq8161不動,修改activemq8162,activemq8163)

進入conf的目錄下。修改jetty的内容

修改activemq8162

cd activemq8162/conf
 vim jetty.xml
           
activemq叢集搭建activemq叢集搭建

修改activemq8163

cd activemq8163/conf
 vim jetty.xml
           
activemq叢集搭建activemq叢集搭建

3.localhost名字映射

vim /etc/hosts
           

添加映射

activemq叢集搭建activemq叢集搭建

4.統一brokerName

vim activemq8161/conf/activemq.xml 
 vim activemq8162/conf/activemq.xml 
 vim activemq8163/conf/activemq.xml 
           
activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建

5.叢集配置

在activemq.xml添加叢集配置(取消掉kahadb)

activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建

6.修改mq消息端口

(activemq8161不動,修改activemq8162,activemq8163)

activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建

7.運作zookeeper叢集和avtivemq叢集

叢集搭建教程:https://blog.csdn.net/weixin_45742032/article/details/108331492

cd /usr/local/zookeeper2181/bin
./zkServer.sh start

cd /usr/local/zookeeper2182/bin
./zkServer.sh start

cd /usr/local/zookeeper2183/bin
./zkServer.sh start
           
cd /usr/local/activemq8161/bin
./activemq start
cd /usr/local/activemq8162/bin
./activemq start
cd /usr/local/activemq8163/bin
./activemq start
           

8.測試

随便登入一個zookeeper

cd /usr/local/zookeeper2183/bin
 ./zkCli.sh -server 192.168.164.134:2182
           

檢視mq叢集節點

activemq叢集搭建activemq叢集搭建

檢視節點

get  /activemq/leveldb-stores/00000000000
 get  /activemq/leveldb-stores/00000000001
 get  /activemq/leveldb-stores/00000000002
           

elected節點不是null的就是主mq,是null的節點就是從mq,是以address為tcp://liumq:61631對應的端口為8161的mq為主mq

activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建
activemq叢集搭建activemq叢集搭建

由于MQ叢集隻能通路主節點,分别通路mq,隻有端口為8161可以通路

http://192.168.164.134:8161
http://192.168.164.134:8162
http://192.168.164.134:8163
           
activemq叢集搭建activemq叢集搭建

9.制造故障

現在我們停掉8161的服務

檢視8161的pid

netstat -nlp
           
activemq叢集搭建activemq叢集搭建

停掉8161的服務

kill -9 3999
           

zookeeper選舉8162為主節點

activemq叢集搭建activemq叢集搭建