Linux下安装 activemq 并指定jdk 1.8

1. 下载安装包

<apache-activemq-5.15.4-bin.tar.gz>

下载地址:https://pan.baidu.com/s/18xzjBAchjWqsHNA1HuYvTg

2. 配置环境

已安装jdk 1.7 & jdk 1.8 

PS:下载jdk 1.8:

① 先查看name -a 查看linux 版本号【X86_64 为64位系统-兼容32位】

② oracle 官网下载指定版本【要点选accept,否则无法下载

③ 解压到指定目录,默认为<opt/jdk1.8>

解压命令:tar -zxvf jdk-8u131-linux-x64.tar.gz

④ 配置环境变量

 1 vim /etc/profile  #编辑配置文件
 2 
 3 # Sun JDK profile
 4 
 5     export JAVA_HOME=/usr/local/jdk1.8/jdk1.8.0_131
 6 
 7     export JRE_HOME=${JAVA_HOME}/jre
 8 
 9     export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
10 
11     export PATH=${JAVA_HOME}/bin:$PATH
12 
13 :wq  # 保存并退出 【或shift+ZZ】
14 
15 source /etc/profile  # 使/etc/profile文件生效
16 
17 java -version   # 查看java版本显示

3. 启动

 1 cd bin #进入bin目录
 2 
 3 # 前台启动,有启动日志(可以用于查看是否正常启动)
 4 ./activemq console
 5 
 6 # 后台启动,无启动日志
 7 ./activemq start
 8 
 9 # 关闭
10 ./activemq stop
11 
12 # 重启
13 ./activemq restart
14 
15 #查看进程
16 ps -ef | grep activemq
17 
18 # 杀死进程
19 kill 1234
20 
21 # 查看61616端口是否打开
22 netstat -anp | grep 8161
23 netstat -anp | grep 61616

4. ActiveMQ指定 jdk1.8 

① 修改配置文件

 1 #进入activemq bin目录
 2 cd /opt/apache-activemq-5.15.4/bin 
 3 
 4 #修改env,环境配置文件
 5 vim env
 6 
 7 #添加指定 jdk 1.8信息 
 8 #进行修改 insert
 9 i
10 #添加信息
11 JAVA_HOME="/opt/jdk1.8"
12
13 #保存并退出
14
:wq # 保存并退出 【或shift+ZZ】

② 重启MQ

./activemq restart

 5. 修改tomcat 配置,调用MQ

① 修改配置信息

 1 #进入tomcat路径下
 2 cd /opt/tomcat/webapps/ROOT/WEB-INF/
 3 
 4 #修改tomcat 配置文件
 5 vim server.properties
 6 
 7 #修改activemq配置,添加如下信息
 8 activemq.url=tcp://10.10.101.101:61616
 9 activemq.username=admin
10 activemq.password=admin

② 重启tomcat

1 #查看tomcat进程
2 ps -ef | grep tomcat 
3 
4 #杀掉进程
5 kill -9 1234
6 
7 #启动tomcat
8 ./opt/tomcat/bin start.sh ;tail -f ../logs/catalina.out

6. 其他配置或常见问题

① jetty.xml 配置

 1 #activemq配置文件路径
 2 vim /opt/apache-activemq-5.15.4/conf/jetty.xml
 3 
 4 # web管理访问的ip和端口
 5 # 可以改成本机的外部IP,不能改成127.0.0.1 ,否则外部无法访问
 6 
 7     <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
 8              <!-- the default port number for the web console -->
 9         <property name="host" value="0.0.0.0"/>
10         <property name="port" value="8161"/>
11     </bean>

② activemq.xml

 1 vim opt/apache-activemq-5.15.4/conf/activemq.xml
 2 
 3 # 使用到的ip和端口
 4         <transportConnectors>
 5             <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
 6             <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
 7             <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
 8             <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
 9             <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
10             <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
11         </transportConnectors>
12 #默认openwire 端口号为 61616

③ 常见问题

a. jdk版本不兼容【<apache-activemq-5.15.4>需要jdk 1.8版本】

问题描述:

启动时报错,

解决办法:由于机器安装的是jdk1.7 不兼容导致,安装jdk1.8 并指定到activemq,问题解决。

猜你喜欢

转载自www.cnblogs.com/SH-xuliang/p/9467101.html
今日推荐