修改apache-activemq的密码

相关简称

简称说明
MQ在本文中特指Apache-activeMQ
$ACTIVEMQ_HOMEMQ的安装目录

修改MQ的控制台登录密码

由于MQ的启动是在jetty容器中,所以修改MQ的控制台密码,只需要修改以下两个地方即可。

  1. 进入MQ的配置文件目录cd $ACTIVEMQ_HOME/conf
  2. 编辑jetty.xml中的securityConstraintBean下的authenticate属性为true即可,如图所示:
    高版本MQ下的authenticate属性默认为true,可以不用修改
    在这里插入图片描述
  3. 上一步骤中提到的authenticate属性设置为true之后,控制台登录的用户名/密码在同级目录下的jetty-realm.properties文件中维护,该配置文件的用户名/密码配置格式如下
    username: password [,rolename ...]
    所以冒号后的才是密码,逗号后的用户的权限名称,如图所示:不要改错了哦
    在这里插入图片描述
  4. 修改完之后保存重启即可生效,http://localhost:8161/admin。

修改MQ的主题、队列用的用户名密码

接下来修改的我们在代码中去连接MQ队列/主题时使用的密码,MQ默认情况下,访问主题/队列时是不需要用户名/密码的,当然不信你也可以测试下。
下面开始修改这个配置,提高我们系统的安全性。

  1. 第一步还是进入到MQ的配置文件目录cd $ACTIVEMQ_HOME/conf
  2. 修改activemq.xml,在如图所示位置添加以下内容
    在这里插入图片描述
<plugins>
	<!-- Configure authentication; Username, passwords and groups -->
	<simpleAuthenticationPlugin>
		<users>
			<!-- 这里引用了两个变量,他们在同级目录下的credentials.properties文件中维护 -->
			<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="admins"/>
		</users>
	</simpleAuthenticationPlugin>
</plugins>
  1. 对应的用户名密码是在conf/credentials.properties文件中维护
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
## 
## http://www.apache.org/licenses/LICENSE-2.0
## 
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

# Defines credentials that will be used by components (like web console) to access the broker

# 用户名(对应activemq.xml中新添加内容的变量${activemq.username})
activemq.username=system

# 密码 (对应activemq.xml中新添加内容的变量${activemq.password})
activemq.password=manager
guest.password=password
  1. 修改完配置后,保存重启MQ即可生效,动动小手测试下吧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值