How to install Apache ActiveMQ on CentOS 8

Welcome to today’s guide on how to install Apache ActiveMQ on CentOS 8. Apache ActiveMQ is an open source and most popular multi-protocol messaging server written in Java. Apache ActiveMQ enables you to send messages from one application (sender) to another (receiver / consumer). The message broker has a reasonable level of functionality, support for client libraries, and mature documentation that you can refer to.

Main features of Apache ActiveMQ

This is a summary of the key Apache ActiveMQ.

Install Apache ActiveMQ on CentOS 8

This blog post was written to guide you through the Apache ActiveMQ installation on a CentOS 8 Linux distribution. This step is easy to perform and does not require a good Linux background.

Step 1: Install Java

First install Java on CentOS 8:

Install Java 11 on CentOS 8

Install Java 8 on CentOS 8

Step 2: Download Apache ActiveMQ on CentOS 8

Visit Apache ActiveMQ download Page for the latest Apache ActiveMQ.

wget https://www.apache.org/dist/activemq/5.15.11/apache-activemq-5.15.11-bin.tar.gz

Unzip the downloaded file.

tar xvf apache-activemq-5.15.11-bin.tar.gz

Move the created directory / Select path.

sudo mv apache-activemq-*/ /opt/apache-activemq

This is a list of files in the directory.

$ ls -lh /opt/apache-activemq/
total 18M
-rwxr-xr-x. 1 cloud-user cloud-user  18M Nov 20 19:59 activemq-all-5.15.11.jar
drwxrwxr-x. 5 cloud-user cloud-user  147 Mar  6 21:14 bin
drwxr-xr-x. 2 cloud-user cloud-user 4.0K Mar  6 21:14 conf
drwxr-xr-x. 2 cloud-user cloud-user   26 Mar  6 21:14 data
drwxr-xr-x. 2 cloud-user cloud-user   76 Mar  6 21:14 docs
drwxr-xr-x. 7 cloud-user cloud-user   71 Nov 20 20:25 examples
drwxr-xr-x. 6 cloud-user cloud-user 4.0K Mar  6 21:14 lib
-rw-r--r--. 1 cloud-user cloud-user  40K Nov 20 20:25 LICENSE
-rw-r--r--. 1 cloud-user cloud-user 3.3K Nov 20 20:25 NOTICE
-rw-r--r--. 1 cloud-user cloud-user 2.6K Nov 20 20:25 README.txt
drwxr-xr-x. 6 cloud-user cloud-user   95 Mar  6 21:14 webapps
drwxrwxr-x. 3 cloud-user cloud-user   18 Mar  6 21:14 webapps-demo

Step 3: Create Apache ActiveMQ System Unit on CentOS 8

Create an activemq user to run the service.

sudo useradd activemq

Set directory permissions.

sudo chown -R activemq:activemq /opt/apache-activemq/

We will create a Systemd unit file to manage the Apache ActiveMQ service.

$ sudo vim /etc/systemd/system/apache-activemq.service

[Unit]
Description=Apache ActiveMQ Messaging Server
After=network.target

[Service]
Type=forking
User=activemq
Group=activemq

ExecStart=/opt/apache-activemq/bin/activemq start
ExecStop=/opt/apache-activemq/bin/activemq stop

[Install]
WantedBy=multi-user.target

Reload the list of available Systemd service unit files.

sudo systemctl daemon-reload 

Put SELinux in relaxed mode.

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Now start and enable the service.

sudo systemctl enable apache-activemq.service
sudo systemctl start apache-activemq.service

Confirm service status:

$ systemctl status  apache-activemq.service 
● apache-activemq.service - Apache ActiveMQ Messaging Server
   Loaded: loaded (/etc/systemd/system/apache-activemq.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-03-06 22:06:09 EAT; 5s ago
  Process: 4306 ExecStop=/opt/apache-activemq/bin/activemq stop (code=exited, status=1/FAILURE)
  Process: 4680 ExecStart=/opt/apache-activemq/bin/activemq start (code=exited, status=0/SUCCESS)
 Main PID: 4732 (java)
    Tasks: 14 (limit: 11512)
   Memory: 91.9M
   CGroup: /system.slice/apache-activemq.service
           └─4732 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/apache-activem>

Mar 06 22:06:09 cent8.novalocal systemd[1]: Starting Apache ActiveMQ Messaging Server...
Mar 06 22:06:09 cent8.novalocal activemq[4680]: INFO: Loading '/opt/apache-activemq//bin/env'
Mar 06 22:06:09 cent8.novalocal activemq[4680]: INFO: Using java '/usr/bin/java'
Mar 06 22:06:09 cent8.novalocal activemq[4680]: INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
Mar 06 22:06:09 cent8.novalocal activemq[4680]: INFO: pidfile created : '/opt/apache-activemq//data/activemq.pid' (pid '4732')
Mar 06 22:06:09 cent8.novalocal systemd[1]: Started Apache ActiveMQ Messaging Server.

Step 4: Change the administrator user password

Change the default administrator user password to a unique password.

$ sudo vi /opt/apache-activemq/conf/jetty-realm.properties

The user definitions in this file take the following form:

username: password [,rolename ...]

I have updated my following.

admin: MyAdminPassw0rd, admin
user: MyUserPassw0rd, user

After making changes, restart the apache-activemq service.

sudo systemctl restart apache-activemq

Verify that authentication is valid, replace password Use your password:

curl --head --user admin:MyAdminPassw0rd http://localhost:8161/admin/xml/topics.jsp

Output:

HTTP/1.1 200 OK
Date: Fri, 06 Mar 2020 19:41:51 GMT
X-FRAME-OPTIONS: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=node0yqbxi60ra47n1fysq6zgx2lte0.node0; Path=/admin; HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/xml;charset=iso-8859-1
Content-Length: 187
Server: Jetty(9.4.22.v20191022)

A kind 200 An OK message should be displayed. A kind 401 unauthorized The message indicates that your username or password is incorrect.

Step 5: Access the Apache ActiveMQ web console

The web console will run on the port 8161. Open the server IP address / hostname to access the ActiveMQ web console.

http://192.168.122.48:8161/admin/

Authenticate using the username and password you created.

You should be provided with an ActiveMQ web interface that looks similar to the following.

How to install Apache ActiveMQ on CentOS 8

Reference Apache ActiveMQ documentation understand more. Other related guidelines:

How to install RabbitMQ on RHEL 8 / CentOS 8

How to set up a RabbitMQ cluster on Ubuntu 18.04 LTS

How to backup and restore RabbitMQ data and configuration

Sidebar