写点什么

Zookeeper+ActiveMQ 集群搭建

  • 2022 年 4 月 16 日
  • 本文字数:2899 字

    阅读完需:约 10 分钟

  • 遇到的问题 1:


用 zkServer.sh?start 启动报错说 zkServer.sh:未找到命令 就用 ./zkServer.sh start 来启动


  • 遇到的问题 2:?


三台虚拟机启动后用 zkServer.sh?status 查看状态发现有错误


[root@localhost conf]# zkServer.sh status JMX enabled by default Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg Error contacting service. It is probably not running.


然后用 $zkServer.sh?start-foreground 命令来启动查看启动日志 发现日志报错


java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:388) at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:765) at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:716) 2016-11-13 18:00:35,602 [myid:0] - WARN [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@368] - Cannot open channel to 1 at election address /192.168.192.131:3888


java.net.NoRouteToHostException: No route to host at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:388) at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:765) at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:716) 2016-11-13 18:00:36,035 [myid:0] - INFO [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@774] - Notification time out: 800 2016-11-13 18:00:36,837 [myid:0] - WARN [QuorumPeer[myid=0]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@368] - Cannot open channel to 2 at election address /192.168.192.134:3888


初步断定是防火墙的问题,我们关闭防火墙试试看能不能解决问题


#关闭防火墙


$?systemctl stop firewalld.service


重新启动 zookeeper 我们发现可以使用了。问题解决


3、搭建 ActiveMQ 并和 Zookeeper 建立集群


搭建三个 ActiveMQ,分在三个服务器上,每一个服务器上一个。192.169.192.130 是 node1,192.168.192.131 是 node2,192.168.192.134 是 node3


(1) 解压 tar -zxvf apache-activemq-5.14.1-bin.tar.gz


(2) 创建文件夹 mkdir /usr/local/activemq-cluster


(3)?将第一步解压的文件夹移动到 activemq-cluster 下


(4)?改名文件夹 mv apache-activemq-5.14.1 node1 (其他两台服务器也如此操作并分别改名为 node2,node3)


(5)?修改 conf/activemq.xml 文件 vim activemq.xml。修改其中的 bind、zkAddress、bhotname、zkPath。


(6)?node1 第一处修改:brokerName="active-cluster"


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


(7)node1 第二处修改:


<persistenceAdapter> <!-- <kahaDB directory="{activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:62621" zkAddress="192.168.192.130:2181,192.168.192.131:2181,192.168.192.134:2181" hostname="192.168.192.130" zkPath="/activemq/leveldb-stores"/> </persistenceAdapter>


(8)node1 第三处修改:修改 name="openwire"


《一线大厂 Java 面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》开源 tions=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> </transportConnectors>


(9)?node2 第一处修改


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


(10)?node2 第二处修改


<persistenceAdapter> <!-- <kahaDB directory="{activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:62622" zkAddress="192.168.192.130:2181,192.168.192.131:2181,192.168.192.134:2181" hostname="192.168.192.131" zkPath="/activemq/leveldb-stores" /> </persistenceAdapter>


(11)?node2 第三处修改参考


(12)?node3 第一处修改


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


(13)?node3 第二处修改


<persistenceAdapter> <!-- <kahaDB directory="{activemq.data}/leveldb" replicas Java 开源项目【ali1024.coding.net/public/P7/Java/git】 ="3" bind="tcp://0.0.0.0:62623" zkAddress="192.168.192.130:2181,192.168.192.131:2181,192.168.192.134:2181" hostname="192.168.192.134" zkPath="/activemq/leveldb-stores" /> </persistenceAdapter>


(14)?node3 第三处修改


Kafka 实战笔记

关于这份笔记,为了不影响大家的阅读体验,我只能在文章中展示部分的章节内容和核心截图



  • Kafka 入门

  • 为什么选择 Kafka

  • Karka 的安装、管理和配置



  • Kafka 的集群

  • 第一个 Kafka 程序


afka 的生产者



  • Kafka 的消费者

  • 深入理解 Kafka

  • 可靠的数据传递




  • Spring 和 Kalka 的整合

  • Sprinboot 和 Kafka 的整合

  • Kafka 实战之削峰填谷

  • 数据管道和流式处理(了解即可)



  • Kafka 实战之削峰填谷



用户头像

还未添加个人签名 2022.04.13 加入

还未添加个人简介

评论

发布
暂无评论
Zookeeper+ActiveMQ集群搭建_Java_爱好编程进阶_InfoQ写作平台