centos7 安装rabbitmq

        经常听到消息队列、消息中间件等,项目中跟其他公司也有业务交叉用到了rabbitmq,基本就是老大封装一个公共方法我们在时间逻辑中调用,具体怎么实现,原理是什么没有过多关注,今天特地搭一个rabbitmq来学习下。

  1. 安装依赖 erlang

    rabbitmq官网有多种安装方法,这里选择了第一种:

    • Team RabbitMQ produces a package stripped down to only provide those components needed to run RabbitMQ. It might be easiest to use if installing Erlang’s dependencies is proving difficult.
    • Erlang Solutions produces packages that are usually reasonably up to date and involve installation of a potentially excessive list of dependencies.
    • EPEL (“Extra Packages for Enterprise Linux”); part of the Red Hat/Fedora organisation, provides many additional packages, including Erlang. These are the most official packages but tend to be out of date. The packages are split into many small pieces.
    • openSUSE produces Erlang packages for each distribution (openSUSE and SLES)

    具体步骤:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    1.切换至/etc/yum.repos.d目录,新建rabbitmq_erlang.repo并编辑:

    [rabbitmq-erlang]
    name=rabbitmq-erlang
    baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/21/el/7
    gpgcheck=1
    gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
    repo_gpgcheck=0
    enabled=1

    2.执行命令 yum install erlang,一路yes等待安装
    3.测试安装成功与否 终端输入:erl,输出相关信息则成功
  2. 安装rabbitmq

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    1.导入key
    rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc

    2.配置源 cd /etc/yum.repos.d && vim rabbitmq.repo
    [bintray-rabbitmq-server]
    name=bintray-rabbitmq-rpm
    baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/
    gpgcheck=0
    repo_gpgcheck=0
    enabled=1

    3.yum install rabbitmq-server

    4.设置开机启动 chkconfig rabbitmq-server on

    5.启动服务 service rabbitmq-server start

    6.开启界面管理 rabbitmq-plugins enable rabbitmq_management

    7.开启远程访问
    cd /etc/rabbitmq
    cp /usr/share/doc/rabbitmq-server-3.5.6/rabbitmq.config.example /etc/rabbitmq/
    mv rabbitmq.config.example rabbitmq.config
    vim /etc/rabbitmq/rabbitmq.config
    将 %% {loopback_users, []}, 修改为 {loopback_users, []} **注意逗号**
    service rabbitmq-server reload