CentOS ACTIVEMQ cluster configuration Networks of Brokers

Source: Internet
Author: User

1. Install the JDK operating environment

#cd/opt #wget--no-check-certificate--no-cookies--header "Cookie:oraclelicense=accept-securebackup-cookie"/HTTP/ download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz #tar zxvf jdk-8u112-linux-x64.tar.gz #vi /etc/profile Add the following export Java_home=/opt/jdk-8u112export path= $JAVA _home/bin: $PATHexport classpath=.: $JAVA _home/li B/dt.jar: $JAVA _home/lib/tools.jar#source/etc/profile#java-versionjava Version "1.8.0_12" JAVA (TM) SE Runtime Environment (build 1.8.0_12-b12) Java HotSpot (TM) 64-bit Server VM (build 25.12-b03, Mixed mode)

Second, installation configuration Activemq

Here we configure the networks of brokers cluster mode

Activemq-1 and activemq-2 These two brokers are prepared for each other, messages sent to you will sync to me, messages sent to me will be synced to you, the implementation of HA, as follows:192.168.1.104:61616<--> 192.168.1.105:61626

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/95/68/wKiom1kVDY7CWEFEAAEQ1FH8mow454.png-wh_500x0-wm_ 3-wmp_4-s_3165021793.png "title=" Qq20170512091811.png "alt=" Wkiom1kvdy7cwefeaaeq1fh8mow454.png-wh_50 "/>



#wget   #tar  -zxvf apache-activemq-5.14.5-bin.tar.gz# vi conf/activemq.xml   Configuration on  192.168.1.104 (write 192.168.1.105:61626) <beans        xmlns= "Http://www.springframework.org/schema/beans"         xmlns:xsi= "http:/ /www.w3.org/2001/xmlschema-instance "        xsi:schemalocation=" http:/ /www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd   http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd " >  <bean class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >    <property name= "Locations" >      < Value>file:${activemq.conf}/credentials.properties</value>    </property>   </bean>  <broker xmlns= "Http://activemq.apache.org/schema/core"  brokername= "Activemq-1" >     <networkconnectors>      <networkconnector  uri= "Static: (tcp://192.168.1.105:61626)"/>    </networkconnectors>     <persistenceadapter>      <kahadb directory= "${ Activemq.data}/kahadb "/>    </persistenceadapter>    < Transportconnectors>      <transportconnector name= "Openwire"                             uri= "tcp://0.0.0.0:61616?maximumconnections=1000&amp; wireformat.maxframesize=104857600 "/>    </transportconnectors>  </ Broker>  <import resOurce= "Jetty.xml"/></beans> Similarly, configure (write 192.168.1.104:61616) on 192.168.1.105 #vi  conf/activemq.xml< Beans        xmlns= "Http://www.springframework.org/schema/beans"          xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"          xsi:schemalocation= "Http://www.springframework.org/schema/beans http ://www.springframework.org/schema/beans/spring-beans.xsd  http://activemq.apache.org/schema/core  http://activemq.apache.org/schema/core/activemq-core.xsd ">  <bean class=" Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">    < Property name= "Locations" >      <value>file:${activemq.conf}/ credentials.properties</value>    </property>  </bean>   <broker xmlns= "Http://activemQ.apache.org/schema/core " brokername=" Activemq-1 ">    <networkConnectors>       <networkconnector uri= "Static: (tcp://192.168.1.104:61616)"/>     </networkConnectors>    <persistenceAdapter>       <kahadb directory= "${ACTIVEMQ.DATA}/KAHADB"/>     </persistenceAdapter>    <transportConnectors>       <transportconnector name= "Openwire"                            uri= "tcp:// 0.0.0.0:61626?maximumconnections=1000&amp;wireformat.maxframesize=104857600 "/>     </transportconnectors>  </broker>  <import resource= "Jetty.xml"/> </beans>

After the configuration, we started it separately,

# BIN/ACTIVEMQ start#tail-f data/activemq.log View Log can see the connection has been established 2017-05-12 09:33:43,404 | INFO | Establishing network connection from Vm://activemq-1?async=false&create=false to tcp://192.168.1.105:61626 | Org.apache.activemq.network.DiscoveryNetworkConnector | Main


accessing ACTIVEMQ Console

http://ip:8161/admin/(Default account: admin default password: admin)

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/95/69/wKioL1kVFpjiO6MzAADNJvaAl9Y601.png-wh_500x0-wm_ 3-wmp_4-s_842692384.png "style=" Float:none; "title=" Qq20170512095641.png "alt=" Wkiol1kvfpjio6mzaadnjvaal9y601.png-wh_50 "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/95/69/wKiom1kVFpiC4cxnAADDrCUyuoY129.png-wh_500x0-wm_ 3-wmp_4-s_4172104857.png "style=" Float:none; "title=" Qq20170512095617.png "alt=" Wkiom1kvfpic4cxnaaddrcuyuoy129.png-wh_50 "/>


producer and consumer are connected to ACTIVEMQ, the configuration file can be written like this:

<bean id= "Jmsfactory"  class= " Org.apache.activemq.pool.PooledConnectionFactory " destroy-method=" Stop ">    < Property name= "ConnectionFactory" >        <bean class= "Org.apache.activemq.ActiveMQConnectionFactory" >             <!--The address of the broker service-->             <property name= "Brokerurl"  value= "Failover: (tcp://192.168.1.104:61616,tcp:// 192.168.1.105:61626) "/>            ...         </bean>    </property></bean> 

The advantage of this HA scheme is that it takes up fewer nodes (only 2 nodes), and 2 brokers can respond to the receipt and delivery of messages, which is better than the zookeeper scheme.






This article is from the "xiangcun168" blog, make sure to keep this source http://xiangcun168.blog.51cto.com/4788340/1924888

CentOS ACTIVEMQ cluster configuration Networks of Brokers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.