第一步:创建集群目录
[root@node001 ~]# mkdir -p /usr/local/activemqCluster
复制单点至集群目录
[root@node001 ~]# cp /usr/local/activemq/apache-activemq-5.14.5 /usr/local/activemqCluster/mq1 -rf
第二步:配置activemq.xml
进入conf所在目录
[root@node001 ~]# cd /usr/local/activemqCluster/mq1/conf
[root@node001 conf]# vi activemq.xml
替换为下面的内容:
配置详细信息解读:
#配置自动切换地址
第三步:再复制两份,共计三份,修改端口号
[root@node001 ~]# cd /usr/local/activemqCluster/
[root@node001 activemqCluster]# cp mq1 mq2 -rf
[root@node001 activemqCluster]# cp mq1 mq3 -rfmq2修改端口号
[root@node001 activemqCluster]# cd mq2/conf
[root@node001 conf]# vi activemq.xml
mq3修改端口号同理,改为61816即可,此处不在演示
第四步:启动
[root@node001 ~]# cd /usr/local/activemqCluster/
[root@node001 activemqCluster]# mq1/bin/activemq start
INFO: Loading '/usr/local/activemqCluster/mq1//bin/env'INFO: Using java '/usr/local/java/jdk1.8.0_161/bin/java'INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get detailsINFO: pidfile created : '/usr/local/activemqCluster/mq1//data/activemq.pid' (pid '2786')[root@node001 activemqCluster]# mq2/bin/activemq startINFO: Loading '/usr/local/activemqCluster/mq2//bin/env'INFO: Using java '/usr/local/java/jdk1.8.0_161/bin/java'INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get detailsINFO: pidfile created : '/usr/local/activemqCluster/mq2//data/activemq.pid' (pid '2840')[root@node001 activemqCluster]# mq3/bin/activemq startINFO: Loading '/usr/local/activemqCluster/mq3//bin/env'INFO: Using java '/usr/local/java/jdk1.8.0_161/bin/java'INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get detailsINFO: pidfile created : '/usr/local/activemqCluster/mq3//data/activemq.pid' (pid '2892')java客户端操作集群
更改连接地址即可,如图: