rabbitMq使用(mac平臺)

rabbitMq使用(mac平臺)

 

1.下載html

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-mac-standalone-3.5.3.tar.gz
解壓獲得rabbitmq_server-3.6.2/目錄
將此目錄拷貝到你本身的程序安裝目錄.個人mac上單首創建了一個/mysoft目錄,專門放一些程序
拷貝完成後
Start the Server
/mysoft/rabbitmq_server-3.6.2/sbin/rabbitmq-server
配置文件:
$RABBITMQ_HOME/etc/rabbitmq/rabbitmq-env.conf 這裏是/mysoft/rabbitmq_server-3.6.2/etc/rabbitmq/rabbitmq-env.conf
$RABBITMQ_HOME/etc/rabbitmq/rabbitmq.config 這裏是/mysoft/rabbitmq_server-3.6.2/etc/rabbitmq/rabbitmq.config

安裝完成後須要將/usr/local/sbin添加到$PATH,能夠將下面這兩行加到~/.bash_profile或者~/.profile:

# RabbitMQ Config
export PATH=$PATH:/usr/local/sbin
node

2.啓動編程

複製代碼
adeMacBook-Pro:rabbitmq_server-3.5.3 apple$ sbin/rabbitmq-server

              RabbitMQ 3.5.3. Copyright (C) 2007-2014 GoPivotal, Inc.
  ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
  ##  ##
  ##########  Logs: sbin/../var/log/rabbitmq/rabbit@adeMacBook-Pro.log
  ######  ##        sbin/../var/log/rabbitmq/rabbit@adeMacBook-Pro-sasl.log
  ##########
              Starting broker... completed with 0 plugins.
複製代碼

3.狀態查詢json

複製代碼
adeMacBook-Pro:rabbitmq_server-3.5.3 apple$ sbin/rabbitmqctl status
Status of node 'rabbit@adeMacBook-Pro' ...
[{pid,79602},
 {running_applications,[{rabbit,"RabbitMQ","3.5.3"},
                        {mnesia,"MNESIA  CXC 138 12","4.12.5"},
                        {os_mon,"CPO  CXC 138 46","2.3.1"},
                        {xmerl,"XML parser","1.3.7"},
                        {sasl,"SASL  CXC 138 11","2.4.1"},
                        {stdlib,"ERTS  CXC 138 10","2.4"},
                        {kernel,"ERTS  CXC 138 10","3.2"}]},
 {os,{unix,darwin}},
複製代碼

4.能夠經過rabbitmq-plugins list查看全部插件信息api

 5.服務中止bash

1 tedzhou$ sudo rabbitmqctl stop
2 Stopping and halting node 'rabbit@zhoumingdeMacBook-Pro' ...

 

 

命令行管理RabbitMQ明細:
    RabbitMQ提供了rabbitmqctl和rabbitmqadmin命令行管理工具,它們都是RabbitMQ的插件,能夠經過rabbitmq-plugins list查看全部插件信息。rabbitmqctl的完整命令列表以下:app

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 setpost

四、Web界面管理RabbitMQui

    默承認以經過http://serverip:15672訪問RabbitMQ的Web管理界面,默認用戶名密碼都是guest。(注意:RabbitMQ 3.0以前的版本默認端口是55672,下同) 

五、RabbitMQ提供的HTTP API接口

    RabbitMQ還提供了HTTP API接口,這樣能夠經過編程方式監控RabbitMQ的運行狀態,HTTP API接口的地址爲:http://serverip:15672/api/

相關文章
相關標籤/搜索