ActiveMQ-在Centos7下安装和安全配置
环境准备:
JDK1.8
ActiveMQ-5.11
Centos7
1、下载Linux版本的ActiveMQ:
$ wget http://apache.fayea.com/activemq/5.11.1/apache-activemq-5.11.1-bin.tar.gz
2、解压安装:
$ tar -zxvf apache-activemq-5.11.1-bin.tar.gz
$mv apache-activemq-5.11.1 /usr/local/
3、配置防火墙:
ActiveMQ 需要用到两个端口:
一个是消息通讯的端口(默认为 61616)
一个是管理控制台端口(默认为 8161)
可在 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>
$ 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
重启防火墙:
$ service iptables restart
4、启动ActiveMQ:
进入到ActiveMQ的bin目录下
$ cd /usr/local/apache-activemq-5.11.1/bin
启动:
$ ./activemq start
5、打开管理界面:
http://192.168.xx.xx:8161

点击 Manage ActiveMQ broker 输入:admin/admin 登陆

6、安全验证配置:
安全验证有两个概念:1.控制台安全配置;2.JMS服务安全配置
6.、 控制台安全配置
打开conf/jetty.xml文件,找到
<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>
将"false" 改为"true",重启ActiveMQ 即可。
控制台的登录用户名密码保存在conf/credentials.properties文件中。
activemq.username=system
activemq.password=manager
guest.password=password
6.2. JMS服务安全配置 在conf/activemq.xml文件中加入以下内容
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
......
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
<plugins>
<!-- Configure authentication; Username, passwords and groups -->
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="system" password="${activemq.password}" groups="users,admins"/>
<authenticationUser username="user" password="${guest.password}" groups="users"/>
<authenticationUser username="guest" password="${guest.password}" groups="guests"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
</broker>
这个${activemq.password} 在conf/credentials.properties文件中配置
7、在程序中运行
public class Sendser {
public static void main(String[] args) throws Exception{
//第一步,建立ConnectionFactory工厂对象,需要填写用户名,密码,以及要连接的地址
//输入账号密码
/*ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
ActiveMQConnectionFactory.DEFAULT_USER,
ActiveMQConnectionFactory.DEFAULT_PASSWORD,
"tcp://localhost:61616"
);*/
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"system",
"manager",
"tcp://localhost:61616"
);
......
}
ActiveMQ-在Centos7下安装和安全配置的更多相关文章
- CentOS7 下 安装 supervisor以及使用
CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...
- Linux CentOs7 下安装 redis
Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装 命令如下 $ yum install gcc-c++ $ wget ht ...
- Centos7下安装配置Redsocks
Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...
- CentOS7下安装SVN服务端
CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...
- centOS7下安装GUI图形界面
1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...
- CentOS7下安装MySQL并配置远程连接
一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...
- Docker学习笔记3:CentOS7下安装Docker-Compose
Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...
- docker(一) Centos7下安装docker
docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...
- centos7 下 安装部署nginx
centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...
随机推荐
- java.lang.NoClassDefFoundError Could not initialize class 异常的处理
class,forname的配置文件出问题核对url数据库中的名字和bean中名字不同没有把jar包变成build path
- RabbitMQ添加rabbitmqadmin和其使用方法(类似Redis的redis-cli)
一:先进入rabbitmq的安装目录下的bin目录,执行wget -c http://localhost:15672/cli/rabbitmqadmin:(前提是plugin management已经 ...
- 第一部分 Mysql的基础
一.登录: mysql -h localhost -u root -p #其中,-h表示后面跟着的是服务器主机地址,-u后面跟着的是用户名,-p表示密码# 本地测试: 账号: 二.也可以省略写成: m ...
- linux上安装maven
解压安装: tar -zxvf apache-maven-3.3.9-bin.tar.gz 配置环境变量 cd /etc/ vi profile 在最后面加上M2_HOME=/usr/local/my ...
- Airplace平台
Demo: 左上角:(0, 0)开始导航,手机终端上实时在地图上当前所在显示,当前点以绿色点显示,轨迹点以红色显示. 系统架构:基于移动手机的以网络为辅助的架构.特点:低头顶交流,用户隐私和安全 &g ...
- (最短路 spfa)Wormholes -- poj -- 3259
http://poj.org/problem?id=3259 Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions ...
- java反射中的动态代理机制(有实例)
在学习Spring的时候,我们知道Spring主要有两大思想,一个是IoC,另一个就是AOP,对于IoC,依赖注入就不用多说了,而对于Spring的核心AOP来说,我们不但要知道怎么通过AOP来满足的 ...
- The Real Meaning of Peace
The Real Meaning of Peace There once was a king who offered a prize to the artist who would paint th ...
- [Linux]几个armhf的ubuntu源
摘自百度贴吧,留存 http://mirrors.ustc.edu.cn/ubuntu-ports/http://ftp.ubuntu-tw.org/mirror/ubuntu-ports/http: ...
- 【转】PHP操作MongoDB【NoSQL】
原文:http://blog.sina.com.cn/s/blog_4b67d3240101519b.html 一.MongoDB简介 MongoDB (名称来自"humongous&quo ...