ActiveMQ环境搭建

Posted 思想累积

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActiveMQ环境搭建相关的知识,希望对你有一定的参考价值。

1、Linux 下 ActiveMQ 安装

ActiveMQ 官网:https://activemq.apache.org/

ActiveMQ 下载地址:https://activemq.apache.org/components/classic/download/

官网下载后上传到 /home/ 目录下

# 我下载的是 apache-activemq-5.16.2-bin.tar.gz
tar -zxvf apache-activemq-5.16.2-bin.tar.gz
# 移动到新建的文件夹 ActiveMQ 内
mv apache-activemq-5.16.2/ /home/ActiveMQ

下面是解压后的文件

[root@VM-0-4-centos ActiveMQ]# ll
total 18264
-rwxr-xr-x 1 root root 18618328 Apr 21 14:56 activemq-all-5.16.2.jar
drwxr-xr-x 5 root root     4096 May 30 22:52 bin
drwxr-xr-x 2 root root     4096 May 30 22:52 conf
drwxr-xr-x 2 root root     4096 May 30 22:52 data
drwxr-xr-x 2 root root     4096 May 30 22:52 docs
drwxr-xr-x 7 root root     4096 Apr 21 15:08 examples
drwxr-xr-x 6 root root     4096 May 30 22:52 lib
-rw-r--r-- 1 root root    40580 Apr 21 15:08 LICENSE
-rw-r--r-- 1 root root     3334 Apr 21 15:08 NOTICE
-rw-r--r-- 1 root root     2610 Apr 21 15:08 README.txt
drwxr-xr-x 6 root root     4096 May 30 22:52 webapps
drwxr-xr-x 3 root root     4096 May 30 22:52 webapps-demo
[root@VM-0-4-centos ActiveMQ]# 

普通启动 ActiveMQ

进入 bin 目录下启动 ActiveMQ

[root@VM-0-4-centos ActiveMQ]# cd /home/ActiveMQ/bin
[root@VM-0-4-centos bin]# ./activemq start
INFO: Loading '/home/ActiveMQ//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/home/ActiveMQ//data/activemq.pid' (pid '2833787')

以带运行日志方式启动

[root@VM-0-4-centos bin]# pwd
/home/ActiveMQ/bin
[root@VM-0-4-centos bin]# ./activemq start > /home/ActiveMQ/runmq.log
[root@VM-0-4-centos bin]# 

指定配置文件启动 ActiveMQ

./activemq start xbin:file:/home/ActiveMQ/conf/newactivemq.xml

查看 ActiveMQ 进程

[root@VM-0-4-centos bin]# ps -ef | grep activemq | grep -v grep
root     2833787       1  5 23:06 pts/2    00:00:12 /usr/bin/java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/home/ActiveMQ//conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/home/ActiveMQ//tmp -Dactivemq.classpath=/home/ActiveMQ//conf:/home/ActiveMQ//../lib/: -Dactivemq.home=/home/ActiveMQ/ -Dactivemq.base=/home/ActiveMQ/ -Dactivemq.conf=/home/ActiveMQ//conf -Dactivemq.data=/home/ActiveMQ//data -jar /home/ActiveMQ//bin/activemq.jar start

ActiveMQ 默认端口为 61616

[root@VM-0-4-centos bin]# netstat -anp | grep 61616
tcp6       0      0 :::61616                :::*                    LISTEN      2833787/java        
[root@VM-0-4-centos bin]# lsof -i:61616
COMMAND     PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    2833787 root  138u  IPv6 18285061      0t0  TCP *:61616 (LISTEN)

关闭 ActiveMQ

[root@VM-0-4-centos bin]# ./activemq stop
INFO: Loading '/home/ActiveMQ//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Waiting at least 30 seconds for regular process termination of pid '2833787' : 
Java Runtime: Oracle Corporation 1.8.0_121 /usr/java/jdk1.8.0_121/jre
  Heap sizes: current=63360k  free=62653k  max=1013632k
    JVM args: -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/home/ActiveMQ//conf/login.config -Dactivemq.classpath=/home/ActiveMQ//conf:/home/ActiveMQ//../lib/: -Dactivemq.home=/home/ActiveMQ/ -Dactivemq.base=/home/ActiveMQ/ -Dactivemq.conf=/home/ActiveMQ//conf -Dactivemq.data=/home/ActiveMQ//data
Extensions classpath:
  [/home/ActiveMQ/lib,/home/ActiveMQ/lib/camel,/home/ActiveMQ/lib/optional,/home/ActiveMQ/lib/web,/home/ActiveMQ/lib/extra]
ACTIVEMQ_HOME: /home/ActiveMQ
ACTIVEMQ_BASE: /home/ActiveMQ
ACTIVEMQ_CONF: /home/ActiveMQ/conf
ACTIVEMQ_DATA: /home/ActiveMQ/data
Connecting to pid: 2833787
.Stopping broker: localhost
. FINISHED

ActiveMQ 控制台

ActiveMQ 使用 61616 端口提供 JMS 服务,使用 8161端口提供管理控制台服务

访问地址:http://IP:8161/admin/

默认用户名和密码:admin/admin

以上是关于ActiveMQ环境搭建的主要内容,如果未能解决你的问题,请参考以下文章

linux环境下搭建ActiveMQ集群

Apache ActiveMQ Fileserver远程代码执行漏洞

搭建activemq环境

ActiveMq系列教程 - 简介与环境搭建

Zookeeper+ActiveMQ集群搭建

Windows 下搭建ActiveMQ环境 #yyds干货盘点#