消息中间件ActiveMQ+Zookeeper_java

原文链接:https://blog.51cto.com/4259679

之前部署过kafka集群,安装过zookeeper,请查看往期记录

ip地址                主机名               安装软件

192.168.20.40   k8s-master       zookeeper、ActiveMQ

192.168.20.43   k8s-node2        zookeeper、ActiveMQ

192.168.20.39   k8s-node3        zookeeper、ActiveMQ

重启三台服务器上的zookeeper服务

[root@k8s-master ~]# cd /data/zookeeper/bin/

[root@k8s-master bin]# ls

README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh  zkServer.sh.back

[root@k8s-master bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /data/zookeeper/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

消息中间件ActiveMQ+Zookeeper_java_02

[root@k8s-node2 ~]#  cd /data/zookeeper/bin/

[root@k8s-node2 bin]# ls

README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh

[root@k8s-node2 bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /data/zookeeper/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

消息中间件ActiveMQ+Zookeeper_java_03

[root@k8s-node3 ~]#  cd /data/zookeeper/bin/

[root@k8s-node3 bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /data/zookeeper/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

[root@k8s-node3 bin]# ps -ef |grep zookeeper

消息中间件ActiveMQ+Zookeeper_java_04

三台服务器安装ActiveMQ


[root@k8s-master ~]# tar -zxvf apache-activemq-5.15.14-bin.tar.gz 

[root@k8s-master ~]# mv apache-activemq-5.15.14 /data/activemq

[root@k8s-master ~]# cd /data/activemq/conf/

[root@k8s-master conf]# vim activemq.xml

 <broker xmlns="http://activemq.apache.org/schema/core" brokerName="cluster-mq" dataDirectory="${activemq.data}">

这里注释掉

 <!--

        <persistenceAdapter>

            <kahaDB directory="${activemq.data}/kahadb"/>

        </persistenceAdapter>

        -->

下面添加配置

 <persistenceAdapter>

          <replicatedLevelDB  

              directory="${activemq.data}/leveldb" 

              replicas="3"            

              bind="tcp://0.0.0.0:0"         

              zkAddress="192.168.20.40:2181,192.168.20.43:2181,192.168.20.39:2181" 

              zkPassword="" 

              hostname="192.168.20.40"          修改成每台服务器ip

              sync="local_disk" 

              zkPath="/activemq/leveldb-stores"/> 修改成不同路径

下面修改IP

  <transportConnector name="openwire" uri="tcp://192.168.20.40:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>

启动ActiveMQ

[root@k8s-master conf]# /data/activemq/bin/activemq start

INFO: Loading '/data/activemq//bin/env'

INFO: Using java '/usr/local/java/bin/java'

INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details

INFO: pidfile created : '/data/activemq//data/activemq.pid' (pid '7865')

消息中间件ActiveMQ+Zookeeper_java_05

消息中间件ActiveMQ+Zookeeper_java_06

消息中间件ActiveMQ+Zookeeper_java_07

部署完成

使用zookeeper做负载均衡,三台服务器中只会有一台是master,其他两台处于等待状态,所以只有其中一台提供服务。

所以其他两台服务器虽然active程序启动了,但是61616服务端口和8161管理端口是关闭等待状态。

----------------------end---------------------

推荐阅读: