activemq一台机器起多个实例

来源:互联网 发布:网络平台app代理 编辑:程序博客网 时间:2024/06/11 09:53

在一台机器上面启动多个activemq实例,然后这几个实例通过配置可以变为一个集群。

将conf文件整个copy出来,修改activemq.xml文件

 <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">        <property name="broker_1">            <value>file:${activemq.conf}/credentials.properties</value>        </property>  </bean>

name要改,集群的节点不能重名。

<persistenceAdapter>     <kahaDB directory="${activemq.data}/kahadb01"/> </persistenceAdapter>

节点存储数据的路径要改

 <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>

所有涉及transportConnectors的端口,都要不一样
到此,activemq就修改完了。
因为这个项目内嵌了jetty。所以要修改jetty配置文件的端口
jetty.xml文件

 <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">         <!-- the default port number for the web console -->         <property name="host" value="0.0.0.0"/>         <property name="port" value="8161"/> </bean>

复制一个bin下面的activemq,进行修改

if [ -z "$ACTIVEMQ_PIDFILE" ]; then   ACTIVEMQ_PIDFILE="$ACTIVEMQ_DATA/activemq.pid"fi

记录实例pid的文件路径,这里最好是设置一个绝对路径,比如/usr/local/activemq-cluster/01/activemq.pid

ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf"

配置conf文件的路径,最好也搞成绝对地址:/usr/local/activemq-cluster/01/conf

现在就可以执行了

activemq start

0 0