Linux下安装HornetQ
2016-07-06 本文已影响671人
lynch0571
环境:
1、操作系统:CentOS release 6.8 (Final)
2、安装版本: hornetq-2.4.0.Final-bin.tar.gz
1、解压并重命名HornetQ
tar zxvf hornetq-2.4.0.Final-bin.tar.gz
mv hornetq-2.4.0.Final hornetq
![](https://img.haomeiwen.com/i1899977/d621f6cd6528da09.png)
![](https://img.haomeiwen.com/i1899977/180c36297405acc9.png)
解压完成后HornetQ就可以直接启动了,但实际项目中需要做一些配置才能方便使用。
2、配置hornetq-beans.xml
修改hornetq-beans.xml,将jnp.host改为本机IP地址,这样就可以被其他计算机访问
cd config/stand-alone/non-clustered/
vim hornetq-beans.xml
![](https://img.haomeiwen.com/i1899977/4c8d916a75a87145.png)
![](https://img.haomeiwen.com/i1899977/f8daf1ca00399985.png)
3、配置hornetq-configuration.xml
同上,将localhost改为本机IP地址
![](https://img.haomeiwen.com/i1899977/153cea642172b162.png)
4、配置hornetq-jms.xml
hornetq-jms.xml主要是配置队列名称,队列配置不同于其他配置,它属于立即生效,不需要重启。在该文件中默认ExpiryQueue队列下添加队列即可。
![](https://img.haomeiwen.com/i1899977/296c3db261d880c8.png)
4、启动HornetQ
cd bin
nohup ./run.sh &
tailf nohup.out
日志中看到 Server is now live表示启动成功。
![](https://img.haomeiwen.com/i1899977/679fb04cb3155078.png)
5、使用JConsole监控HornetQ
修改HQ的bin目录下的run.sh文件,在默认的java启动命令中加入三个参数:
-Dcom.sun.management.jmxremote.port="6666"
-Dcom.sun.management.jmxremote.authenticate="false"
-Dcom.sun.management.jmxremote.ssl="false"
//port指定远程连接的端口号
//设置authenticate为false,jconsole远程连接jvm时,就不需要输入JVM的用户名和密码(服务器用户名和密码还是要输入的)。否则,要在/jre/lib/management/jmxremote.password中配置密码。
//ssl默认为true,需要指定为false,否则仍需进行身份认证
参数具体含义可以参考Oracle的官方文档
![](https://img.haomeiwen.com/i1899977/dcdac9597ddbd44a.png)
![](https://img.haomeiwen.com/i1899977/4868bcbfd61998c3.png)
修改完成后,运行bin目录下的stop.sh文件停止服务,然后按照第四步重新启动HornetQ。
最后,打开JConsole连接刚才设置好的端口以及对应的IP,并输入服务器的用户名和密码:
![](https://img.haomeiwen.com/i1899977/f2b3a9705cb0ae89.png)
连接成功之后,可以查看具体的信息:
![](https://img.haomeiwen.com/i1899977/4099a4016cccbe6a.png)