默认的web页面用户名密码admin:admin,非常不安全,
编辑jetty-realm.properties文件,(用户:密码,组)
admin: admin123 , admin
user: user123 , user
编辑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>
编辑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协议端口
编辑activemq.xml,在 < transportConnectors>下找到指定协议的配置,并修改0.0.0.0为要绑定的ip
<transportConnector name="openwire" uri="tcp:// 192.168.0.10 :61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
编辑activemq.xml,在<beans>下插入如下bean配置
<bean id="mysql-ds" class="org.apache.commons.dbcp2.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>
两个以上activemq使用一样的db配置,
客户端连接url为 failover:(tcp:
//broker1:61616,tcp://broker2:61616)
官方参考文档
linux下,修改bin/env的 ACTIVEMQ_OPTS_MEMORY属性 ,Xms=最小内存, Xmx=最大内存
ACTIVEMQ_OPTS_MEMORY="-Xms 64M -Xmx 1G"
window下,修改activemq.bat,在 if "%ACTIVEMQ_OPTS%" == " 前设置
set ACTIVEMQ_OPTS=-Xms 1G -Xmx 1G
linux(RedHat,Centos)下( 官方参考文档 ),运行以下命令注册为service,并设置为开机自动启动
ln -snf bin/activemq /etc/init.d/activemq chkconfig --add activemq chkconfig activemq on
然后就可以使用如下service命令了
service activemq start|stop|status|restart