安装环境:
Linux OS:Redhat7.1
RabbitMQ是基于Erlang的,所以要先安装Erlang:
1. 添加Erlang Solutions Key支持
rpm --import http://binaries.erlang-solutions.com/debian/erlang_solutions.asc
2. 配置Erlang的repo文件
wget -o /etc/yum.repos.d/erlang_solutions.repo http://binaries.erlang-solutions.com/rpm/centos/erlang_solutions.repo
3. 安装Erlang
yum install erlang*
4.下载并安装RabbitMQ
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-3.5.3-1.noarch.rpm
rpm -ivh rabbitmq-server-3.5.3-1.noarch.rpm
5.配置并启动rabbitMQ
新编辑文件rabbitmq-env.conf
NODE_IP_ADDRESS=10.14.1.32
CONFIG_FILE=/etc/rabbitmq/rabbitmq
MNESIA_BASE=/var/lib/rabbitmq/mnesia
RabbitMQ的环境变量:
Name | Default | Description |
---|---|---|
RABBITMQ_NODE_IP_ADDRESS | the empty string - meaning bind to all network interfaces. | Change this if you only want to bind to one network interface. To bind to two or more interfaces, use thetcp_listeners key inrabbitmq.config. |
RABBITMQ_NODE_PORT | 5672 | |
RABBITMQ_DIST_PORT | RABBITMQ_NODE_PORT + 20000 | Port to use for clustering. Ignored if your config file setsinet_dist_listen_min orinet_dist_listen_max |
RABBITMQ_NODENAME |
| The node name should be unique per erlang-node-and-machine combination. To run multiple nodes, see the clustering guide. |
RABBITMQ_USE_LONGNAME | When set to true this will cause RabbitMQ to use fully qualified names to identify nodes. This may prove useful on EC2. Note that it is not possible to switch between using short and long names without resetting the node. | |
RABBITMQ_SERVICENAME | Windows Service: RabbitMQ | The name of the installed service. This will appear in services.msc. |
RABBITMQ_CONSOLE_LOG | Windows Service: | Set this variable to new or reuse to redirect console output from the server to a file named%RABBITMQ_SERVICENAME%.debug in the default RABBITMQ_BASEdirectory.
|
RABBITMQ_CTL_ERL_ARGS | None | Parameters for the erl command used when invoking rabbitmqctl. This should be overridden for debugging purposes only. |
RABBITMQ_SERVER_ERL_ARGS |
| Standard parameters for the erlcommand used when invoking the RabbitMQ Server. This should be overridden for debugging purposes only. Overriding this variablereplaces the default value. |
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS |
| Additional parameters for the erlcommand used when invoking the RabbitMQ Server. The value of this variable is appended the default list of arguments (RABBITMQ_SERVER_ERL_ARGS). |
RABBITMQ_SERVER_START_ARGS | None | Extra parameters for the erlcommand used when invoking the RabbitMQ Server. This will not overrideRABBITMQ_SERVER_ERL_ARGS. |
新编辑文件rabbitmq.config
[
{kernel, [
]},
{rabbit, [
{default_user,<<"guest">>},
{default_pass,<<"guest">>}
]}
].
这是个标准的Erlang文件,可配置参数可详见
http://www.rabbitmq.com/configure.html#config-items
启动RabbitMQ Server
[root@localhost rabbitmq]# /etc/init.d/rabbitmq-server start
Starting rabbitmq-server (via systemctl): [ OK ]
查看RabbitMQ状态
[root@localhost rabbitmq]# /etc/init.d/rabbitmq-server status
Status of node rabbit@localhost ...
[{pid,27673},
{running_applications,[{rabbit,"RabbitMQ","3.5.3"},
{mnesia,"MNESIA CXC 138 12","4.13"},
{os_mon,"CPO CXC 138 46","2.4"},
{xmerl,"XML parser","1.3.8"},
{sasl,"SASL CXC 138 11","2.5"},
{stdlib,"ERTS CXC 138 10","2.5"},
{kernel,"ERTS CXC 138 10","4.0"}]},
{os,{unix,linux}},
{erlang_version,"Erlang/OTP 18 [erts-7.0] [source-4d83b58] [64-bit] [smp:4:4] [async-threads:30] [hipe] [kernel-poll:true]\n"},
{memory,[{total,37641048},
{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,2808},
{queue_procs,2808},
{queue_slave_procs,0},
{plugins,0},
{other_proc,13606664},
{mnesia,61008},
{mgmt_db,0},
{msg_index,35144},
{other_ets,778488},
{binary,16384},
{code,16654384},
{atom,654217},
{other_system,5829143}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"10.14.1.32"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,3423297536},
{disk_free_limit,50000000},
{disk_free,36318142464},
{file_descriptors,[{total_limit,924},
{total_used,3},
{sockets_limit,829},
{sockets_used,1}]},
{processes,[{limit,1048576},{used,126}]},
{run_queue,0},
{uptime,8}]
6. RabbitMQ用户管理
Rabbitmq服务器的主要通过rabbitmqctl
[root@localhost rabbitmq]# rabbitmqctl --help | grep user
Error: could not recognise command
add_user <username> <password>
delete_user <username>
change_password <username> <newpassword>
clear_password <username>
set_user_tags <username> <tag> ...
list_users
set_permissions [-p <vhostpath>] <user> <conf> <write> <read>
clear_permissions [-p <vhostpath>] <username>
list_user_permissions <username>
比如添加新用户:
[root@localhost rabbitmq]# rabbitmqctl add_user test test
Creating user "test" ...
[root@localhost rabbitmq]# rabbitmqctl list_users
Listing users ...
guest [administrator]
test []