1. 程式人生 > >activemq 安裝-單點

activemq 安裝-單點

home 需要 readme localhost could not 指定 準備工作 real netstat

一,準備工作:首先安裝jdk1.7及其以上版本,此環境安裝的是jdk-1.8 二.搭建activemq 環境: 192.168.9.25 centos6.5 jdk-1.8 apache-activemq-5.14.5-bin.tar.gz 三.搭建activemq 1》解壓activemq [[email protected] soft]# tar xf apache-activemq-5.14.5-bin.tar.gz [[email protected] soft]# cp -rf apache-activemq-5.14.5 /usr/local/ 2》啟動activemq
activeMQ具有三種啟動方式 1、普通啟動 ./activemq start 2、啟動並指定日誌文件 ./activemq start >tmp/smlog 3、後臺啟動方式 [[email protected] bin]# nohup ./activemq start >/tmp/smlog [[email protected] soft]# cd /usr/local/apache-activemq-5.14.5/ [[email protected] apache-activemq-5.14.5]# ls activemq-all-5.14.5.jar conf docs lib NOTICE tmp webapps-demo bin data examples LICENSE README.txt webapps [[email protected] apache-activemq-5.14.5]# cd bin [[email protected] bin]# ls activemq activemq.jar linux-x86-32 macosx wrapper.jar activemq-diag env linux-x86-64 nohup.out [[email protected] bin]# nohup ./activemq start //采用後臺啟動方式
3》檢查啟動 [[email protected] bin]# ps -ef | grep activemq root 8740 1 1 23:20 pts/0 00:00:11 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/usr/local/apache-activemq-5.14.5//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/usr/local/apache-activemq-5.14.5//tmp -Dactivemq.classpath=/usr/local/apache-activemq-5.14.5//conf:/usr/local/apache-activemq-5.14.5//../lib/: -Dactivemq.home=/usr/local/apache-activemq-5.14.5/ -Dactivemq.base=/usr/local/apache-activemq-5.14.5/ -Dactivemq.conf=/usr/local/apache-activemq-5.14.5//conf -Dactivemq.data=/usr/local/apache-activemq-5.14.5//data -jar /usr/local/apache-activemq-5.14.5//bin/activemq.jar start root 8860 8839 0 23:39 pts/2 00:00:00 grep activemq [[email protected] conf]# netstat -lnpt | grep 8161 tcp 0 0 :::8161 :::* LISTEN 8740/java 四.登陸activemq控制臺
[[email protected] bin]# cd ../ [[email protected] apache-activemq-5.14.5]# ls activemq-all-5.14.5.jar conf docs lib NOTICE tmp webapps-demo bin data examples LICENSE README.txt webapps [[email protected] apache-activemq-5.14.5]# cd conf/ [[email protected] conf]# ll 總用量 80 -rw-r--r--. 1 root root 5911 3月 20 23:09 activemq.xml -rw-r--r--. 1 root root 1370 3月 20 23:09 broker.ks -rw-r--r--. 1 root root 592 3月 20 23:09 broker-localhost.cert -rw-r--r--. 1 root root 665 3月 20 23:09 broker.ts -rw-r--r--. 1 root root 1357 3月 20 23:09 client.ks -rw-r--r--. 1 root root 665 3月 20 23:09 client.ts -rw-r--r--. 1 root root 1172 3月 20 23:09 credentials-enc.properties -rw-r--r--. 1 root root 1121 3月 20 23:09 credentials.properties -rw-r--r--. 1 root root 962 3月 20 23:09 groups.properties -rw-r--r--. 1 root root 1011 3月 20 23:09 java.security -rw-r--r--. 1 root root 1087 3月 20 23:09 jetty-realm.properties -rw-r--r--. 1 root root 7795 3月 20 23:09 jetty.xml -rw-r--r--. 1 root root 965 3月 20 23:09 jmx.access -rw-r--r--. 1 root root 964 3月 20 23:09 jmx.password -rw-r--r--. 1 root root 3084 3月 20 23:09 log4j.properties -rw-r--r--. 1 root root 1207 3月 20 23:09 logging.properties -rw-r--r--. 1 root root 1016 3月 20 23:09 login.config -rw-r--r--. 1 root root 961 3月 20 23:09 users.properties 查看broker連接端口 [[email protected] conf]# vim activemq.xml <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> </transportConnectors> 61616就是我們的broker連接端口 查看amq控制臺的端口 [[email protected] conf]# vim jetty.xml <property name="host" value="0.0.0.0"/> <property name="port" value="8161"/> 五。瀏覽器進入控制臺 http://192.168.9.25:8161 username:admin passwd:admin 技術分享 六,修改activemq控制臺登陸端口 [[email protected] conf]# vim jetty.xml 。。。。。。。。。。。。。。 109 <property name="host" value="0.0.0.0"/> 110 <property name="port" value="9766"/> //控制臺端口修改成9766 。。。。。。。。。。。。。。。。。 [[email protected] bin]# nohup ./activemq restart //重啟activemq服務 [[email protected] bin]# ps -ef | grep activemq root 8992 1 54 00:05 pts/0 00:00:06 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/usr/local/apache-activemq-5.14.5//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/usr/local/apache-activemq-5.14.5//tmp -Dactivemq.classpath=/usr/local/apache-activemq-5.14.5//conf:/usr/local/apache-activemq-5.14.5//../lib/: -Dactivemq.home=/usr/local/apache-activemq-5.14.5/ -Dactivemq.base=/usr/local/apache-activemq-5.14.5/ -Dactivemq.conf=/usr/local/apache-activemq-5.14.5//conf -Dactivemq.data=/usr/local/apache-activemq-5.14.5//data -jar /usr/local/apache-activemq-5.14.5//bin/activemq.jar start root 9036 8289 0 00:05 pts/0 00:00:00 grep activemq [[email protected] bin]# netstat -lnpt | grep 9766 //查看9766端口 tcp 0 0 :::9766 :::* LISTEN 8992/java 瀏覽器登錄測試: http://192.168.9.25:9766 username:admin passwd:admin 七,修改activemq控制臺登陸用戶名和密碼 [[email protected] conf]# vim jetty.xml 30 <property name="roles" value="user,admin" /> 31 <!-- set authenticate=false to disable login --> 32 <property name="authenticate" value="true" /> //確認次數為“true”,說明在web登陸時會開啟認證。若此處更改為“flash”,在web登陸時不需要認證 activemq用戶名密碼存放的位置 [[email protected] conf]# vim jetty-realm.properties ## --------------------------------------------------------------------------- ## Licensed to the Apache Software Foundation (ASF) under one or more ## contributor license agreements. See the NOTICE file distributed with ## this work for additional information regarding copyright ownership. ## The ASF licenses this file to You under the Apache License, Version 2.0 ## (the "License"); you may not use this file except in compliance with ## the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- # Defines users that can access the web (console, demo, etc.) # username: password [,rolename ...] #admin: admin, admin #user: user, user zxjr: zxjr123, admin //此處用戶名修改成“zxjr” 密碼修改成“zxjr123”。值得註意的是用戶名和密碼的格式是:用戶名 : 密碼 ,角色名。 user: user, user 重啟activemq 服務 [[email protected] conf]# ps -ef | grep activemq root 9188 1 1 00:07 pts/0 00:00:10 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/usr/local/apache-activemq-5.14.5//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/usr/local/apache-activemq-5.14.5//tmp -Dactivemq.classpath=/usr/local/apache-activemq-5.14.5//conf:/usr/local/apache-activemq-5.14.5//../lib/: -Dactivemq.home=/usr/local/apache-activemq-5.14.5/ -Dactivemq.base=/usr/local/apache-activemq-5.14.5/ -Dactivemq.conf=/usr/local/apache-activemq-5.14.5//conf -Dactivemq.data=/usr/local/apache-activemq-5.14.5//data -jar /usr/local/apache-activemq-5.14.5//bin/activemq.jar start root 9303 8289 0 00:17 pts/0 00:00:00 grep activemq [[email protected] conf]# kill 9188 [[email protected] bin]# nohup ./activemq start //後臺啟動activemq服務 [[email protected] bin]# netstat -lnpt | grep 9766 tcp 0 0 :::9766 :::* LISTEN 9347/java web網頁登陸測試: http://192.168.9.25:9766 username:zxjr passwd:zxjr123 技術分享 八,在搭建過程中可能會出現的問題 問題1:當在同一臺機器上安裝activemq和rabbitmq時,如果是先安裝rabbitmq,後安裝activmq,在啟動activemq時會報錯,查看activemq日誌,報錯內容為: Error creating bean with name ‘org.apache.activemq.xbean.XBeanBrokerService#0‘ defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Transport Connector could not be registered in JMX: java.io.IOException: Failed to bind to server socket: amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: 地址已在使用 (Bind failed) | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main 次報錯信息為activmq 5672的端口被占用,更改5672的端口即可 [[email protected] conf]#vim /usr/local/apache-activemq-5.14.4/conf/activemq.xml 111 <transportConnectors> 112 <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> 113 <transportConnector name="openwire" uri="tcp://127.0.0.1:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104 857600"/> 114 <transportConnector name="amqp" uri="amqp://127.0.0.1:9766? maximumConnections=1000&amp;wireFormat.maxFrameSize=1048576 00"/> //5672的端口更改為9766 115 <transportConnector name="stomp" uri="stomp://127.0.0.1:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=1048 57600"/> 116 <transportConnector name="mqtt" uri="mqtt://127.0.0.1:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=1048576 00"/> 117 <transportConnector name="ws" uri="ws://127.0.0.1:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600" /> 118 </transportConnectors> 重啟啟動activemq: [[email protected] conf]# cd ../bin/ [[email protected] bin]# nohup ./activemq restart [[email protected] bin]# ps -ef | grep activemq root 14617 14196 0 14:46 pts/2 00:00:00 tail -f activemq.log root 15196 1 61 15:01 pts/0 00:00:06 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/usr/local/apache-activemq-5.14.4//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/usr/local/apache-activemq-5.14.4//tmp -Dactivemq.classpath=/usr/local/apache-activemq-5.14.4//conf:/usr/local/apache-activemq-5.14.4//../lib/: -Dactivemq.home=/usr/local/apache-activemq-5.14.4/ -Dactivemq.base=/usr/local/apache-activemq-5.14.4/ -Dactivemq.conf=/usr/local/apache-activemq-5.14.4//conf -Dactivemq.data=/usr/local/apache-activemq-5.14.4//data -jar /usr/local/apache-activemq-5.14.4//bin/activemq.jar start 問題2:Error creating bean with name ‘org.apache.activemq.xbean.XBeanBrokerService#0‘ defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: port out of range:-1 | org.apache.activemq.xbean.XBeanBrokerFactory$1 | main 報次錯誤時,可以把[[email protected] conf]#vim /usr/local/apache-activemq-5.14.4/conf/activemq.xml,的ip地址修改為127.0.0.1,如上錯誤已被修改。

activemq 安裝-單點