zoukankan      html  css  js  c++  java
  • CentOS7.2 安装RabbitMQ3.6.10

    CentOS上面使用yum安装比较方便

    先记录一些rabbitmq的基本操作命令:

    $ sudo chkconfig rabbitmq-server on  # 添加开机启动RabbitMQ服务
    $ sudo /sbin/service rabbitmq-server start # 启动服务
    $ sudo /sbin/service rabbitmq-server status  # 查看服务状态
    $ sudo /sbin/service rabbitmq-server stop   # 停止服务
    
    # 查看当前所有用户
    $ sudo rabbitmqctl list_users
    
    # 查看默认guest用户的权限
    $ sudo rabbitmqctl list_user_permissions guest
    
    # 由于RabbitMQ默认的账号用户名和密码都是guest。为了安全起见, 先删掉默认用户
    $ sudo rabbitmqctl delete_user guest
    
    # 添加新用户
    $ sudo rabbitmqctl add_user username password
    
    # 设置用户tag
    $ sudo rabbitmqctl set_user_tags username administrator
    
    # 赋予用户默认vhost的全部操作权限
    $ sudo rabbitmqctl set_permissions -p / username ".*" ".*" ".*"
    
    # 查看用户的权限
    $ sudo rabbitmqctl list_user_permissions username

    准备工作:

    Centos自带yum,首先给yum换源,换成国内的阿里云

    第一步:安装erlang

    安装rpm仓库:

    [hongdada@localhost ~]$ sudo rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

    安装erlang

    [hongdada@localhost ~]$ yum install erlang

    第二步:安装rabbitmq

    先下载rpm

    [hongdada@localhost ~]$ sudo wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm

    安装

    [hongdada@localhost ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm

    安装完成后启动服务:

    [hongdada@localhost ~]$ sudo yum install rabbitmq-server-3.6.10-1.el7.noarch.rpm

    查看服务状态:

    [hongdada@localhost ~]$ service rabbitmq-server status

    详细信息:

    [hongdada@localhost ~]$ sudo service rabbitmq-server status
    [sudo] password for hongdada: 
    Redirecting to /bin/systemctl status  rabbitmq-server.service
    ● rabbitmq-server.service - RabbitMQ broker
       Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
       Active: active (running) since 日 2017-07-23 22:10:39 CST; 4min 3s ago
     Main PID: 34634 (beam.smp)
       Status: "Initialized"
       CGroup: /system.slice/rabbitmq-server.service
               ├─34634 /usr/lib64/erlang/erts-5.10.4/bin/beam.smp -W w -A 128 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true -- -root /...
               ├─34775 /usr/lib64/erlang/erts-5.10.4/bin/epmd -daemon
               ├─34977 inet_gethost 4
               └─34978 inet_gethost 4
    
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: RabbitMQ 3.6.10. Copyright (C) 2007-2017 Pivotal Software, Inc.
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ##  ##
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ##########  Logs: /var/log/rabbitmq/rabbit@localhost.log
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ######  ##        /var/log/rabbitmq/rabbit@localhost-sasl.log
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: ##########
    7月 23 22:10:38 localhost.localdomain rabbitmq-server[34634]: Starting broker...
    7月 23 22:10:39 localhost.localdomain rabbitmq-server[34634]: systemd unit for activation check: "rabbitmq-server.service"
    7月 23 22:10:39 localhost.localdomain systemd[1]: Started RabbitMQ broker.
    7月 23 22:10:39 localhost.localdomain rabbitmq-server[34634]: completed with 0 plugins.

     查看对应的日志文件:

    [hongdada@localhost ~]$ cd /var/log/rabbitmq/
    [hongdada@localhost rabbitmq]$ ls
    rabbit@localhost.log  rabbit@localhost-sasl.log
    [hongdada@localhost rabbitmq]$ vi rabbit@localhost.log

    日志文件内容:

    =INFO REPORT==== 23-Jul-2017::22:10:38 ===
    Starting RabbitMQ 3.6.10 on Erlang R16B03-1
    Copyright (C) 2007-2017 Pivotal Software, Inc.
    Licensed under the MPL.  See http://www.rabbitmq.com/
    
    =INFO REPORT==== 23-Jul-2017::22:10:38 ===
    node           : rabbit@localhost
    home dir       : /var/lib/rabbitmq
    config file(s) : /etc/rabbitmq/rabbitmq.config (not found)
    cookie hash    : uyKwm1mYlbUecxvrRAhaaQ==
    log            : /var/log/rabbitmq/rabbit@localhost.log
    sasl log       : /var/log/rabbitmq/rabbit@localhost-sasl.log
    database dir   : /var/lib/rabbitmq/mnesia/rabbit@localhost
    
    =INFO REPORT==== 23-Jul-2017::22:10:39 ===
    Memory limit set to 1509MB of 3774MB total.
    
    =INFO REPORT==== 23-Jul-2017::22:10:39 ===
    Enabling free disk space monitoring
    
    =INFO REPORT==== 23-Jul-2017::22:10:39 ===
    Disk free limit set to 50MB
    "rabbit@localhost.log" [只读] 75L, 2451C  

    发现/etc/rabbitmq/rabbitmq.config不存在

    先创建用户:

    [hongdada@localhost system]$ sudo chkconfig rabbitmq-server on
    注意:正在将请求转发到“systemctl enable rabbitmq-server.service”。
    Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
    [hongdada@localhost system]$ sudo rabbitmqctl list_users
    Listing users
    guest    [administrator]
    [hongdada@localhost system]$ sudo rabbitmqctl add_user hongdada hongdada
    Creating user "hongdada"
    [hongdada@localhost system]$ sudo rabbitmqctl set_user_tags hongdada administrator
    Setting tags for user "hongdada" to [administrator]
    [hongdada@localhost system]$ sudo rabbitmqctl list_user_permissions hongdada
    Listing permissions for user "hongdada"
    [hongdada@localhost system]$ sudo rabbitmqctl set_permissions -p / hongdada ".*" ".*" ".*"
    Setting permissions for user "hongdada" in vhost "/"
    [hongdada@localhost system]$ sudo rabbitmqctl list_user_permissions hongdada
    Listing permissions for user "hongdada"
    /    .*    .*    .*

    创建rabbitmq.config文件

    [
     {rabbit,
      [%%
      %% Network Connectivity
      %% ====================
      %%
      %% By default, RabbitMQ will listen on all interfaces, using
      %% the standard (reserved) AMQP port.
      %%
      {tcp_listeners, [5672]},
      {loopback_users, ["hongda"]}
      ]}
    ].

    最后启动Web管理器界面:(主要是找不到rabbitmq的安装位置了,可以用文件夹搜索)

    hongdada@localhost rabbitmq_server-3.6.10]$ cd /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10
    [hongdada@localhost rabbitmq_server-3.6.10]$ ls
    ebin  include  plugins  sbin
    [hongdada@localhost rabbitmq_server-3.6.10]$ sudo rabbitmq-plugins enable rabbitmq_management
    The following plugins have been enabled:
      amqp_client
      cowlib
      cowboy
      rabbitmq_web_dispatch
      rabbitmq_management_agent
      rabbitmq_management
    
    Applying plugin configuration to rabbit@localhost... started 6 plugins.

    在虚拟机端访问:

    打开防火墙端口:15672

    重启虚拟机,在主机端远程访问192.168.1.108:15672,ok了,不重启的话访问不了。

    http://www.cnblogs.com/uptothesky/p/6094357.html

    http://www.cnblogs.com/crazylqy/p/6567253.html

    http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD

    http://blog.csdn.net/weixin_35934768/article/details/52637273

  • 相关阅读:
    Android自动化测试探索(三)Android SDK tools安装、aapt配置以及使用aapt获取apk包名
    城市要素库时空分析项目启动
    在Python3.5下安装和测试Scrapy爬网站
    快速制作规则及获取规则提取器API
    为采集动态网页安装和测试Python Selenium库
    为编写网络爬虫程序安装Python3.5
    【04】基础:将采集结果转成Excel
    【03】基础:同种网页结构套用采集规则
    【02】基础:单页采集(以微博博主主页采集为例)
    【01】基础:集搜客爬虫软件安装
  • 原文地址:https://www.cnblogs.com/hongdada/p/7226339.html
Copyright © 2011-2022 走看看