Home / How To / How to install Apache ActiveMQ and Hawt.io on CentOS 8

How to install Apache ActiveMQ and Hawt.io on CentOS 8



Apache ActiveMQ is a free, open source and Java based message broker that can be used to send messages between two applications. It offers many features including high availability and load balancing of messages for your data. It also supports multiple language clients and protocols including, Java, C, C ++, Python, PHP, Perl, Ruby and C #. It translates messages from sender to recipient and allows messages to be queued.

In this tutorial, we will teach you how to install Apache ActiveMQ on CentOS 8.

Prerequisites

  • A server running CentOS 8. [19659005] A root password is configured on your server.

Installing Java

Apache ActiveMQ is a Java based application so Java must be installed in your system. If it is not installed, you can install it with the following command:

  dnf install java-11-openjdk-devel -y 

After installing Java, verify the installed version of Java with the following command:

  java - version 

You should get the following output:

  openjdk 11.0.6 2020-01-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.6 + 10-LTS)
OpenJDK 64-bit server VM 18.9 (build 11.0.6 + 10-LTS, mixed mode, sharing)

Installing and Configuring Apache ActiveMQ

First you need to download the latest version of ActiveMQ from their official website. You can download it with the following command:

  cd / opt 
wget https://www.apache.org/dist/activemq/5.15.12/apache-activemq-5.15.12 -bin.tar.gz

Once downloaded, extract the downloaded file with the following command:

  tar -xvzf apache-activemq-5.15.12-bin.tar.gz 

Then rename the extracted directory apache -activemq with the following command:

  etc. apache-activemq-5.15.12 apache-activemq 

Then it is a good idea to create a separate user for Apache ActiveMQ. You can create a new user named activemq with the following command:

  useradd activemq 

Then change the ownership of the apache-activemq directory to activemq:

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

When you are finished, you can proceed to the next step.

Create Systemd Service File for ActiveMQ

Then you need to create a Systemd Service File to manage the Apache ActiveMQ service. You can create it with the following command:

  nano /etc/systemd/system/apache-activemq.service tu 1919900919 Add the following lines: 

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

[Service]
Type = forking
User = ActiveMQ
The group = ActiveMQ

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

[Install]
WantedBy = multi-user.target

Save and close the file when you are done. Then reload the system daemon with the following command:

  systemctl daemon-reload 

Then start the ActiveMQ service and enable it after system startup with the following command:

  systemctl start apache-activemq 
systemctl enable apache-activemq

You can verify the status of the ActiveMQ service with the following command:

  systemctl status apache-activemq 

You should see the following output:

? apache-activemq.service - Apache ActiveMQ Messaging Server
Loaded: loaded (/etc/systemd/system/apache-activemq.service; disabled; vendor setting: disabled)
Active: active (running) since Thu 2020-03-26 10:15:32 PM EDT; 12 years ago
Process: 9005 ExecStart = / opt / apache-activemq / bin / activemq start (code = terminated, status = 0 / SUCCESS)
Main PID: 9057 (java)
Details: 49 (limit: 25028)
Memory: 197.5 M
CGroup: /system.slice/apache-activemq.service
?? 9057 / usr / bin / java -Xms64M -Xmx1G -Djava.util.logging.config.file = logging.properties -Djava.security.auth.login.config = / opt / apach>

Mar 26 10:15:32 centos8 systemd [1]: Launch Apache ActiveMQ Messaging Server ...
26 Mar 10:15:32 centos8 activemq [9005]: INFO: Loading & # 39; / opt / apache-activemq // bin / env & # 39;
26 Mar 10:15:32 centos8 activemq [9005]: INFO: Using java & # 39; / usr / bin / java & # 39;
26 Mar 10:15:32 centos8 activemq [9005]: INFO: Start - inspect log files specified in logging.properties and log4j.properties for information
26 Mar 10:15:32 centos8 activemq [9005]: INFO: pidfile created: & # 39; /opt/apache-activemq//data/activemq.pid' (pid & # 39; 9057 & # 39;)
Mar 26 10:15:32 centos8 systemd [1]: Started Apache ActiveMQ Messaging Server.

By default, Apache ActiveMQ listens on port 8161. You can check it with the following command:

  netstat -antup | grep 8161 

You should get the following output:

  tcp6 0 0 ::: 8161 ::: * LISTEN 9289 / java

Set Apache ActiveMQ Admin Password

By default, Apache ActiveMQ admin username and password is set to admin / admin. It is very dangerous for security reasons. So it is recommended that you change it with a secure password.

You can change it by editing the following file:

  nano /opt/apache-activemq/conf/jetty-realm.properties Chapter19659009 ?? Change the following lines with your preferred password: 

  # username : password [,rolename ...]
admin: activemqpassword, admin
user: userpassword, user

Save and close the file when you are done. Then restart the ActiveMQ service to apply the changes:

  systemctl restart apache-activemq 

When you are finished, you can proceed to the next step.

Configure Nginx as a reverse proxy for Apache ActiveMQ

Then it is recommended to configure Nginx as a reverse proxy for ActiveMQ. Ads

First install Nginx web server with the following command:

  dnf install nginx-y 

Once Nginx is installed, create a new Nginx virtual host configuration file with the following command:

  nano / etc / nginx /conf.d/activemq.confebrit19659009??Add the following lines: 

  server {
listen 80;
server-name your-server-ip;
location / {
proxy_pass http://127.0.0.1:8161;
proxy_http_version 1.1;
proxy_set_header Upgrade $ http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $ host;
proxy_cache_bypass $ http_upgrade;
}
}

Save and close the file when you are done. Then check Nginx for syntax errors with the following command:

  nginx -t 

You should see the following output:

  nginx: configuration file /etc/nginx/nginx.conf syntax is ok
nginx: The /etc/nginx/nginx.conf test configuration file is successful

Finally, start the Nginx service and enable it to start after system startup with the following command:

  systemctl start nginx 
systemctl enable nginx

You can also verify Nginx status with the following command: [19659008] systemctl status nginx

You should see the following output:

? nginx.service - Nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor setting: disabled)
Active: active (running) since Thu 2020-03-26 10:27:45 PM EDT; 1min 9s ago
Process: 9984 ExecStart = / usr / sbin / nginx (code = terminated, status = 0 / SUCCESS)
Process: 9982 ExecStartPre = / usr / sbin / nginx-t (code = terminated, status = 0 / SUCCESS)
Process: 9980 ExecStartPre = / usr / bin / rm -f /run/nginx.pid (code = terminated, status = 0 / SUCCESS)
Main PID: 9985 (nginx)
Details: 3 (limit: 25028)
Memory: 5.5M
CGroup: /system.slice/nginx.service
?? 9985 nginx: master process / usr / sbin / nginx
?? 9986 nginx: worker process
?? 9987 nginx: worker process

26 Mar 10:27:44 centos8 systemd [1]: Start nginx HTTP and reverse proxy server ...

Configuring SELinux and Firewall

By default, SELinux is enabled in CentOS 8. It is recommended to disable SELinux to work properly Apache ActiveMQ.

You can disable SELinux by editing / etc / selinux / config file: Ads

  nano / etc / selinux / config 

Find the following line:

  SELINUX = maintain

And replace it with the following line:

   SELINUX = permissive 

Save and close the file. Then restart the system to apply the changes:

Then you must allow ports 80 and 8161 through firewall. You can allow them with the following command:

  firewall-cmd - zone = public --permanent --add-port = 8161 / tcp 
firewall-cmd --zone = public --permanent --add-port = 80 / tcp

Then load the firewall to apply the changes:

  firewall-cmd - load 

When you are finished, you can proceed to the next step.

Access Apache ActiveMQ [19659007] At this point Apache ActiveMQ is installed and configured.

Now open your browser and type the URL http: // your-server-ip . You should see the following page:

 ActiveMQ

You can also access the Apache ActiveMQ admins interface by visiting URL http: // your-server-ip / admin . You will be redirected to the following page:

 Login Provide your admin username, password and click on the Login button. You should see the Apache ActiveMQ Admin interface on the following page:

 ActiveMQ Dashboard

Monitor ActiveMQ With Hawt.io

You can also monitor your Apache ActiveMQ with Hawt.io. Hawt.io is a modular web console for managing your Java-based application. It is a plug-in management console that supports all types of JVM, all types of containers including Tomcat, Jetty, Karaf, JBoss and many more.

Download the latest version of the Hawt.io war file with the following command:

  wget https://repo1.maven.org/maven2/io/hawt/hawtio-default/2.9.1/hawtio-default-2.9 .1.warebrit19659009 ?? Next, extract the downloaded file with the following command: 

  unzip hawtio-default-2.9.1.war -d hawtio 

Then move the extracted directory to the web app directory with the following command: [19659007] etc. hawtio / opt / apache-activemq / webapps / [19659009] Then you change the ownership of the webapps directory to activemq with the following command:

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

Then edit the Apache ActiveMQ environment file and make some changes:

  nano / opt / apache-activemq / bin / env 

Find the following line:

  ACTIVEMQ_OPTS = "$ ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config. f ile = logging.properties -Djava.security.auth.login.config = $ ACTIVEMQ_CONF / login.config "

Replace it with the following line:

  ACTIVEMQ_OPTS = "$ ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file = logging.properties -Djava.security.auth.login.config = $ ACTIVEMQ_CONF / login.config .config Dhawtio.realm = activemq -Dhawtio.role = admins -Dhawtio.rolePrincipalClasses = org.apache.activemq.jaas.GroupPrincipal "

Save and close the file when you are done. Then open the bridge.xml file: Ads

Ads

  nano / opt / apache-activemq / conf / jetty.xml 

Add the following line below the line :

  




Save and close the file when you are done, then restart the Apache ActiveMQ service to apply the changes:

  systemctl restart apache-activemq 

When you are finished, you can proceed to the next step.

Access Hawt.io Web Interface

Hawt.io is now installed and configured. It's time to access its web interface.

Open your browser and enter the URL http: // your-server-ip / hawtio . You will be redirected to the login page Hawt.io:

 Hawt.io Login

Enter the default username and password as admin / admin and click on Log in -button. You should see the Hawt.io dashboard on the following page:

 Hawt.io Dashboard

Conclusion

Congratulations! you have installed Apache ActiveMQ on CentOS 8. For more information, visit the Apache ActiveMQ documentation on ActiveMQ.


Source link