阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Mac下RabbitMQ搭建和管理

156次阅读
没有评论

共计 5849 个字符,预计需要花费 15 分钟才能阅读完成。

1、安装

在 Mac 下安装 RabbitMQ 是非常简单的,一般默认 RabbitMQ 服务器依赖的 Erlang 已经安装,只需要用下面两个命令就可以完成 RabbitMQ 的安装(前提是 homebrew 已经被安装):

brew update
brew install rabbitmq
 
安装完成后需要将 /usr/local/sbin 添加到 $PATH,可以将下面这两行加到~/.bash_profile 或者~/.profile:
 
# RabbitMQ Config
export PATH=$PATH:/usr/local/sbin
 
在 Windows 下安装稍微麻烦些,需要先安装 ErLang,然后下载 RabbitMQ 可执行文件安装
 
2、启动 RabbitMQ 服务
    上面配置完成后,需要关闭终端窗口,重新打开,然后输入下面命令即可启动 RabbitMQ 服务:

rabbitmq-server
 
可以在后面加 -detatched 选项参数表示以守护进程方式启动
 
3、命令行管理 RabbitMQ
    RabbitMQ 提供了 rabbitmqctl 和 rabbitmqadmin 命令行管理工具,它们都是 RabbitMQ 的插件,可以通过 rabbitmq-plugins list 查看所有插件信息。rabbitmqctl 的完整命令列表如下:

stop [<pid_file>]
    stop_app
    start_app
    wait <pid_file>
    reset
    force_reset
    rotate_logs <suffix>
 
    join_cluster <clusternode> [–ram]
    cluster_status
    change_cluster_node_type disc | ram
    forget_cluster_node [–offline]
    update_cluster_nodes clusternode
    sync_queue queue
    cancel_sync_queue queue
 
    add_user <username> <password>
    delete_user <username>
    change_password <username> <newpassword>
    clear_password <username>
    set_user_tags <username> <tag> …
    list_users
 
    add_vhost <vhostpath>
    delete_vhost <vhostpath>
    list_vhosts [<vhostinfoitem> …]
    set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
    clear_permissions [-p <vhostpath>] <username>
    list_permissions [-p <vhostpath>]
    list_user_permissions <username>
 
    set_parameter [-p <vhostpath>] <component_name> <name> <value>
    clear_parameter [-p <vhostpath>] <component_name> <key>
    list_parameters [-p <vhostpath>]
 
    set_policy [-p <vhostpath>] [–priority <priority>] [–apply-to <apply-to>]
<name> <pattern>  <definition>
    clear_policy [-p <vhostpath>] <name>
    list_policies [-p <vhostpath>]
 
    list_queues [-p <vhostpath>] [<queueinfoitem> …]
    list_exchanges [-p <vhostpath>] [<exchangeinfoitem> …]
    list_bindings [-p <vhostpath>] [<bindinginfoitem> …]
    list_connections [<connectioninfoitem> …]
    list_channels [<channelinfoitem> …]
    list_consumers [-p <vhostpath>]
    status
    environment
    report
    eval <expr>
 
    close_connection <connectionpid> <explanation>
    trace_on [-p <vhost>]
    trace_off [-p <vhost>]
    set_vm_memory_high_watermark <fraction>
 
    start_app、stop_app 分别是启动和停止 RabbitMQ 应用。其他的 list_queues、list_exchanges 等是显示 RabbitMQ 队列、RabbitMQ 交换机信息。
    rabbitmqadmin 的完整命令列表如下(Mac 下安装好了就带了这个命令,Windows 下貌似还需要从 http://server-name:15672/cli/ 下载,并可能需要通过 rabbitmq-plugins enable rabbitmq management 启用这个插件):

Usage
=====
  rabbitmqadmin [options] subcommand
 
  where subcommand is one of:
 
Options
=======
–help, -h              show this help message and exit
–config=CONFIG, -c CONFIG
                        configuration file [default: ~/.rabbitmqadmin.conf]
–node=NODE, -N NODE    node described in the configuration file [default:
                        ‘default’ only if configuration file is specified]
–host=HOST, -H HOST    connect to host HOST [default: localhost]
–port=PORT, -P PORT    connect to port PORT [default: 15672]
–vhost=VHOST, -V VHOST
                        connect to vhost VHOST [default: all vhosts for list,
                        ‘/’ for declare]
–username=USERNAME, -u USERNAME
                        connect using username USERNAME [default: guest]
–password=PASSWORD, -p PASSWORD
                        connect using password PASSWORD [default: guest]
–quiet, -q            suppress status messages [default: True]
–ssl, -s              connect with ssl [default: False]
–ssl-key-file=SSL_KEY_FILE
                        PEM format key file for SSL
–ssl-cert-file=SSL_CERT_FILE
                        PEM format certificate file for SSL
–format=FORMAT, -f FORMAT
                        format for listing commands – one of [raw_json, long,
                        pretty_json, kvp, tsv, table, bash] [default: table]
–sort=SORT, -S SORT    sort key for listing queries
–sort-reverse, -R      reverse the sort order
–depth=DEPTH, -d DEPTH
                        maximum depth to recurse for listing tables [default:
                        1]
–bash-completion      Print bash completion script [default: False]
–version              Display version and exit
 
Display
=======
 
  list users [<column>…]
  list vhosts [<column>…]
  list connections [<column>…]
  list exchanges [<column>…]
  list bindings [<column>…]
  list permissions [<column>…]
  list channels [<column>…]
  list parameters [<column>…]
  list queues [<column>…]
  list policies [<column>…]
  list nodes [<column>…]
  show overview [<column>…]
 
Object Manipulation
===================
 
  declare queue name=… [node=… auto_delete=… durable=… arguments=…]
  declare vhost name=… [tracing=…]
  declare user name=… password=… tags=…
  declare exchange name=… type=… [auto_delete=… internal=… durable=… arguments=…]
  declare policy name=… pattern=… definition=… [priority=… apply-to=…]
  declare parameter component=… name=… value=…
  declare permission vhost=… user=… configure=… write=… read=…
  declare binding source=… destination=… [arguments=… routing_key=… destination_type=…]
  delete queue name=…
  delete vhost name=…
  delete user name=…
  delete exchange name=…
  delete policy name=…
  delete parameter component=… name=…
  delete permission vhost=… user=…
  delete binding source=… destination_type=… destination=… properties_key=…
  close connection name=…
  purge queue name=…
 
Broker Definitions
==================
 
  export <file>
  import <file>
 
Publishing and Consuming
========================
 
  publish routing_key=… [payload=… payload_encoding=… exchange=…]
  get queue=… [count=… requeue=… payload_file=… encoding=…]
 
  * If payload is not specified on publish, standard input is used
 
  * If payload_file is not specified on get, the payload will be shown on
    standard output along with the message metadata
 
  * If payload_file is specified on get, count must not be set

4、Web 界面管理 RabbitMQ

    默认可以通过 http://serverip:15672 访问 RabbitMQ 的 Web 管理界面,默认用户名密码都是 guest。(注意:RabbitMQ 3.0 之前的版本默认端口是 55672,下同)

5、RabbitMQ 提供的 HTTP API 接口

    RabbitMQ 还提供了 HTTP API 接口,这样可以通过编程方式监控 RabbitMQ 的运行状态,HTTP API 接口的地址为:http://serverip:15672/api/

CentOS 5.6 安装 RabbitMQ http://www.linuxidc.com/Linux/2013-02/79508.htm

RabbitMQ 客户端 C ++ 安装详细记录 http://www.linuxidc.com/Linux/2012-02/53521.htm

用 Python 尝试 RabbitMQ http://www.linuxidc.com/Linux/2011-12/50653.htm

RabbitMQ 集群环境生产实例部署 http://www.linuxidc.com/Linux/2012-10/72720.htm

Ubuntu 下 PHP + RabbitMQ 使用 http://www.linuxidc.com/Linux/2010-07/27309.htm

在 CentOS 上安装 RabbitMQ 流程 http://www.linuxidc.com/Linux/2011-12/49610.htm

RabbitMQ 的详细介绍 :请点这里
RabbitMQ 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计5849字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中