Kiến Thức Linux Linux Nâng Cao

How to Install Apache ActiveMQ on Debian

ActiveMQ

Apache ActiveMQ is an open source message broker written in Java developed by Apache. It’s one of the most popular message brokers. It offers power and flexibility, supports multi-protocol and java-based messaging server. Connectivity from major programing language such as C, C++, Python, .Net, etc.

Apache ActiveMQ allows you to integrate multi-platform applications using the ubiquitous AMPQ protocol. An exchange between web applications using the STOMP over websocket, manage IoT devices using the MQTT, and supports JMS infrastructure and beyond.

In this tutorial, we will show you how to install the Apache ActiveMQ on the latest Debian Buster 10. We will install the ActiveMQ using the official binary file, setup the ActiveMQ as a systemd service, and enable password authentication.

Prerequisites

For this guide, we will use the latest Debian Buster 10 with 2GB of RAM, 50GB free disk space, and 2 CPUs.

What we will do?

  • Install Java on Debian 10
  • Download and Install Apache ActiveMQ
  • Setup Apache ActiveMQ as a Systemd Service
  • Setup Encrypted Password for Web Console
  • Testing

Step 1 – Install Java on Debian 10

First, we will install the Java OpenJDK and JRE to the Debian Buster 10. Both packages are available by default on the Debian repository.

Update all available repositories on the Debian system and install the Java OpenJDK and JRE using the apt command below.

sudo apt update
sudo apt install default-jdk default-jre

Once all installation is completed, check the Java version using the following command.

java -version

Below is the response you will get.

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Debian-3deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Debian-3deb10u1, mixed mode, sharing)

As a result, the Java OpenJDK and JRE ’11’ has been installed on the Debian Server.

Step 2 – Download and Install Apache ActiveMQ

In this step, we will download and install the Apache ActiveMQ to our Debian system.

Before going any further, let’s create a new system user ‘activemq’ using the following command.

adduser --system --no-create-home --disabled-login --group activemq

Now download the Apache ActiveMQ Binary file and extract the file using the following command.

wget --quiet http://www-us.apache.org/dist/activemq/5.15.12/apache-activemq-5.15.12-bin.tar.gz
tar -xf apache-activemq-5.15.12-bin.tar.gz

After that, move the Apache ActiveMQ directory to ‘/opt/activemq’ and change the ownership of the ActiveMQ directory to the user ‘activemq’.

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

As a result, The Apache ActiveMQ is installed on the Debian System.

Step 3 – Setup Apache ActiveMQ as a Systemd Service

After downloading and installing the Apache ActiveMQ, we will set up the ActiveMQ as a systemd service.

Now go to the ‘/etc/systemd/system’ directory and create a new service file ‘activemq.service’ using vim editor.

cd /etc/systemd/system/
vim activemq.service

Paste the following configuration into it.

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

[Service]
Type=forking
WorkingDirectory=/opt/activemq/bin
ExecStart=/opt/activemq/bin/activemq start
ExecStop=/opt/activemq/bin/activemq stop
Restart=on-abort
User=activemq
Group=activemq

[Install]
WantedBy=multi-user.target

Save and close.

Next, reload the systemd manager to apply the new systemd service configuration.

systemctl daemon-reload

Now start the ActiveMQ server and add it to the system boot.

systemctl start activemq
systemctl enable activemq

As a result, the Apache ActiveMQ is up and running, check it using the following command.

systemctl status activemq

Below is the result you will get.

Step 4 – Setup Encrypted Password for Web Console

By default, the authentication of the ActiveMQ Web Console is enabled, all user and password for ActiveMQ are stored in the ‘jetty-realm.properties’ as plain-text. For this step, we will change the default plain-text password with an encrypted password.

First, download the jetty distribution and extract.

wget --quiet https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.28.v20200408/jetty-distribution-9.4.28.v20200408.tar.gz
tar -xf jetty-distribution-*.tar.gz

Now go to the ‘jetty-distribution-*’ directory.

cd jetty-distribution-*/

Run the following command to generate your password, and make sure to change the ‘salt’ and password with your own.

java -cp lib/jetty-util-9*.jar org.eclipse.jetty.util.security.Password salt password

Now you will get the following response.

2020-04-29 07:15:22.367:INFO::main: Logging initialized @194ms to org.eclipse.jetty.util.log.StdErrLog
mypassword
OBF:1uh41zly1x8g1vu11ym71ym71vv91x8e1zlk1ugm
MD5:34819d7beeabb9260a5c854bc85b3e44
CRYPT:myylAylKPNtmw

Copy the ‘CRYPT:myy...’ encrypted password to your note, because it will be used for the ActiveMQ.

Now go to the ActiveMQ configuration directory ‘/opt/activemq/conf’ and edit the configuration ‘jetty-realm.properties’ using vim editor.

cd /opt/activemq/conf/
vim jetty-realm.properties

Change the default admin password with the generated encrypted password ‘CRYPT:myy…’ as below.

admin: CRYPT:myylAylKPNtmw, admin
user: user, user

Save and close.

Next, restart the Apache ActiveMQ service to apply the new configuration.

systemctl restart activemq

As a result, the configuration of the ActiveMQ Web Console with the encrypted password has been completed.

Step 5 – Testing

Now open your web browser and type the server IP address with port ‘8161’.

http://serverip:8161/

And you will get the default index.html page of the ActiveMQ Web Console.

Next, add the ‘/admin’ path on the URL as below.

http://serverip:8161/admin

And you will be prompted for the ActiveMQ authentication.

Type the default user ‘admin’ with your password as generated on top, then click ‘OK’ to login.

Once your password is correct, you will get the ActiveMQ Dashboard as below.

As a result, the installation and configuration of Apache ActiveMQ on the Debian Buster 10 has been completed successfully.

 

 

 

 

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Tags

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !