Install Apache ActiveMQ on Ubuntu 20.04

原文链接:https://www.vultr.com/docs/install-apache-activemq-on-ubuntu-20-04/

Introduction

A message broker enables applications to communicate with each other to share information. Apache ActiveMQ is a popular open-source, multi-protocol, Java message broker. It supports industry-standard protocols such as AMQP (Advanced Message Queuing Protocol) to integrate multi-platform applications, STOMP (Simple Text Orientated Messaging Protocol) for exchanging messages between web applications over websockets, and MQTT (Message Queuing Telemetry Transport) to manage IoT devices. In this article, you will learn how to install Apache ActiveMQ on Ubuntu 20.04 server.

Prerequisites

1. Install Java

  1. Update the system.

    $ sudo apt update
    
  2. Apache ActiveMQ requires Java to run. Install Java.

    $ sudo apt install openjdk-11-jre -y
    
  3. Verify the Java installation.

    $ java -version
    

2. Install and Configure Apache ActiveMQ

  1. Download ActiveMQ from the Apache. To find the latest version of this software, you can visit the download page.

    $ wget http://archive.apache.org/dist/activemq/5.16.3/apache-activemq-5.16.3-bin.tar.gz
    
  2. Extract the downloaded file.

    $ sudo tar -xvzf apache-activemq-5.16.3-bin.tar.gz
    
  3. Create a directory named /opt/activemq.

    $ sudo mkdir /opt/activemq
    
  4. Move the extracted files to the /opt/activemq directory.

    $ sudo mv apache-activemq-5.16.3/* /opt/activemq
    
  5. Create a group account activemq to run Apache ActiveMQ.

    $ sudo addgroup --quiet --system activemq
    
  6. Create a user for the group.

    $ sudo adduser --quiet --system --ingroup activemq --no-create-home --disabled-password activemq
    
  7. Change the permissions of the /opt/activemq directory.

    $ sudo chown -R activemq:activemq /opt/activemq
    
  8. Create an ActiveMQ systemd service file to control the Apache ActiveMQ service.

    $ sudo nano /etc/systemd/system/activemq.service
    
  9. Add the below code into the file. Save and close the file.

    [Unit]
    Description=Apache ActiveMQ
    After=network.target
    [Service]
    Type=forking
    User=activemq
    Group=activemq
    
    ExecStart=/opt/activemq/bin/activemq start
    ExecStop=/opt/activemq/bin/activemq stop
    
    [Install]
    WantedBy=multi-user.target
    
  10. Edit the jetty.xml configuration file to change the host.

    $ sudo nano /opt/activemq/conf/jetty.xml
    
  11. Find the line below:

    <property name="host" value="127.0.0.1"/>
    

    Change it to:

    <property name="host" value="0.0.0.0"/>
    
  12. Save and close the file.

  13. Reload the system daemon.

    $ sudo systemctl daemon-reload
    
  14. Start the Apache ActiveMQ service.

    $ sudo systemctl start activemq
    
  15. Enable the Apache ActiveMQ service to run at system startup.

    $ sudo systemctl enable activemq
    
  16. Verify the status of the service.

    $ sudo systemctl status activemq
    
  17. Restart ActiveMQ service.

    $ sudo systemctl restart activemq
    

3. Access Apache ActiveMQ Web Interface

Open your web browser and access the Apache ActiveMQ web UI using the URL http://YourServerIP:8161/admin/. For example:

http://192.0.2.10:8161/admin/

Conclusion

You have successfully installed Apache ActiveMQ on your Ubuntu server. Use the default credentials admin as your username and admin as your password to log in. You can now configure Apache ActiveMQ via the dashboard.

posted @ 2022-05-20 10:08  h.yl  阅读(174)  评论(0编辑  收藏  举报