安装jdk并配置环境。
下载解压(略)
[root@server ~]#vi /etc/profile;JAVA_HOME=/usr/java/jdk_1.7.0_80 JRE_HOME=/usr/java/jdk_1.7.0_80/jre CLASS_PATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH export JAVA_HOME JRE_HOME CLASS_PATH PATH :wq [root@server ~]#java -version
2.安装activemq
[root@server ~]#adduser amq [root@server ~]#su - amq [amq@server ~]$tar -zxvf apache-activemq-5.11.2-bin.tar.gz [amq@server ~]$mv apache-activemq-5.11.2-bin.tar.gz activemq [amq@server ~]$cd /home/amq/aticvemq/bin/ [amq@server ~]$chmod 755 ./activemq
3.配置activemq
查看或修改两个服务端口,消息通迅端口(default 61616)和管理控制台端口(default 8186)
[amq@server ~]$cd /home/amq/activemq/ [amq@server activemq]$vi 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="0.0.0.0"/> <property name="port" value="8161"/> </bean> [amq@server activemq]$vi conf/activemq.xml <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
开启防火墙端口
[amq@server activemq]$su - root [root@server ~]#vi /etc/sysconfig/iptables /*追加两行*/ -A INPUT -m state --state NEW -m tcp -p tcp --dport 61616 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8161 -j ACCEPT :wq [root@server ~]#service iptables restart [root@server ~]#service iptables status
启动activemq
[root@server ~]#su - amq [amq@server ~]$cd /home/amq/activemq/bin [amq@server bin]$./activemq start
打开管理界面
默认用户名/密码:admin/admin
安全验证配置
(1)添加MQ使用者,在代码中将用到。
[amq@server ~]$cd /home/amq/activemq/ [amq@server activemq]$vi conf/activemq.xml /*在broker标签内最后加入*/ <plugins> <simpleAuthenticationPlugin> <users> <authenticationUser username="amq" password="123456" groups="users,admins"/> </users> </simpleAuthenticationPlugin> </plugins> :wq [amq@server activemq]$vi conf/jetty.xml /*确保authenticate的值为true*/ <bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint"> <property name="name" value="BASIC" /> <property name="roles" value="user,admin" /> <!-- set authenticate=false to disable login --> <property name="authenticate" value="true" /> </bean> :q!
(2)修改控制台用户名和密码
[amq@server activemq]$vi conf/jetty-realm.properties admin:123321,admin /**格式:用户:密码,角色**/ [amq@server activemq]$cd bin [amq@server bin]$./activemq restart
设置开机启动
[amq@server bin]$su - root [root@server ~]#vi /etc/rc.local su - amq -c ‘/home/amq/activemq/bin/activemq start‘
本文出自 “开心程序” 博客,请务必保留此出处http://jamesoak.blog.51cto.com/4365697/1867712
原文:http://jamesoak.blog.51cto.com/4365697/1867712