官网:http://www.rabbitmq.com/download.html
在安装rabbitmq之前要先安装erlang:http://www.rabbitmq.com/releases
wget www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el6.noarch.rpm sh-4.1# wget www.rabbitmq.com/releases/erlang/erlang-17.4-1.el6.x86_64.rpm
sh-4.1# rpm -ivh erlang-17.4-1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:erlang ########################################### [100%] sh-4.1# rpm -ivh rabbitmq-server-3.6.6-1.el6.noarch.rpm warning: rabbitmq-server-3.6.6-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY error: Failed dependencies: socat is needed by rabbitmq-server-3.6.6-1.el6.noarch
sh-4.1# yum install socat-1.7.2.2-1.el5.x86_64.rpm sh-4.1# yum install rabbitmq-server-3.6.6-1.el6.noarch.rpm #因为有依赖socat所以第一次装失败了
缺省配置先启动看看:
sh-4.1# /sbin/service rabbitmq-server start Starting rabbitmq-server: SUCCESS rabbitmq-server.
查看一下运行状态:
sh-4.1# /sbin/service rabbitmq-server status Status of node rabbit@GitLab ... [{pid,12729}, {running_applications,[{rabbit,"RabbitMQ","3.6.6"}, {mnesia,"MNESIA CXC 138 12","4.12.4"}, {os_mon,"CPO CXC 138 46","2.3"}, {rabbit_common,[],"3.6.6"}, {xmerl,"XML parser","1.3.7"}, {ranch,"Socket acceptor pool for TCP protocols.", "1.2.1"}, {sasl,"SASL CXC 138 11","2.4.1"}, {stdlib,"ERTS CXC 138 10","2.3"}, {kernel,"ERTS CXC 138 10","3.1"}]}, {os,{unix,linux}}, {erlang_version,"Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:64] [kernel-poll:true] "}, {memory,[{total,49939848}, {connection_readers,0}, {connection_writers,0}, {connection_channels,0}, {connection_other,0}, {queue_procs,2704}, {queue_slave_procs,0}, {plugins,0}, {other_proc,18858944}, {mnesia,60664}, {mgmt_db,0}, {msg_index,51568}, {other_ets,925600}, {binary,21384}, {code,19758635}, {atom,711569}, {other_system,9548780}]}, {alarms,[]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,787234816}, {disk_free_limit,50000000}, {disk_free,32652062720}, {file_descriptors,[{total_limit,65436}, {total_used,2}, {sockets_limit,58890}, {sockets_used,0}]}, {processes,[{limit,1048576},{used,140}]}, {run_queue,0}, {uptime,161}, {kernel,{net_ticktime,60}}]
查看当前用户列表:
sh-4.1# rabbitmqctl list_users Listing users ... 第一件事要创建用户,因为缺省的guest/guet 用户只能在本地豋录,所以先用命令行创建一个admin/admin123,并让他成为管理员 sh-4.1# rabbitmqctl add_user admin admin123 Creating user "admin" ... sh-4.1# rabbitmqctl list_users Listing users ... admin [] guest [administrator] sh-4.1# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] ... sh-4.1# rabbitmqctl list_users Listing users ... admin [administrator] guest [administrator]
查看一下当前启动的端口,并没有发现rabbit:
sh-4.1# netstat -lnutp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:60801 0.0.0.0:* LISTEN 1534/rpc.statd tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 12729/beam.smp tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1069/redis-server 1 tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1512/rpcbind tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1301/unicorn master tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1079/nginx tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 12232/epmd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1741/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1820/master tcp 0 0 :::5672 :::* LISTEN 12729/beam.smp tcp 0 0 :::111 :::* LISTEN 1512/rpcbind tcp 0 0 :::45872 :::* LISTEN 1534/rpc.statd tcp 0 0 :::22 :::* LISTEN 1741/sshd tcp 0 0 ::1:25 :::* LISTEN 1820/master udp 0 0 0.0.0.0:36251 0.0.0.0:* 1534/rpc.statd udp 0 0 0.0.0.0:68 0.0.0.0:* 2492/dhclient udp 0 0 0.0.0.0:839 0.0.0.0:* 1512/rpcbind udp 0 0 127.0.0.1:863 0.0.0.0:* 1534/rpc.statd udp 0 0 0.0.0.0:111 0.0.0.0:* 1512/rpcbind udp 0 0 :::45055 :::* 1534/rpc.statd udp 0 0 :::839 :::* 1512/rpcbind udp 0 0 :::111 :::* 1512/rpcbind
启动用web管理:
sh-4.1# rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent rabbitmq_management Applying plugin configuration to rabbit@GitLab... started 6 plugins. 再看一下开的端口: sh-4.1# netstat -lnutp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:60801 0.0.0.0:* LISTEN 1534/rpc.statd tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 12729/beam.smp tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1069/redis-server 1 tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1512/rpcbind tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1301/unicorn master tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1079/nginx tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 12232/epmd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1741/sshd tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 12729/beam.smp tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1820/master tcp 0 0 :::5672 :::* LISTEN 12729/beam.smp tcp 0 0 :::111 :::* LISTEN 1512/rpcbind tcp 0 0 :::45872 :::* LISTEN 1534/rpc.statd tcp 0 0 :::22 :::* LISTEN 1741/sshd tcp 0 0 ::1:25 :::* LISTEN 1820/master udp 0 0 0.0.0.0:36251 0.0.0.0:* 1534/rpc.statd udp 0 0 0.0.0.0:68 0.0.0.0:* 2492/dhclient udp 0 0 0.0.0.0:839 0.0.0.0:* 1512/rpcbind udp 0 0 127.0.0.1:863 0.0.0.0:* 1534/rpc.statd udp 0 0 0.0.0.0:111 0.0.0.0:* 1512/rpcbind udp 0 0 :::45055 :::* 1534/rpc.statd udp 0 0 :::839 :::* 1512/rpcbind udp 0 0 :::111 :::* 1512/rpcbind
查看本机ip并能过15672端口看进入页面管理:
删除一个用户:
sh-4.1# rabbitmqctl list_users Listing users ... admin [administrator] guest [administrator] sh-4.1# rabbitmqctl delete_user guest Deleting user "guest" ... sh-4.1# rabbitmqctl list_users Listing users ... admin [administrator]
修改用户的密码:
sh-4.1# rabbitmqctl change_password admin admin@test Changing password for user "admin" ...
查看所有队列消息:
sh-4.1# rabbitmqctl list_queues Listing queues ...
清除所有队列:
sh-4.1# rabbitmqctl reset
发现问题:刚装的rabbitmq无法用guest豋录
[root@NB ok]# rabbitmqctl add_user admin admin@test Creating user "admin" ... 新增用户,但并没有设置角色的情况下,也不能用网页来管理,只有设置角色后才可以 [root@NB ok]# rabbitmqctl set_user_tags admin administrator Setting tags for user "admin" to [administrator] ...