登录root用户操作
[administrator@localhost ~]$ su root
密码:
[root@localhost administrator]#
进入/etc/init.d目录
[root@localhost administrator]# cd /etc/init.d
创建activemq脚本文件
[root@localhost init.d]# touch activemq
编辑activemq文件
[root@localhost init.d]# vi activemq
将下段脚本复制到activemq文件中,注意修改JAVA_HOME和CATALINA_HOME的路径为自己的
#!/bin/sh
#
# /etc/init.d/activemq
# chkconfig: 345 63 37
# description: activemq servlet container.
# processname: activemq 5.14.1
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
export JAVA_HOME=/home/java/jdk1.8.0_11
export CATALINA_HOME=/opt/myactiveMQ/apache-activemq-5.15.10
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
给脚本授权
[root@localhost init.d]# chmod +x activemq
添加到开机启动项
[root@localhost init.d]# chkconfig --add activemq
查看是否添加成功
[root@localhost init.d]# chkconfig --list
如下则表示已经添加成功
[root@localhost init.d]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
activemq 0:关 1:关 2:关 3:开 4:开 5:开 6:关
[root@localhost init.d]#
重启系统
[root@localhost init.d]# reboot
访问服务(http://localhost:8161/admin/)
访问成功,操作生效。
(完结)