环境准备:

  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&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;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下安装和安全配置的更多相关文章

  1. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  2. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  3. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  4. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

  5. centOS7下安装GUI图形界面

    1.如何在centOS7下安装GUI图形界面 当你安装centOS7服务器版本的时候,系统默认是不会安装GUI的图形界面程序,这个需要手动安装CentOS7 Gnome GUI包. 2.在系统下使用命 ...

  6. CentOS7下安装MySQL并配置远程连接

    一.CentOS7下安装MySQL数据库 CentOS7默认的安装包里面已经没有 MySQL-Server安装包了,远程镜像中也没有了. 默认的是MariaDB (MySQL的一个分支,开发这个分支的 ...

  7. Docker学习笔记3:CentOS7下安装Docker-Compose

    Docker-Compose是一个部署多个容器的简单但是非常必要的工具. 安装Docker-Compose之前,请先安装 python-pip,请参考我的另一篇博文CentOS7下安装python-p ...

  8. docker(一) Centos7下安装docker

    docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...

  9. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

随机推荐

  1. Strut2的配置文件strust.xml报错:Package Action extends undefined package struts-default

    struts.xml的警告信息,是需要联网验证dtd是否符合规范,只要配置成本地的dtd就会消失, 配置方式请看: 详细请看http://www.cnblogs.com/liuyangfirst/p/ ...

  2. PHP数据库抽象层--PDO(PHP Data Object) [一]

    1.简介:(PDO数据库访问抽象层,统一各种 数据库的访问接口 ) PHP 数据对象 (PDO) 扩展为PHP访问数据库定义了一个轻量级的一致接口.实现 PDO 接口的每个数据库驱动可以公开具体数据库 ...

  3. 基于NLP和GAN的小说影视化

    轮廓: https://tieba.baidu.com/p/1271120336 着色:

  4. PHP Functions - arsort()

    <?php $characters = array('a','b','c','d','e','f'); arsort($characters); print_r($characters); /* ...

  5. Get size of all tables in database

    http://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database SELECT t.NAME AS Table ...

  6. 关于C_Sharp集中处理异常

    1.写在前面 “异常意味着什么?”,想必不用对此做多余的解释,我们有理由相信在任何情况下任何应用程序都有可能出现异常,若在程序中没有对异常进行处理,则操作系统会以粗暴的方式处理掉它(弹出错误提示框), ...

  7. ADO.NET系列之DataAdapter对象

    ADO.NET系列之Connection对象 ADO.NET系列之Command对象 ADO.NET系列之DataAdapter对象 ADO.NET系列之事务和调用存储过程 我们前两篇文章介绍了ADO ...

  8. MVC中使用Hangfire执行定时任务

    需求描述 项目中有一个通知公告的功能,在后台管理员添加公告后需要推送消息给所有注册用户,让其查看消息.消息推送移动端采用极光推送,但是消息在何时发送是个问题,比如说有一个重要的会议通知,可能希望在会议 ...

  9. python 发qq邮件

    import smtplibfrom email.mime.text import MIMETextmsg_from = '979477675@qq.com' # 发送方邮箱passwd = 'irg ...

  10. uiautomator2 手工翻译版

    原文:https://github.com/openatx/uiautomator2 1.安装 pip install --pre uiautomator2   #或者你可以直接从github源码安装 ...