zoukankan      html  css  js  c++  java
  • 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后修改



  • 相关阅读:
    【flutter学习】基础知识(一)
    【软件测试学习】 敏捷开发(二)
    【软件测试学习】 软件测试初步认识(一)
    【hugo】- hugo 监听浏览器切换title
    【hugo】- hugo 博客 添加鼠标单击特效
    春风十里
    一眼就能看懂的C#委托、多播委托和事件的区别与联系。
    js控制的DataGrid的URL参数不能动态刷新表格的问题
    [报错解决].net web api测试页面ajax 报错400 的问题
    [MVC]使用jquery.form.js 异步上传文件
  • 原文地址:https://www.cnblogs.com/jpfss/p/10445501.html
Copyright © 2011-2022 走看看