如何在Debian 10上安装Apache ActiveMQ

如何在Debian 10上安装Apache ActiveMQ

Apache ActiveMQ是由Apache开发的用Java编写的开源消息代理。它是最受欢迎的消息代理之一。它具有强大的功能和灵活性,支持多协议和基于Java的消息传递服务器。来自主要编程语言(例如C,C ++,Python,.Net等)的连接。

Apache ActiveMQ允许您使用无处不在的AMPQ协议集成多平台应用程序。使用WebSocket上的STOMP在Web应用程序之间进行交易所,使用MQTT管理IoT设备,并支持JMS基础结构及其他。

在本教程中,我们将向您展示如何在最新的Debian Buster 10上安装Apache ActiveMQ。我们将使用官方二进制文件安装ActiveMQ,将ActiveMQ设置为systemd服务,并启用密码验证。

先决条件

对于本指南,我们将使用具有2GB RAM,50GB可用磁盘空间和2个CPU的最新Debian Buster 10。

我们要做什么?

  • 在Debian 10上安装Java
  • 下载并安装Apache ActiveMQ
  • 将Apache ActiveMQ设置为系统服务
  • 设置Web控制台的加密货币密码
  • 测试中

第1步-在Debian 10上安装Java

首先,我们将Java OpenJDK和JRE安装到Debian Buster10。默认情况下,这两个软件包在Debian存储库中都可用。

更新Debian系统上的所有可用存储库,并使用下面的apt命令安装Java OpenJDK和JRE。

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

一旦所有安装完成,请使用以下命令检查Java版本。

java -version

以下是您将获得的答复。

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)

结果,Java OpenJDK和JRE’11’已安装在Debian服务器上。

第2步-下载并安装Apache ActiveMQ

在这一步中,我们将下载Apache ActiveMQ并将其安装到我们的Debian系统中。

在继续之前,让我们使用以下命令创建一个新的系统用户’activemq’。

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

现在下载Apache ActiveMQ Binary文件,并使用以下命令解压缩该文件。

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

之后,将Apache ActiveMQ目录移至“ / opt / activemq”,并将ActiveMQ目录的所有权更改为用户“ activemq”。

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

结果,Apache ActiveMQ被安装在Debian系统上。

下载Apace ActiveMQ

第3步-将Apache ActiveMQ设置为系统服务

下载并安装Apache ActiveMQ之后,我们将把ActiveMQ设置为系统服务。

现在转到“ / etc / systemd / system”目录,并使用vim编辑器创建一个新的服务文件“ activemq.service”。

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

将以下配置粘贴到其中。Advertisements.banner-1{text-align:center; padding-top:10pximportant; padding-bottom:10pximportant; padding-left:0pximportant; padding-right:0pximportant; width:100%important; box-sizing:border-boximportant; background -color:#eeeeeeimportant; border:1px solid #dfdfdf} Advertisements.banner-1 {text-align:center; padding-top:10pximportant; padding-bottom:10pximportant; padding-left:0pximportant; padding-right:0pximportant; width:100%important; box-sizing:border-boximportant; background -color:#eeeeeeimportant; border:1px实心#dfdfdf}

[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

保存并关闭。

接下来,重新加载systemd管理器以应用新的systemd服务配置。

systemctl daemon-reload

现在启动ActiveMQ服务器并将其添加到系统引导中。

systemctl start activemq
systemctl enable activemq

将Apache ActiveMQ设置为Systemd Services

结果,Apache ActiveMQ已启动并正在运行,请使用以下命令对其进行检查。

systemctl status activemq

以下是您将获得的结果。

Apache ActiveMQ已在Debian 10上启动并运行

第4步-设置Web控制台的加密货币密码

默认情况下,启用ActiveMQ Web控制台的身份验证,ActiveMQ的所有用户和密码均以纯文本形式存储在“ jetty-realm.properties”中。对于此步骤,我们将使用加密的密码更改默认的纯文本密码。

首先,下载码头分布并提取。

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

现在转到“ jetty-distribution- *”目录。

cd jetty-distribution-*/

运行以下命令来生成您的密码,并确保使用您自己的密码更改“ salt”和密码。

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

现在您将收到以下响应。

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

将“ CRYPT:myy …”加密的密码复制到您的笔记中,因为它将用于ActiveMQ。

现在转到ActiveMQ配置目录“ / opt / activemq / conf”,并使用vim编辑器编辑配置“ jetty-realm.properties”。

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

如下更改生成的加密货币密码“ CRYPT:myy …”的默认管理员密码。Advertisements.leader-1{text-align:center; padding-top:10pximportant; padding-bottom:10pximportant; padding-left:0pximportant; padding-right:0pximportant; width:100%important; box-sizing:border-boximportant; background -color:#eeeeeeimportant; border:1px实心#dfdfdf}

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

保存并关闭。

接下来,重新启动Apache ActiveMQ服务以应用新配置。

systemctl restart activemq

设置Web控制台的Apache ActiveMQ加密货币密码

结果,使用加密货币密码的ActiveMQ Web控制台的配置已完成。

步骤5-测试

现在,打开Web浏览器,并使用端口“ 8161”键入服务器IP地址。

http:// serverip:8161 /

然后,您将获得ActiveMQ Web控制台的默认index.html页面。

Apache ActiveMQ索引页面

接下来,如下所示在URL上添加“ / admin”路径。

http:// serverip:8161 / admin

并且将提示您进行ActiveMQ身份验证。

Apache ActiveMQ登录页面

键入默认用户“ admin”,并在顶部生成您的密码,然后单击“确定”登录。

密码正确后,您将获得如下所示的ActiveMQ仪表板。

Apache ActiveMQ仪表板

结果,在Debian Buster 10上Apache ActiveMQ的安装和配置已成功完成。

资讯来源:由0x资讯编译自HOWTOFORGE,版权归作者所有,未经许可,不得转载
你可能还喜欢