网上的教程真的是凤毛麟角,就不想说啥了,一次一次把我带入坑。

好了关于Zookeeper的搭建已经说好了,本文说说基于Zookeeper的MQ集群。

第一步、将mq安装包上传到CentOS7,并解压

我这里有个   /mysoft   的路径,用来存放安装包的。执行命令:

[root@localhost mysoft]# ll
total
-rw-r--r--. root root Jul : apache-activemq-5.15.-bin.tar.gz
-rw-r--r--. root root Jul : jdk-8u131-linux-x64.gz
-rw-r--r--. root root Jul : zookeeper-3.4..tar.gz
[root@localhost mysoft]# tar -zxvf apache-activemq-5.15.-bin.tar.gz -C /usr/local

我这里解压到了/usr/local 目录下。

第二步、修改配置文件

小插曲:

当我没有配置ActiveMQ的环境变量时,会出现(两个/)
[root@localhost conf]# cd ../
[root@localhost apache-activemq-5.15.]# cd bin
[root@localhost bin]# ./activemq start
INFO: Loading '/usr/local/apache-activemq-5.15.0//bin/env'
INFO: Using java '/usr/local/java/jdk/jdk1.8.0_131/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/usr/local/apache-activemq-5.15.0//data/activemq.pid' (pid '') 所以我就配了个环境变量, vi /etc/profile export ACTIVEMQ_HOME=/usr/local/apache-activemq-5.15.0
之后就没有两个/了

找到配置文件

cd /usr/local/apache-activemq-5.15./conf

vi activemq.xml

1. 先修改节点名称,这里三台机器一致

2. 修改persistenceAdapter

节点一:

节点二:

节点三:

3. 提个醒

第三步、开放端口

2. 端口说明

Zookeeper
– the port that clients will use to connect to the ZK ensemble
– port used by ZK for quorum election
– port used by ZK for leader election
ActiveMQ
– 消息端口(服务端口)  # 默认的
– 控制台端口       # 默认的
– 集群通信端口

centos7命令开放端口--重启防火墙--查看端口:

[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@localhost conf]# systemctl restart firewalld 
[root@localhost conf]# firewall-cmd --zone=public --list-ports 
/tcp /tcp /tcp /tcp /tcp /tcp

第四步、启动Zookeeper,启动MQ

Zookeeper的启动我就不说了,我写的那篇文章有。

先定位到ActiveMQ的bin目录。然后

./activemq start

节点一:

节点二:

节点三:

那么有没有启动成功呢?

先看看ActiveMQ的启动日志,有没有异常的东西

[root@localhost conf]# cd ../
[root@localhost apache-activemq-5.15.]# cd data/
[root@localhost data]# tail activemq.log
-- ::, | WARN | unprocessed event state: AuthFailed | org.apache.activemq.leveldb.replicated.groups.ZKClient | main-EventThread
-- ::, | INFO | Socket connection established to 192.168.127.131/192.168.127.131:, initiating session | org.apache.zookeeper.ClientCnxn | main-SendThread(192.168.127.131:)
-- ::, | INFO | Session establishment complete on server 192.168.127.131/192.168.127.131:, sessionid = 0x25d71f9f3ed0000, negotiated timeout = | org.apache.zookeeper.ClientCnxn | main-SendThread(192.168.127.131:)
-- ::, | WARN | listeners are taking too long to process the events | org.apache.activemq.leveldb.replicated.groups.ChangeListenerSupport | main-EventThread
-- ::, | WARN | listeners are taking too long to process the events | org.apache.activemq.leveldb.replicated.groups.ChangeListenerSupport | main-EventThread
-- ::, | INFO | Using the pure java LevelDB implementation. | org.apache.activemq.leveldb.LevelDBClient | ActiveMQ BrokerService[activemqCluster] Task-
-- ::, | INFO | Attaching to master: tcp://192.168.127.129:62621 | org.apache.activemq.leveldb.replicated.SlaveLevelDBStore | ActiveMQ BrokerService[activemqCluster] Task-1
-- ::, | INFO | Slave started | org.apache.activemq.leveldb.replicated.MasterElector | ActiveMQ BrokerService[activemqCluster] Task-
-- ::, | INFO | Attaching... Downloaded 0.00/0.00 kb and / files | org.apache.activemq.leveldb.replicated.SlaveLevelDBStore | hawtdispatch-DEFAULT-
-- ::, | INFO | Attached | org.apache.activemq.leveldb.replicated.SlaveLevelDBStore | hawtdispatch-DEFAULT-

可以看出并没有。

再执行一下zkCli.sh ,看看有没有我们配的节点。

[root@localhost data]# cd /usr/local
[root@localhost local]# zkCli.sh
Connecting to localhost:
-- ::, [myid:] - INFO [main:Environment@] - Client environment:zookeeper.version=3.4.-39d3a4f269333c922ed3db283be479f9deacaa0f, built on // : GMT
-- ::, [myid:] - INFO [main:Environment@] - Client environment:host.name=localhost
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.version=1.8.0_131
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.vendor=Oracle Corporation
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.home=/usr/local/java/jdk/jdk1..0_131/jre
-- ::, [myid:] - INFO ...省略 -- ::, [myid:] - INFO [main:Environment@] - Client environment:java.io.tmpdir=/tmp
-- ::, [myid:] - INFO [main:Environment@] - Client environment:java.compiler=<NA>
-- ::, [myid:] - INFO [main:Environment@] - Client environment:os.name=Linux
-- ::, [myid:] - INFO [main:Environment@] - Client environment:os.arch=amd64
-- ::, [myid:] - INFO [main:Environment@] - Client environment:os.version=3.10.-.el7.x86_64
-- ::, [myid:] - INFO [main:Environment@] - Client environment:user.name=root
-- ::, [myid:] - INFO [main:Environment@] - Client environment:user.home=/root
-- ::, [myid:] - INFO [main:Environment@] - Client environment:user.dir=/usr/local
-- ::, [myid:] - INFO [main:ZooKeeper@] - Initiating client connection, connectString=localhost: sessionTimeout= watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@506c589e
-- ::, [myid:] - INFO [main-SendThread(localhost:):ClientCnxn$SendThread@] - Opening socket connection to server localhost/127.0.0.1:. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
-- ::, [myid:] - INFO [main-SendThread(localhost:):ClientCnxn$SendThread@] - Socket connection established to localhost/127.0.0.1:, initiating session
-- ::, [myid:] - INFO [main-SendThread(localhost:):ClientCnxn$SendThread@] - Session establishment complete on server localhost/127.0.0.1:, sessionid = 0x15d71f9f3e00000, negotiated timeout = WATCHER:: WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:(CONNECTED) ] ls /
[activemq, zookeeper]
[zk: localhost:(CONNECTED) ] ls /activemq
[leveldb-stores]
[zk: localhost:(CONNECTED) ] ls /activemq/leveldb-stores
[, , ]
[zk: localhost:(CONNECTED) ] quit
Quitting...
-- ::, [myid:] - INFO [main:ZooKeeper@] - Session: 0x15d71f9f3e00000 closed
-- ::, [myid:] - INFO [main-EventThread:ClientCnxn$EventThread@] - EventThread shut down for session: 0x15d71f9f3e00000
[root@localhost local]#

可以看到

[00000000006, 00000000007, 00000000005]

,之所以不是1,2,3,可能是我前几次没成功导致的吧,毕竟掉了几次坑。。。

你在这三台机器上都可以看到这三个,就证明ok了。

最后直观一点:打开浏览器。分别访问

http://192.168.127.129:8161/admin/

http://192.168.127.130:8161/admin/

http://192.168.127.131:8161/admin/

会发现只有一个提供服务。

------------------------------

-----------------------------------

现在我们停掉129的MQ

[root@localhost local]# cd apache-activemq-5.15./bin/
[root@localhost bin]# ./activemq stop
INFO: Loading '/usr/local/apache-activemq-5.15.0/bin/env'
INFO: Using java '/usr/local/java/jdk/jdk1.8.0_131/bin/java'
INFO: Waiting at least seconds for regular process termination of pid '' :
Java Runtime: Oracle Corporation 1.8.0_131 /usr/local/java/jdk/jdk1..0_131/jre
Heap sizes: current=63360k free=62311k max=1013632k
JVM args: -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/usr/local/apache-activemq-5.15./conf/login.config -Dactivemq.classpath=/usr/local/apache-activemq-5.15./conf:/usr/local/apache-activemq-5.15./../lib/: -Dactivemq.home=/usr/local/apache-activemq-5.15. -Dactivemq.base=/usr/local/apache-activemq-5.15. -Dactivemq.conf=/usr/local/apache-activemq-5.15./conf -Dactivemq.data=/usr/local/apache-activemq-5.15./data
Extensions classpath:
[/usr/local/apache-activemq-5.15./lib,/usr/local/apache-activemq-5.15./lib/camel,/usr/local/apache-activemq-5.15./lib/optional,/usr/local/apache-activemq-5.15./lib/web,/usr/local/apache-activemq-5.15./lib/extra]
ACTIVEMQ_HOME: /usr/local/apache-activemq-5.15.
ACTIVEMQ_BASE: /usr/local/apache-activemq-5.15.
ACTIVEMQ_CONF: /usr/local/apache-activemq-5.15./conf
ACTIVEMQ_DATA: /usr/local/apache-activemq-5.15./data
...Connecting to pid:
..Stopping broker: activemqCluster
... TERMINATED
[root@localhost bin]#

发现刚才不可以访问的130可以访问了

到这里Zookeeper+ActiveMQ集群搭建好了,关于负载均衡以后更新

Zookeeper3.4.10 + ActiveMQ-5.15.0 集群搭建的更多相关文章

  1. ubuntu18.04.2 hadoop3.1.2+zookeeper3.5.5高可用完全分布式集群搭建

    ubuntu18.04.2 hadoop3.1.2+zookeeper3.5.5高可用完全分布式集群搭建 集群规划: hostname NameNode DataNode JournalNode Re ...

  2. Redis 3.0 集群搭建

    Redis 3.0 集群搭建 开启两个虚拟机 分别在两个虚拟机上开启3个Redis实例 3主3从两个虚拟机里的实例互为主备 下面分别在两个虚拟机上安装,网络设置参照codis集群的前两个主机 分别关闭 ...

  3. Redis 5.0 集群搭建

    Redis 5.0 集群搭建 单机版的 Redis 搭建 https://www.jianshu.com/p/b68e68bbd725 /usr/local/目录 mkdir redis-cluste ...

  4. Ubuntu 12.04下Hadoop 2.2.0 集群搭建(原创)

    现在大家可以跟我一起来实现Ubuntu 12.04下Hadoop 2.2.0 集群搭建,在这里我使用了两台服务器,一台作为master即namenode主机,另一台作为slave即datanode主机 ...

  5. Weblogic 10.3.6.0 集群搭建

    Weblogic 集群搭建 Oracle的Weblogic分开发者版本和生产版本,有32位和64位.一般生产版本的weblogic是64位的,安装文件是一个大小为1G多的jar包.去oracle官网上 ...

  6. hadoop2.6.0集群搭建

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. redis5.0.0集群搭建【实战经历】

    redis集群搭建 作者:陈土锋 时间:2020年6月2日 目录 一.环境介绍... 1 1.机器准备... 1 2.关闭防护墙和selinux. 1 3.时间同步... 1 二.Redis Clus ...

  8. Ubuntu 12.04下spark1.0.0 集群搭建(原创)

    spark1.0.0新版本的于2014-05-30正式发布啦,新的spark版本带来了很多新的特性,提供了更好的API支持,spark1.0.0增加了Spark SQL组件,增强了标准库(ML.str ...

  9. linux Redis 5.0集群搭建

    文档结构如下: Redis cluster 是redis的分布式解决方案,在3.0版本正式推出后,有效的解决了redis分布式方面的需求:当遇到单机内存,并发,流量等瓶颈是,可以采用cluster架构 ...

随机推荐

  1. Python_闭包_27

    #闭包:嵌套函数,内部函数 并且必须调用外部函数的变量 def outer(): a = 1 def inner(): print(a) inner() print(inner.__closure__ ...

  2. PLSQL使用技巧 如何设置默认显示My Objects、记住密码等

    https://www.cnblogs.com/yilinzi/p/7144852.html PL/SQL Developer实现双击table查询 https://blog.csdn.net/zhy ...

  3. C. Maximum Subrectangle

    链接 [http://codeforces.com/contest/1060/problem/C] 题意 给你两个数列,可以构成一个矩阵C,ci,j=ai⋅bj 1≤x1≤x2≤n , 1≤y1≤y2 ...

  4. Map获取key值

    有两种方法 public static void test4(){ Map<String, Object> map = new HashMap<>(); map.put(&qu ...

  5. 11.18 Daily Scrum

    这两天开发人员陆续提交了自己开发的部分. 目前所有开发任务都已经完成,剩下的只是测试和整合,做最后的冲刺. 明天的任务: 李承晗:测试与整合

  6. Scrum Meeting NO.8

    Scrum Meeting No.8 1.会议内容 2.任务清单 徐越 序号 近期的任务 进行中 已完成 1 代码重构:前端通讯模块改为HttpClient+Json √ 2 添加对cookies的支 ...

  7. LINUX内核设计第五周——扒开系统调用的三层皮(下)

  8. text2

    我的实践2代码已经传到GITHUb:https://github.com/jiaweihao/Test.git一下为测试结果截图:

  9. spring播放器详细设计说明书(一)

    1 引言 1.1编写目的 编写目的是详细说明SPRING音乐播放器的设计使用,预期读者对象为在个人电脑上需要使用简单音乐播放器的用户.1.2项目背景  说明: a.待开发软件系统的名称为SPRING音 ...

  10. Hibernate的初次使用

    使用hibernate的四个步骤:第一:创建一个hibernate.cfg.xml.<!DOCTYPE hibernate-configuration PUBLIC "-//Hiber ...