1、环境
ActiveMQ是一个纯Java程序,这里安装5.18.2版ActiveMQ,该版MQ运行在JDK 11+环境内,为此需要先搭建JDK 11+环境,这里安装JDK 15。
1.1、卸载
卸载开源JDK软件包,如下所示:
[root@localhost ~]# rpm -qa | grep openjdk
java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64
java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
[root@localhost ~]#
1.2、上传
借助MobaXterm等工具将JDK压缩文件上传至/opt目录,这里上传jdk-15.0.1_linux-x64_bin.tar.gz压缩文件;
1.3、解压
将JDK压缩文件解压至/usr/local目录:tar -zxvf /opt/jdk-15.0.1_linux-x64_bin.tar.gz -C /usr/local
1.4、删除
删除压缩文件:rm -f /opt/jdk-15.0.1_linux-x64_bin.tar.gz
1.5、环境变量
# cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk-15.0.1
export PATH=$JAVA_HOME/bin:$PATH
EOF
# cat /etc/profile
# source /etc/profile
# java -version
2、安装
2.1、下载
下载地址:http://activemq.apache.org/components/classic/download/,这里下载apache-activemq-5.18.2-bin.tar.gz
2.2、上传
将软件包apache-activemq-5.18.2-bin.tar.gz上传至Linux系统/opt目录
2.3、解压
将软件包解压至/usr/local目录:tar -zxvf /opt/apache-activemq-5.18.2-bin.tar.gz -C /usr/local/
2.4、删除
删除压缩文件:rm -f /opt/apache-activemq-5.18.2-bin.tar.gz
2.5、重命名
将解压后apache-activemq-5.18.2文件名改为activemq:mv /usr/local/apache-activemq-5.18.2 /usr/local/activemq
2.6、环境变量
ActiveMQ可执行文件位于 bin 目录下,为了便于操作ActiveMQ,这里将其路径添加至 PATH 环境变量中:
# cat >> /etc/profile << EOF
export PATH=/usr/local/activemq/bin:$PATH
EOF
# cat /etc/profile
# source /etc/profile
3、配置
3.1、jetty.xml
i、vi /usr/local/activemq/conf/jetty.xml,如下所示:
<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start"><!-- the default port number for the web console --><property name="host" value="127.0.0.1"/><property name="port" value="8161"/>
</bean>
ii、将上面127.0.0.1改成0.0.0.0以支持外网访问;
iii、保存jetty.xml文件;
3.2、防火墙
# firewall-cmd --zone=public --add-port=8161/tcp --permanent
# firewall-cmd --reload
说明:ActiveMQ默认端口为8161
4、操作
启动:activemq start
[root@localhost ~]# activemq start
INFO: Loading '/usr/local/activemq//bin/env'
INFO: Using java '/usr/local/jdk-15.0.1/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j2.properties to get details
INFO: pidfile created : '/usr/local/activemq//data/activemq.pid' (pid '80671')
[root@localhost ~]#
状态:activemq status
[root@localhost ~]# activemq status
INFO: Loading '/usr/local/activemq//bin/env'
INFO: Using java '/usr/local/jdk-15.0.1/bin/java'
ActiveMQ is running (pid '80671')
[root@localhost ~]#
日志:activemq console
停止:activemq stop
5、访问
启动浏览器—>访问http://192.168.1.130:8161—>输入用户名和密码:admin/admin,参见/usr/local/activemq/conf/users.properties文件,如下所示: