ActiveMQ进阶配置

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&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的openwire协议端口

绑定协议连接端口到指定IP

编辑activemq.xml,在<transportConnectors>下找到指定协议的配置,并修改0.0.0.0为要绑定的ip

<transportConnector name="openwire" uri="tcp://192.168.0.10:61616?maximumConnections=1000&amp;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
ln -snf bin /activemq /etc/init .d /activemq
chkconfig --add activemq
chkconfig activemq on

然后就可以使用如下service命令了

?
1
service activemq start|stop|status|restart

可能遇到的问题:

查看启动记录:${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页面源码。<*参考 
http://marc.info/?l=bugtraq&m=127196074718617&q=p3
https://issues.apache.org/activemq/si/jira.issueviews:issue-html/AMQ-2700/AMQ-2700.html
http://secunia.com/advisories/39567/
*>
测试方法:

本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!http://www.example.com:8161//admin/index.jsp
http://www.example.com:8161//admin/queues.jsp
http://www.example.com:8161//admin/topics.jspSEBUG安全建议:
临时解决方法:

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
------------
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载

https://repository.apache.org/content/repositories/snapshots/org/apache/activemq/apache-activemq/5.4-SNAPSHOT/apache-activemq-5.4-SNAPSHOT-bin.tar.gz



cd conf ,修改activemq.xml 修改里面的61616端口


修改jetty.xml,修改内容容器jetty的默认启动端口,找到默认的8161后修改



  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值