- 安装jdk并配置环境。
下载解压(略)
[[email protected] ~]#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 [[email protected] ~]#java -version
2.安装activemq
[[email protected] ~]#adduser amq [[email protected] ~]#su - amq [[email protected] ~]$tar -zxvf apache-activemq-5.11.2-bin.tar.gz [[email protected] ~]$mv apache-activemq-5.11.2-bin.tar.gz activemq [[email protected] ~]$cd /home/amq/aticvemq/bin/ [[email protected] ~]$chmod 755 ./activemq
3.配置activemq
- 查看或修改两个服务端口,消息通迅端口(default 61616)和管理控制台端口(default 8186)
[[email protected] ~]$cd /home/amq/activemq/ [[email protected] 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> [[email protected] activemq]$vi conf/activemq.xml <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- 开启防火墙端口
[[email protected] activemq]$su - root [[email protected] ~]#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 [[email protected] ~]#service iptables restart [[email protected] ~]#service iptables status
- 启动activemq
[[email protected] ~]#su - amq [[email protected] ~]$cd /home/amq/activemq/bin [[email protected] bin]$./activemq start
- 打开管理界面
默认用户名/密码:admin/admin
- 安全验证配置
(1)添加MQ使用者,在代码中将用到。
[[email protected] ~]$cd /home/amq/activemq/ [[email protected] activemq]$vi conf/activemq.xml /*在broker标签内最后加入*/ <plugins> <simpleAuthenticationPlugin> <users> <authenticationUser username="amq" password="123456" groups="users,admins"/> </users> </simpleAuthenticationPlugin> </plugins> :wq [[email protected] 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)修改控制台用户名和密码
[[email protected] activemq]$vi conf/jetty-realm.properties admin:123321,admin /**格式:用户:密码,角色**/ [[email protected] activemq]$cd bin [[email protected] bin]$./activemq restart
- 设置开机启动
[[email protected] bin]$su - root [[email protected] ~]#vi /etc/rc.local su - amq -c ‘/home/amq/activemq/bin/activemq start‘
时间: 2024-10-25 17:54:56