在CentOS 7系统上安装RabbitMQ

前端之家收集整理的这篇文章主要介绍了在CentOS 7系统上安装RabbitMQ前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
http://www.rabbitmq.com/download.html


[root@contoso ~]#rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-10.noarch.rpm

[root@contoso ~]# yum install -y erlang
[root@contoso ~]# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
[root@contoso ~]# yum install -y https://bintray.com/rabbitmq/rabbitmq-server-rpm/download_file?file_path=rabbitmq-server-3.6.10-1.el7.noarch.rpm
[root@contoso ~]# systemctl enable rabbitmq-server
[root@contoso ~]# systemctl restart rabbitmq-server
[root@contoso ~]# systemctl status rabbitmq-server
[root@contoso ~]# rabbitmqctl status
Status of node rabbit@contoso
[{pid,6577},
{running_applications,
[{rabbit,"RabbitMQ","3.6.10"},
{mnesia,"MNESIA CXC 138 12","4.11"},
{os_mon,"CPO CXC 138 46","2.2.14"},
{ranch,"Socket acceptor pool for TCP protocols.","1.3.0"},
{ssl,"Erlang/OTP SSL application","5.3.3"},
{public_key,"Public key infrastructure","0.21"},
{crypto,"CRYPTO version 2","3.2"},
{rabbit_common,
"Modules shared by rabbitmq-server and rabbitmq-erlang-client",
"3.6.10"},
{compiler,"ERTS CXC 138 10","4.9.4"},
{xmerl,"XML parser","1.3.6"},
{Syntax_tools,"Syntax tools","1.6.13"},
{asn1,"The Erlang ASN1 compiler version 2.0.4","2.0.4"},
{sasl,"SASL CXC 138 11","2.3.4"},
{stdlib,"1.19.4"},
{kernel,"2.16.4"}]},
{os,{unix,linux}},
{erlang_version,
"Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:64] [hipe] [kernel-poll:true]\n"},
{memory,
[{total,54096928},
{connection_readers,0},
{connection_writers,
{connection_channels,
{connection_other,
{queue_procs,2800},
{queue_slave_procs,
{plugins,
{other_proc,22582320},60912},
{metrics,132072},
{mgmt_db,
{msg_index,40536},
{other_ets,2084968},
{binary,740008},
{code,22700940},
{atom,842665},
{other_system,5038979}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,3274466918},
{disk_free_limit,50000000},
{disk_free,47952224256},
{file_descriptors,
[{total_limit,924},{total_used,2},{sockets_limit,829},{sockets_used,0}]},
{processes,[{limit,1048576},{used,152}]},
{run_queue,
{uptime,155},
{kernel,{net_ticktime,60}}]
[root@contoso ~]#
[root@contoso ~]# 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@contoso... started 6 plugins.

[root@contoso ~]#

http://127.0.0.1:15672

一个是环境变量的配置文件 rabbitmq-env.conf
一个是配置信息的配置文件 rabbitmq.config
注意,这两个文件默认是没有的,如果需要必须自己创建。

rabbitmq-env.conf

这个文件的位置是确定和不能改变的,位于:/etc/rabbitmq目录下(这个目录需要自己创建)。
文件内容包括了RabbitMQ的一些环境变量,常用的有:
#RABBITMQ_NODE_PORT= //端口号
#HOSTNAME=
RABBITMQ_NODENAME=mq
RABBITMQ_CONFIG_FILE= //配置文件的路径
RABBITMQ_MNESIA_BASE=/rabbitmq/data //需要使用的MNESIA数据库的路径
RABBITMQ_LOG_BASE=/rabbitmq/log //log的路径
RABBITMQ_PLUGINS_DIR=/rabbitmq/plugins //插件的路径

rabbitmq 添加远程访问功能

[root@contoso ~]# cat > /etc/rabbitmq/rabbitmq.config
[{rabbit,[{loopback_users,[]}]}].
[root@contoso ~]# systemctl restart rabbitmq-server
[root@contoso ~]# systemctl status rabbitmq-server






http://127.0.0.1:15672/api/


RabbitMQ Management HTTP API
Introduction

Apart from this help page,all URIs will serve only resources of type application/json,and will require HTTP basic authentication (using the standard RabbitMQ user database). The default user is guest/guest.

Many URIs require the name of a virtual host as part of the path,since names only uniquely identify objects within a virtual host. As the default virtual host is called "/",this will need to be encoded as "%2f".

PUTing a resource creates it. The JSON object you upload must have certain mandatory keys (documented below) and may have optional keys. Other keys are ignored. Missing mandatory keys constitute an error.

Since bindings do not have names or IDs in AMQP we synthesise one based on all its properties. Since predicting this name is hard in the general case,you can also create bindings by POSTing to a factory URI. See the example below.

Many URIs return lists. Such URIs can have the query string parameters sort and sort_reverse added. sort allows you to select a primary field to sort by,and sort_reverse will reverse the sort order if set to true. The sort parameter can contain subfields separated by dots. This allows you to sort by a nested component of the listed items; it does not allow you to sort by more than one field. See the example below.

You can also restrict what information is returned per item with the columns parameter. This is a comma-separated list of subfields separated by dots. See the example below.

Most of the GET queries return many fields per object. See the separate stats documentation.
Examples

A few quick examples for Windows and Unix,using the command line tool curl:

Get a list of vhosts:

:: Windows
C:\> curl -i -u guest:guest http://localhost:15672/api/vhosts
# Unix
$ curl -i -u guest:guest http://localhost:15672/api/vhosts
HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon,16 Sep 2013 12:00:02 GMT
Content-Type: application/json
Content-Length: 30

[{"name":"/","tracing":false}]


Get a list of channels,fast publishers first,restricting the info items we get back:

:: Windows
C:\> curl -i -u guest:guest "http://localhost:15672/api/channels?sort=message_stats.publish_details.rate&sort_reverse=true&columns=name,message_stats.publish_details.rate,message_stats.deliver_get_details.rate"

# Unix
$ curl -i -u guest:guest 'http://localhost:15672/api/channels?sort=message_stats.publish_details.rate&sort_reverse=true&columns=name,message_stats.deliver_get_details.rate'

HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon,16 Sep 2013 12:01:17 GMT
Content-Type: application/json
Content-Length: 219
Cache-Control: no-cache

[{"message_stats":{"publish_details":{"rate" ... (remainder elided)

Create a new vhost:

:: Windows
C:\> curl -i -u guest:guest -H "content-type:application/json" ^
-XPUT http://localhost:15672/api/vhosts/foo


# Unix
$ curl -i -u guest:guest -H "content-type:application/json" \
-XPUT http://localhost:15672/api/vhosts/foo


HTTP/1.1 204 No Content
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon,16 Sep 2013 12:03:00 GMT
Content-Type: application/json
Content-Length: 0

Note: you must specify application/json as the mime type.

Note: the name of the object is not needed in the JSON object uploaded,since it is in the URI. As a virtual host has no properties apart from its name,this means you do not need to specify a body at all!
Create a new exchange in the default virtual host:

:: Windows
C:\> curl -i -u guest:guest -H "content-type:application/json" ^
-XPUT -d"{""type"":""direct"",""durable"":true}" ^
http://localhost:15672/api/exchanges/%2f/my-new-exchange


# Unix
$ curl -i -u guest:guest -H "content-type:application/json" \
-XPUT -d'{"type":"direct","durable":true}' \
http://localhost:15672/api/exchanges/%2f/my-new-exchange


HTTP/1.1 204 No Content
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon,16 Sep 2013 12:04:00 GMT
Content-Type: application/json
Content-Length: 0

Note: we never return a body in response to a PUT or DELETE,unless it fails.
And delete it again:

:: Windows
C:\> curl -i -u guest:guest -H "content-type:application/json" ^
-XDELETE http://localhost:15672/api/exchanges/%2f/my-new-exchange


# Unix
$ curl -i -u guest:guest -H "content-type:application/json" \
-XDELETE http://localhost:15672/api/exchanges/%2f/my-new-exchange


HTTP/1.1 204 No Content
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Mon,16 Sep 2013 12:05:30 GMT
Content-Type: application/json
Content-Length: 0

Reference


[root@contoso ~]# python -V
Python 2.7.5
[root@contoso ~]#


[root@contoso ~]# wget https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/rabbitmq_v3_6_10/bin/rabbitmqadmin

[root@contoso ~]# mv rabbitmqadmin /usr/local/bin/

[root@contoso ~]# chmod 755 /usr/local/bin/rabbitmqadmin
[root@contoso ~]# rabbitmqadmin --help Usage ===== rabbitmqadmin [options] subcommand 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] --path-prefix=PATH_PREFIX use specific URI path prefix for the RabbitMQ HTTP API (default: blank string) [default: ] --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 --ssl-ca-cert-file=SSL_CA_CERT_FILE PEM format CA certificate file for SSL --ssl-disable-hostname-verification Disables peer hostname verification --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 More Help ========= For more help use the help subcommand: rabbitmqadmin help subcommands # For a list of available subcommands rabbitmqadmin help config # For help with the configuration file [root@contoso ~]#

原文链接:https://www.f2er.com/centos/376396.html

猜你在找的CentOS相关文章