activitymq 集群构建
测试zk是否正常
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | [root@node2 bin] # cd /zk/1/zookeeper-3.4.10/bin/ [root@node2 bin] # ./zkCli.sh -server 10.50.50.38:2181 Connecting to 10.50.50.38:2181 2018-12-03 16:03:09,869 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03 /23/2017 10:13 GMT 2018-12-03 16:03:09,873 [myid:] - INFO [main:Environment@100] - Client environment:host.name=node2 2018-12-03 16:03:09,873 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_171 2018-12-03 16:03:09,876 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-12-03 16:03:09,876 [myid:] - INFO [main:Environment@100] - Client environment:java.home= /usr/java/jdk1 .8.0_171-amd64 /jre 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir= /tmp 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user.home= /root 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user. dir = /zk/1/zookeeper-3 .4.10 /bin 2018-12-03 16:03:09,879 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=10.50.50.38:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyW atcher@799f7e29Welcome to ZooKeeper! 2018-12-03 16:03:09,905 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 10.50.50.38 /10 .50.50.38:2181. Will not attempt to authenticate using SASL (unknown error)JLine support is enabled 2018-12-03 16:03:09,982 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@876] - Socket connection established to 10.50.50.38 /10 .50.50.38:2181, initiating session 2018-12-03 16:03:09,997 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 10.50.50.38 /10 .50.50.38:2181, sessionid = 0x1 6772dd90850001, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type :None path:null [zk: 10.50.50.38:2181(CONNECTED) 0] |
下载配置启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | mkdir -pv /activemq/activemq {1,2,3} tar xf apache-activemq-5.14.3-bin. tar .gz -C /activemq/activemq1/ tar xf apache-activemq-5.14.3-bin. tar .gz -C /activemq/activemq2/ tar xf apache-activemq-5.14.3-bin. tar .gz -C /activemq/activemq3/ cd /activemq/activemq1/apache-activemq-5 .14.3 /conf/ cp -a activemq.xml{,.bak} 后面需要修改的配置文件都在ACTIVEMQ_HOME /conf 文件夹下。首先修改每个ActiveMQ的持久化方式(修改ACTIVEMQ_HOME /bin/activemq .xml文件),ActiveMQ默认使用的是kahaDB作为持久化存储数据的,这里修改成levelDB。如下所示 vim activemq.xml <persistenceAdapter> <replicatedLevelDB directory= "${activemq.data}/leveldb" replicas= "3" bind= "tcp://0.0.0.0:62621" zkAddress= "10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname = "10.50.50.38" zkPath= "/activemq/leveldb-stores" /> < /persistenceAdapter > [root@node2 conf] # cd /activemq/activemq2/apache-activemq-5.15.8/conf/ [root@node2 conf] # vim activemq.xml mechanism is the KahaDB store (identified by the kahaDB tag). For more information, see: http: //activemq .apache.org /persistence .html --> <persistenceAdapter> <replicatedLevelDB directory= "${activemq.data}/leveldb" replicas= "3" bind= "tcp://0.0.0.0:62621" zkAddress= "10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname = "10.50.50.38" zkPath= "/activemq/leveldb-stores" /> < /persistenceAdapter > <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name= "openwire" uri= "tcp://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> 把端口改61617 <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 > [root@node2 conf] # vim jetty.xml <bean id = "contexts" class= "org.eclipse.jetty.server.handler.ContextHandlerCollection" > < /bean > <bean id = "jettyPort" class= "org.apache.activemq.web.WebConsolePort" init-method= "start" > <!-- the default port number for the web console --> <property name= "host" value= "0.0.0.0" /> <property name= "port" value= "8162" /> 修改默认端口 < /bean > [root@node2 conf] # cd /activemq/activemq3/apache-activemq-5.15.8/conf/ [root@node2 conf] # vim activemq.xml [root@node2 conf] # vim activemq.xml <persistenceAdapter> <replicatedLevelDB directory= "${activemq.data}/leveldb" replicas= "3" bind= "tcp://0.0.0.0:62621" zkAddress= "10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname = "10.50.50.38" zkPath= "/activemq/leveldb-stores" /> < /persistenceAdapter > <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name= "openwire" uri= "tcp://0.0.0.0:61618?maximumConnections=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" /> [root@node2 conf] # vim jetty.xml < /tran <bean id = "jettyPort" class= "org.apache.activemq.web.WebConsolePort" init-method= "start" > <!-- the default port number for the web console --> <property name= "host" value= "0.0.0.0" /> <property name= "port" value= "8163" /> 修改默认端口 < /bean > sportConnectors> |
启动服务
1 2 3 4 5 6 7 8 | [root@node2 conf] # cd /activemq/activemq1/apache-activemq-5.15.8/bin/ [root@node2 bin] # ./activemq start [root@node2 bin] #cd /activemq/activemq2/apache-activemq-5.15.8/bin/ [root@node2 bin] # ./activemq start [root@node2 bin] #cd /activemq/activemq3/apache-activemq-5.15.8/bin/ [root@node2 bin] # ./activemq start [root@node2 bin] # ss -lntp | grep 61616 LISTEN 0 128 :::61616 :::* users :(( "java" ,pid=13674,fd=154)) |
参考文章:https://blog.csdn.net/haoyuyang/article/details/53931710
草都可以从石头缝隙中长出来更可况你呢
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏