解压
1、解压安装包 至 /usr/
$ sudo tar -zxvf apache-activemq-xx.tar.gz -C /usr/
2、修改解压后目录名称
$ sudo mv /usr/apache-activemq/ /usr/activemq
3、添加 JAVA_HOME 路径
$ cd /usr/activemq/bin
$ echo "$JAVA_HOME"
$ sudo vim /usr/activemq/bin/activemq
JAVA_HOME="/usr/java/jdk1.6"
4、启动服务
$ ./activemq start # 启动服务
$ ./activemq stop # 关闭服务
$ ./activemq status # 查看状态
$ ./activemq console # 查看终端报错
5、登录
IP:8161/admin
6、设置开机自启
6.1、创建 systemd 服务文件
$ sudo vim /usr/lib/systemd/system/activemq.service
[Unit]
Description=ActiveMQ service
After=network.target
[Service]
Type=simple
ExecStart=/bin/sh /usr/activemq/bin/activemq start
ExecStop=/bin/sh /usr/activemq/bin/activemq stop
[Install]
WantedBy=multi-user.target
6.2重新加载下服务文件
$ sudo systemctl daemon-reload
6.3、开机自启
# 启动服务
$ sudo systemctl start activemq
# 查看服务状态
$ sduo systemctl status activemq
# 开机自启服务
$ sudo systemctl enable activemq
# 关闭服务
$ sudo systemctl stop activemq
# 检测是否开机自启成功
$ sudo systemctl list-unit-files | grep activemq
7、防火墙
#允许端口通过防火墙–permanent永久生效,没有此参数重启后失效
firewall-cmd --add-port=8161/tcp --permanent
firewall-cmd --add-port=61616/tcp --permanent
firewall-cmd --reload
#查看端口是否设置成功
$sudo firewall-cmd --list-ports
设置开机启动二:
切换到
vim /usr/local/apache-activemq-5.15.0/conf/activemq.xml
修改activemq.xml:
在broker标签内部添加配置如下:
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="test" password="user@test" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
添加软链接
ln -s /usr/local/apache-activemq-5.15.0/bin/activemq /usr/bin
cd /etc/init.d/
touch activemq
vim activemq
#!/bin/sh
#
# /etc/init.d/activemq
# chkconfig: 345 63 37
# description: activemq servlet container.
# processname: activemq 5.15.0
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
#java的安装路径
export JAVA_HOME=/usr/local/jdk1.8.0_181/
#activemq的安装路径
export CATALINA_HOME=/usr/local/apache-activemq-5.15.0/
case $1 in
start)
sh $CATALINA_HOME/bin/activemq start
;;
stop)
sh $CATALINA_HOME/bin/activemq stop
;;
restart)
sh $CATALINA_HOME/bin/activemq stop
sleep 1
sh $CATALINA_HOME/bin/activemq start
;;
esac
exit 0
#给activemq可执行权限
chmod +x activemq
#设置开机启动
chkconfig activemq on
#查看开机启动服务列表
chkconfig –list
#关闭开机启动
chkconfig activemq off
#设置管理员账号
vim /usr/local/apache-activemq-5.15.0/conf/jetty-realm.properties
#在user下添加用户名密码信息。如
test:test1,admin
格式为 用户名:密码,权限。
网友评论