修改内存
CentOS6.5 64位,启动在${activemq.home}/bin/linux-x86-64/activemq start|restart|stop|status
配置web管理页面的安全认证
默认的web页面用户名密码admin:admin,非常不安全,
编辑jetty-realm.properties文件,(用户:密码,组)
admin: admin123, admin
user: user123, user
配置web管理页面的绑定IP和端口
编辑jetty.xml,查找WebConsolePort
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
<!-- the default port number for the web console -->
<property name="host" value="192.168.0.31"/>
<property name="port" value="8161"/>
</bean>
配置MQ连接的安全认证
编辑activemq.xml,在<broker>下加
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="user" password="user123" groups="users" />
</users>
</simpleAuthenticationPlugin>
</plugins>
禁用不使用的连接协议
编辑activemq.xml,在<transportConnectors>中注销或删除不使用的<transportConnector>
<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>
上面我只保留了61616的openwire协议端口
绑定协议连接端口到指定IP
编辑activemq.xml,在<transportConnectors>下找到指定协议的配置,并修改0.0.0.0为要绑定的ip
<transportConnector name="openwire" uri="tcp://192.168.0.10:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
使用MySql作为持久化保存
拷贝mysql-connector-java-5.1.28-bin.jar commons-dbcp.jar commons-pool.jar 到 lib 目录下
建空数据库 CREATE DATABASE IF NOT EXISTS `activemq` DEFAULT CHARACTER SET latin1; 注意:::: CHARACTER SET latin1; utf-8会报错
编辑activemq.xml,在<beans>下插入如下bean配置
<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://192.168.0.20/activemq?relaxAutoCommit=true" />
<property name="username" value="activemq" />
<property name="password" value="123456" />
<property name="poolPreparedStatements" value="true" />
</bean>
删除或注销掉<persistenceAdapter>下的<kahaD>,添加<jdbcPersistenceAdapter>
<persistenceAdapter>
<!--<kahaDB directory="${activemq.data}/kahadb"/>-->
<jdbcPersistenceAdapter dataDirectory="activemq-data" dataSource="#mysql-ds"/>
</persistenceAdapter>
配置基于JDBC的高可用环境
两个以上activemq使用一样的db配置,
客户端连接url为failover:(tcp:
//broker1:61616,tcp://broker2:61616)?jms.useAsyncSend=true
修改内存
linux下,修改bin/env的ACTIVEMQ_OPTS_MEMORY属性,Xms=最小内存,Xmx=最大内存
ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx1G"
window下,修改activemq.bat,在 if "%ACTIVEMQ_OPTS%" == " 前设置
set ACTIVEMQ_OPTS=-Xms1G -Xmx1G
注册为Service
linux(RedHat,Centos)下(官方参考文档),运行以下命令注册为service,并设置为开机自动启动
?
1 2 3 | |
然后就可以使用如下service命令了
?
1 | |
可能遇到的问题:
查看启动记录:${active.home}/bin/activemq console
1)
错误:
INFO | Database lock driver override not found for : [mysql-ab_jdbc_driver]. Will use default implementation.
INFO | Attempting to acquire the exclusive lock to become the Master broker
INFO | Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...
INFO | Failed to acquire lock. Sleeping for 1000 milli(s) before trying again...
解决办法:
在persistenceAdapter中添加useDatabaseLock="false"
<persistenceAdapter>
<jdbcPersistenceAdapter dataSource="#mysql-ds" useDatabaseLock="false" />
</persistenceAdapter>
2)
错误:
Failure Details: Binary logging not possible.
解决:
修改my.cnf,把下面几行打开。
log-bin=mysql-bin
binlog_format=mixed
Apache ActiveMQ URL请求源码泄露漏洞
漏洞描述:
Apache ActiveMQ是流行的消息传输和集成模式提供程序。
Apache ActiveMQ中存在输入验证错误,用户在提交给admin/index.jsp、admin/queues.jsp、admin /topics.jsp等管理页面的URL请求后附加“//”就可以读取JSP页面源码。
测试方法:
本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
临时解决方法:
1. 到${ACTIVEMQ_HOME}/webapps}}目录下
2. 创建名为static的新目录 - mkdir static
3. 将index.html文件移动到该目录下 - mv index.html static/
4. 更改ResourceHandler使用static目录,编辑{{${ACTIVEMQ_HOME}/conf/jetty.xml将 ResourceHandler定义更改为
<bean class="org.mortbay.jetty.handler.ResourceHandler">
<property name="welcomeFiles">
<list>
<value>index.html</value>
</list>
</property>
<property name="resourceBase" value="${activemq.base}/webapps/static"/>
</bean>
厂商补丁:
Apache Group
------------
cd conf ,修改activemq.xml 修改里面的61616端口
修改jetty.xml,修改内容容器jetty的默认启动端口,找到默认的8161后修改