您的位置:首页 > 其它

01.ActiveMQ安装部署

2015-10-08 22:56 549 查看

1.下载安装ActiveMQ

下载地址:http://activemq.apache.org/download-archives.html选择相应的版本,笔者选择的是:apache-activemq-5.9.0-bin.tar.gz
解压文件:
[lizhiwei@localhost ActiveMQ]$ tar -zxvf apache-activemq-5.9.0-bin.tar.gz

[/code]进入解压后的目录apache-activemq-5.9.0,如下:
[lizhiwei@localhost ActiveMQ]$ cd apache-activemq-5.9.0

[lizhiwei@localhost apache-activemq-5.9.0]$ ll

total 9956

-rwxr-xr-x. 1 lizhiwei lizhiwei 10105484 Oct 14  2013 activemq-all-5.9.0.jar

drwxrwxr-x. 5 lizhiwei lizhiwei     4096 Oct  8 06:34 bin

drwxr-xr-x. 2 lizhiwei lizhiwei     4096 Oct  8 06:34 conf

drwxr-xr-x. 3 lizhiwei lizhiwei     4096 Oct  8 06:45 data

drwxr-xr-x. 2 lizhiwei lizhiwei     4096 Oct  8 06:34 docs

drwxr-xr-x. 8 lizhiwei lizhiwei     4096 Oct  8 06:34 examples

drwxr-xr-x. 6 lizhiwei lizhiwei     4096 Oct  8 06:34 lib

-rw-r--r--. 1 lizhiwei lizhiwei    40580 Oct 14  2013 LICENSE

-rw-r--r--. 1 lizhiwei lizhiwei     3334 Oct 14  2013 NOTICE

-rw-r--r--. 1 lizhiwei lizhiwei     2610 Oct 14  2013 README.txt

drwxrwxr-x. 6 lizhiwei lizhiwei     4096 Oct  8 06:45 tmp

drwxr-xr-x. 8 lizhiwei lizhiwei     4096 Oct  8 06:34 webapps

drwxrwxr-x. 3 lizhiwei lizhiwei     4096 Oct  8 06:34 webapps-demo

[/code]bin,放置启动、停止、注册服务等命令文件。
conf,配置文件,包括broker、jetty、log等配置文件。
data,放置消息缓存(kahadb)、jetty中jsp编译后的class、AMQ日志等文件。
docs,帮助文档
examples,应用示例
lib,依赖的jar包
webapps,AMQ下的web应用,包括web console 和 file server。
webapps-demo,demo应用,默认不能访问,如需访问需要在conf/jetty.xml文件中配置。
activemq-all-5.10.1.jar, AMQ的开发用的jar包
其它文件,包括license、notice和 readme
修改文件:apache-activemq-5.9.0/bin/activemq设置Java运行环境,如下:
# Location of the java installation

# Specify the location of your java installation using JAVA_HOME, or specify the

# path to the "java" binary using JAVACMD

# (set JAVACMD to "auto" for automatic detection)

#JAVA_HOME=""  此处可以设置JAVA_HOME

JAVACMD="auto"

[/code]

2.启动ActiveMQ

1.activeMQ具有三种启动方式(1)普通启动 ./activemq start(2)启动并指定日志文件 ./activemq start /tmp/smlog(3)后台启动方式 nohup ./activemq start /tmp/smlog前两种方式下在命令行窗口关闭时或者ctrl+c时导致进程退出,采用后台启动方式则可以避免这种情况。2.启动如下:
[lizhiwei@localhost bin]$./activemq start

INFO: Using default configuration

(you can configure options in one of these file: /etc/default/activemq /home/lizhiwei/.activemqrc)


INFO: Invoke the following command to create a configuration file

./activemq setup [ /etc/default/activemq | /home/lizhiwei/.activemqrc ]


INFO: Using java '/usr/bin/java'

INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details

INFO: pidfile created : '/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/data/activemq-localhost.localdomain.pid' (pid '3658')

[/code]检查是否已启动:
[lizhiwei@localhost bin]$ps -ef | grep java.*active.*

lizhiwei   3989      1  5 07:42 pts/0    00:00:04 /usr/bin/java -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security.auth.login.config=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/tmp -Dactivemq.classpath=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/conf; -Dactivemq.home=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0 -Dactivemq.base=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0 -Dactivemq.conf=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/conf -Dactivemq.data=/home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/data -jar /home/lizhiwei/SoftWare/ActiveMQ/apache-activemq-5.9.0/bin/activemq.jar start

lizhiwei   4043   2490  0 07:44 pts/0    00:00:00 grep java.*active.*

[lizhiwei@localhost bin]$

[/code]或者使用如下命令:
[lizhiwei@localhost bin]$netstat -anlp | grep -E 'java'

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

tcp        0      0 :::61613                    :::*                        LISTEN      3989/java

tcp        0      0 :::61614                    :::*                        LISTEN      3989/java

tcp        0      0 :::61616                    :::*                        LISTEN      3989/java

tcp        0      0 :::37712                    :::*                        LISTEN      3989/java

tcp        0      0 :::1883                     :::*                        LISTEN      3989/java

tcp        0      0 :::8161                     :::*                        LISTEN      3989/java

tcp        0      0 :::5672                     :::*                        LISTEN      3989/java

unix  2      [ ]         STREAM     CONNECTED     29511  3989/java

unix  2      [ ]         STREAM     CONNECTED     29507  3989/java

[/code]ActiveMQ默认采用61616端口提供JMS服务,使用8161端口提供管理控制台服务。
3.使用浏览器登入ActiveMQ控制台ActiveMQ控制台地址:http://192.168.110.100:8161/admin/ 使用默认的用户名密码(用户名:admin 密码:admin)登入,如下:


手动设置用户名密码,需要修改文件apache-activemq-5.9.0/conf/jetty-realm.properties,如下:
# Defines users that can access the web (console, demo, etc.)

# username: password [,rolename ...]

admin: admin, admin

user: user, user

[/code]

3.简单配置

配置文件都在conf文件夹下,主要有activemq.xml、jetty.xml和log4j.properties。
1.配置broker的端口 修改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&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>

[/code]2.配置jetty的端口 修改jetty.xml中的下面内容。
<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="8161"/>

</bean>

[/code]3.配置启动demo工程 在jetty.xml中找到org.eclipse.jetty.webapp.WebAppContext,增加下面的内容。
<bean class="org.eclipse.jetty.webapp.WebAppContext">

<property name="contextPath" value="/demo" />

<property name="resourceBase" value="${activemq.home}/webapps-demo/demo" />

<property name="logUrlOnStart" value="true" />

</bean>

[/code]4.ActiveMQ架构图




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

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: