Install ActiveMQ under Linux

1. Download or upload the installation package to the installation directory of the server and enter the installation directory: cd /opt/

2. Unzip: tar -zxvf apache-activemq-5.11.1-bin.tar.gz

3. Rename: mv apache-activemq-5.11.1/activemq5

4. Open the port filtering of the firewall. By default, 8161 is the port of the control console, and 61616 is the message communication port.

vi /etc/sysconfig/iptables, add the following:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8161 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 61616 -j ACCEPT

--Restart firewall: service iptables restart

The port of the console can be modified here: vi activemq5/conf/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>

5. Start the service: ./activemq5/bin/activemq start, access the console test

http://192.168.0.207:8161, the default username and password are: admin

6. Control console authority control and password modification

--Modify default password

vi activemq5/conf/jetty-realm.properties, as follows:

# username: password [,rolename ...]

admin : admin , admin

user: user, user

-- Modify whether to verify the login

vi activemq5/conf/jetty.xml, as follows:

<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">

        <property name="name" value="BASIC" />

        <property name="roles" value="user,admin" />

        <!-- set authenticate=false to disable login -->

        <property name="authenticate" value="true" />

    </bean>

7. View the startup log

tail -f activemq5/data/activemq.log 

8. Self-start at boot

vi /etc/rc.local, add the following content

#JAVA_HOME

export JAVA_HOME=/opt/jdk1.7.0_07

 #activemq

/opt/activemq5/bin/activemq start

9. Security configuration (message security), if no security policy is set, others can send messages without restrictions or obtain known queue topic data when they know the service address and port.

vi activemq5/conf/activemq.xml, add simple access control to the <borker> node, which can be added above the </broker> node:

 

<plugins>
             <simpleAuthenticationPlugin>
                 <users>
                     <authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/>
                 </users>
             </simpleAuthenticationPlugin>
        </plugins>

 10. Management interface description 


Number Of Consumers: Indicates the number of consumers;

Number Of Pending Messages: Messages waiting to be consumed, this is the number of currently unqueued; 

Messages Enqueued: messages entering the queue; (this number only increases and does not decrease, it will be cleared after restarting acmq) 

Messages Dequeued: Messages out of the queue can be understood as the consumption of the amount consumed (it will be cleared after restarting acmq)

In general,

1. When there are producers sending messages and consumers consuming messages at the same time, Number Of Pending Messages=0, Messages Enqueued=Messages Dequeued. That is: the number of waiting for consumption is 0, and the incoming and outgoing messages are equal ( finally).

2. When there are producers sending messages and there are no consumers, Number Of Pending Messages=Messages Enqueued. That is, the number of messages enqueued is equal to the number to be consumed.

3. When AMQ restarts, Messages Enqueued=Messages Dequeued = 0 (ie: clear), if message persistence is set, the messages that were not consumed before restart will be displayed in Number Of Pending Messages.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443527&siteId=291194637