在Linux Ubuntu 18.04.x上安装和配置ActiveMQ-Artemis

目录

假设/期望

Linux命令和Vim

“root”用户

背景

面向消息的中间件(MoM)

为什么要使用MoM?

Apache ActiveMQ Artemis

Artemis支持的消息协议

系统信息

JAVA(openjdk-11)安装

安装后配置:设置JAVA_HOME环境变量

确定JDK安装目录的绝对路径

在/etc/bash.bashrc中设置JAVA_HOME

2. ActiveMQ-Artemis安装/配置

从Apache.org下载Artemis

提取下载的捆绑包

创建一个新的Linux用户组`activemq`

创建一个新的Linux用户`activemq`

更改目录“/opt/apache-artemis-2.12.0”的所有权

导航到“bin”目录

创建代理

启动代理实例

测试运行#1:手动启动代理进行测试运行

测试运行2:启动代理作为守护程序进程

为代理创建系统服务

创建系统服务脚本

关于创建其他代理的说明


本文是企业数据总线系统研究的一部分。这项特殊的研究将ActiveMQ-Artemis(此后称为Artemis)选为集中式消息中心,供系统中所有进程使用Artemis支持的协议之一相互通信。在本文中,我将讨论在ARM64计算机上运行的Linux Ubuntu 18.04.x OS上安装/配置Artemis的过程。

假设/期望

Linux命令和Vim

我假设本文的读者对Linux shell和命令有一定的了解,并且对所用Linux命令的解释不在本文的讨论范围之内。除非另有说明,否则Linux命令将在终端中运行。

我正在使用vim编辑器进行文本编辑,但是读者可以使用他们想要的任何其他文本编辑器。

“root”用户

本文中的所有命令均由root用户发出。

背景

面向消息的中间件(MoM

面向消息的中间件(MoM)是在分布式系统之间支持,发送和接收消息的软件或硬件基础结构。

为什么要使用MoM

MoM允许将应用程序模块分布在异构平台上,并降低了开发跨越多个操作系统\网络协议和编程语言的应用程序的复杂性。MoM通过提供可靠性、事务处理和许多其他功能,使系统中的进程能够通过定义明确的协议之一进行通信。

Apache ActiveMQ Artemis

Apache ActiveMQ ArtemisArtemis)是异步消息传递系统,并且是MoM系统的软件实现。Artemis能够通过正在运行的代理实例协调分布式系统中进程之间的消息传递流量。

Artemis支持的消息协议

Artemis支持以下协议:

  • MPQOpenWire
  • MQTT
  • STOMP
  • HornetQ(用于HornetQ客户端)
  • CoreArtemis CORE协议)

例如,在三层系统中,可能有一些用JavaC / C ++Python编写的进程。GoLangnodejs等在前端,中间层和后端分布式运行。这些进程可以通过将其自身注册到命名队列或主题以发送/接收消息来相互通信(例如,使用STOMP协议)。

系统信息

  • 硬件Odroid N2ARM 64
  • 操作系统Ubuntu 18.04.4 LTSBionic Beaver

JAVAopenjdk-11)安装

Artemis需要JRE(至少具有版本8)才能运行。以下是openjdk-11安装/配置的过程。

安装:

sudo apt install openjdk-11-jdk

校验:

which java

/usr/bin/java

java --version

openjdk 11.0.7 2020-04-14

OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)

OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode)

安装后配置:设置JAVA_HOME环境变量

Artemis要求JAVA_HOME设置环境。以下是在/etc/bash.bashrc进行设置并激活它的步骤。

确定JDK安装目录的绝对路径

Ubuntu中,jdks安装在/usr/lib/jvmjdk构建中的二进制文件是特定于平台的;因此,该JAVA_HOME变量必须指向特定于平台的已安装JDK(在这种情况下,该平台为ARM64)。

这是/usr/lib/jvm应有的样子:

pwd
/usr/lib/jvm

ls
java-1.11.0-openjdk-arm64 java-11-openjdk-arm64  openjdk-11

java-1.11.0-openjdk-arm64 java-11-openjdk-arm64  openjdk-11

因此,JAVA_HOME应将环境变量设置为/usr/lib/jvm

/etc/bash.bashrc中设置JAVA_HOME

编辑文件/etc/bash.bashrc

vim /etc/bash.bashrc

添加以下行(在此文件的底部):

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64

源脚本:

source /etc/bash.bashrc

验证变量的值:

echo $JAVA_HOME

/usr/lib/jvm/java-11-openjdk-arm64

2. ActiveMQ-Artemis安装/配置

Apache.org下载Artemis

打开Web浏览器并指向以下URL

http://activemq.apache.org/components/artemis/download/

源包和二进制包的URL

http://activemq.apache.org/components/artemis/download/

1ActiveMQ Artemis下载页面

注意事项

  • 我在本教程中使用了tar包(此示例中的文件位于/media/SDA1)。
  • ActiveMQ服务器及其代理将安装在/opt ”目录中。
  • 我将使用的经纪人名称为`ActiveMQ-Odroid-110`

提取下载的捆绑包

pwd
/opt

tar -xzf /media/SDA1/apache-artemis-2.12.0-bin.tar.gz

校验:

ls

(among other things…) apache-artemis-2.12.0

创建一个新的Linux用户组`activemq`

addgroup --quiet --system activemq

创建一个新的Linux用户`activemq`

adduser --quiet --system --ingroup activemq \
--no-create-home --disabled-password activemq

更改目录“/opt/apache-artemis-2.12.0”的所有权

chown -R activemq:activemq /opt/activemq

导航到“bin”目录

cd apache-artemis-2.12.0/bin

校验:

./artemis

如果看到以下输出,则表明已准备好安装代理:

usage: artemis <command> [<args>]

The most commonly used artemis commands are:

    address     Address tools group (create|delete|update|show) 
                (example ./artemis address create)
    browser     It will browse messages on an instance
    consumer    It will consume messages from an instance
    create      creates a new broker instance
    data        data tools group (print) (example ./artemis data print)
    help        Display help information
    mask        mask a password and print it out
    migrate1x   Migrates the configuration of a 1.x Artemis Broker
    producer    It will send messages to an instance
    queue       Queue tools group (create|delete|update|stat|purge) 
                (example ./artemis queue create)

See 'artemis help <command>' for more information on a specific command.

创建代理

在此示例中,代理将具有以下属性:

  • 名称ActiveMQ-Odroid-110
  • 管理员UIDadmin
  • 管理员密码admin
./artemis create ActiveMQ-Odroid-110 --user=admin --password=admin \
--http-host 0.0.0.0 --relax-jolokia

...安装将出现一个额外的提示(只需键入Y,然后按Enter):

--allow-anonymous | --require-login: is a mandatory property!
Allow anonymous access?, valid values are Y,N,True,False

Y      <--- Enter

其余输出:

Auto tuning journal ...
done! Your system can make 1.61 writes per millisecond, 
your journal-buffer-timeout will be 620000

You can now start the broker by executing:
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis" run
Or you can run the broker in the background using:
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" start
   
   "/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service"
Usage: ./artemis-service {start|stop|restart|force-stop|status}

启动代理实例

现在,我们准备运行代理:

测试运行#1:手动启动代理进行测试运行

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis" run

现在,打开Web浏览器并将其指向以下网站:

http://<IP of the broker>:8161

如果您看到以下网页,则代理实例已启动并成功运行:

2ActiveMQ初始网页

单击管理控制台链接以打开登录页面(注意:先前在创建代理程序时指定的用户名= admin,密码= admin)。

3ActiveMQ登录页面

ActiveMQ管理控制台初始页:

4ActiveMQ管理控制台初始页面

恭喜,您已经成功安装了第一个ActiveMQ代理!

测试运行2:启动代理作为守护程序进程

要将代理作为后台服务运行,请首先杀死代理的当前实例(即,运行代理的控制台上的Ctrl + C),然后运行以下命令:

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" start

输出:

Starting artemis-service
artemis-service is now running (14289)

校验:

ps -ef| grep 14289

输出:

root     14289     1 10 18:18 pts/0    00:00:23 /usr/lib/jvm/java-11-openjdk-arm64/bin/java
-XX:+PrintClassHistogram -XX:+UseG1GC -XX:+UseStringDeduplication -Xms512M -Xmx2G
-Dhawtio.realm=activemq -Dhawtio.offline=true -Dhawtio.role=amq
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
-Djolokia.policyLocation=file:/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc/jolokia-
access.xml -Xbootclasspath/a:/opt/apache-artemis-2.12.0/lib/jboss-logmanager-2.1.10.Final.jar:
/opt/apache-artemis-2.12.0/lib/wildfly-common-1.5.2.Final.jar 
-Djava.security.auth.login.config=/opt
/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc/login.config 
-classpath /opt/apache-artemis-2.12.0
/lib/artemis-boot.jar -Dartemis.home=/opt/apache-artemis-2.12.0 -Dartemis.instance=/opt/apache-
artemis-2.12.0/bin/ActiveMQ-Odroid-110 
-Djava.library.path=/opt/apache-artemis-2.12.0/bin/lib/linux-
aarch64 -Djava.io.tmpdir=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/tmp -Ddata.dir=/opt
/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/data -Dartemis.instance.etc=/opt/apache-artemis-
2.12.0/bin/ActiveMQ-Odroid-110/etc -Djava.util.logging.manager=org.jboss.logmanager.LogManager
-Dlogging.configuration=file:/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/etc
//logging.properties org.apache.activemq.artemis.boot.Artemis run

再次注销/登录到Web控制台,以确保一切仍然正常。

现在,停止守护进程:

"/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service" stop

至此,我们准备为代理实例创建一个新的systemd服务。

为代理创建系统服务

至此,我们已经在地面和守护程序处理模式下测试了代理。但是,在这些模式下,该过程将无法在系统重新启动后继续存在。为了防止每次系统重新启动时手动重新启动代理进程,我们需要创建一个系统服务,并让Linux操作系统自动处理所有启动/停止操作。

创建系统服务脚本

touch /etc/systemd/system/activemq-artemis.service

chmod 644 /etc/systemd/system/activemq-artemis.service

vim /etc/systemd/system/activemq-artemis.service

将以下行添加到文件中:

[Unit]

Description=Apache ActiveMQ Artemis
After=network.target

[Service]

Type=forking
User=activemq
Group=activemq

ExecStart=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service start
ExecStop=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service stop

[Install]
WantedBy=multi-user.target

加载/启动服务:

systemctl daemon-reload

systemctl start activemq-artemis

启用服务(以便它可以在系统重新启动后幸存):

systemctl enable activemq-artemis

输出:

Created symlink /etc/systemd/system/multi-user.target.wants/ 
activemq-artemis.service → /etc/systemd
/system/activemq-artemis.

通过系统服务进行验证:

systemctl status activemq-artemis

输出应类似于以下内容:

Loaded: loaded (/etc/systemd/system/activemq-artemis.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2020-05-02 16:17:52 UTC; 34s ago

  Process: 2894 
  ExecStart=/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service start 
  (code=exited, sta

 Main PID: 2919 (java)

    Tasks: 50 (limit: 3838)

   CGroup: /system.slice/activemq-odroid-110.service

           └─2919 java -XX:+PrintClassHistogram -XX:+UseG1GC 
             -XX:+UseStringDeduplication -Xms512M -Xmx2G -Dhawtio.realm=


May 02 16:17:30 odroid systemd[1]: Starting Apache ActiveMQ Artemis...

May 02 16:17:30 odroid artemis-service[2894]: Starting artemis-service

May 02 16:17:52 odroid artemis-service[2894]: artemis-service is now running (2919)

May 02 16:17:52 odroid systemd[1]: Started Apache ActiveMQ Artemis.

(可选)使用代理的状态报告进行验证:

/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service status

输出应类似于以下内容:

artemis-service is running (16934)

测试系统停止服务:

systemctl stop activemq-odroid-110

通过系统服务进行验证:

systemctl status activemq-odroid-110

过去的几行输出应该类似于如下:

May 02 16:35:13 odroid artemis-service[4031]: Gracefully Stopping artemis-service

May 02 16:35:14 odroid systemd[1]: activemq-odroid-110.service: 
                Main process exited, code=exited, status=143/n/a

May 02 16:35:14 odroid systemd[1]: activemq-odroid-110.service: 
                Failed with result 'exit-code'.

May 02 16:35:14 odroid systemd[1]: Stopped Apache ActiveMQ Artemis.

验证与代理的状态报告:

/opt/apache-artemis-2.12.0/bin/ActiveMQ-Odroid-110/bin/artemis-service status

输出应类似于以下内容:

artemis-service is stopped

关于创建其他代理的说明

Artemis支持在同一主机上同时运行的多个代理,因此可以按照本教程中的过程创建所需的其他代理。

到此结束在Linux Ubuntu / ARM64系统上安装Apache-Artemis的过程。

以下是在Ubuntu 18.04.04上安装配置Realsense D435i的步骤: 1. 下载和安装Realsense SDK: ``` sudo apt-get update && sudo apt-get upgrade sudo apt-get install libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev mkdir -p ~/realsense_ws/src cd ~/realsense_ws/src git clone https://github.com/IntelRealSense/realsense-ros.git cd realsense-ros/ git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1` cd ~/realsense_ws/ catkin_make clean catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release ``` 2. 安装ibrealsense2: ``` sudo apt-get install librealsense2-dkms sudo apt-get install librealsense2-utils sudo apt-get install librealsense2-dev sudo apt-get install librealsense2-dbg ``` 3. 配置udev规则: ``` sudo cp ~/realsense_ws/src/realsense-ros/realsense2_camera/99-realsense-libusb.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && udevadm trigger sudo modprobe uvcvideo ``` 4. 启动camera: ``` source ~/realsense_ws/devel/setup.bash roslaunch realsense2_camera rs_camera.launch ``` 如果需要启用D435i的IMU功能,可以添加以下参数: ``` source ~/realsense_ws/devel/setup.bash roslaunch realsense2_camera rs_camera.launch enable_imu:=true ``` 5. 查看camera输入: ``` rostopic list rostopic echo /camera/color/image_raw rostopic echo /camera/depth/image_raw rostopic echo /camera/infra1/image_raw rostopic echo /camera/infra2/image_raw rostopic echo /camera/imu ``` 6. 使用rviz查看camera输入: ``` rosrun rviz rviz ``` 在rviz中添加以下内容: - Fixed Frame: camera_link - Add -> By Topic -> /camera/color/image_raw - Add -> By Topic -> /camera/depth/image_raw - Add -> By Topic -> /camera/infra1/image_raw - Add -> By Topic -> /camera/infra2/image_raw - Add -> By Topic -> /camera/imu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值