RabbitMQ用户管理
查看RabbitMQ状态:
[root@server-1 rabbitmq]# rabbitmqctl status Status of node 'rabbit@server-1' ... [{pid,5077}, {running_applications, [{rabbitmq_management,"RabbitMQ Management Console","3.3.5"}, {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.3.5"}, {webmachine,"webmachine","1.10.3-rmq3.3.5-gite9359c7"}, {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.3.5-git680dba8"}, {rabbitmq_management_agent,"RabbitMQ Management Agent","3.3.5"}, {rabbit,"RabbitMQ","3.3.5"}, {os_mon,"CPO CXC 138 46","2.2.14"}, {inets,"INETS CXC 138 49","5.9.8"}, {amqp_client,"RabbitMQ AMQP Client","3.3.5"}, {xmerl,"XML parser","1.3.6"}, {mnesia,"MNESIA CXC 138 12","4.11"}, {sasl,"SASL CXC 138 11","2.3.4"}, {stdlib,"ERTS CXC 138 10","1.19.4"}, {kernel,"ERTS CXC 138 10","2.16.4"}]}, {os,{unix,linux}}, {erlang_version, "Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [async-threads:30] [hipe] [kernel-poll:true]\n"}, {memory, [{total,39719216}, {connection_procs,5440}, {queue_procs,5440}, {plugins,293952}, {other_proc,13392192}, {mnesia,60680}, {mgmt_db,11680}, {msg_index,33936}, {other_ets,1072544}, {binary,117568}, {code,20229052}, {atom,711569}, {other_system,3785163}]}, {alarms,[]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,407858380}, {disk_free_limit,50000000}, {disk_free,18684399616}, {file_descriptors, [{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]}, {processes,[{limit,1048576},{used,178}]}, {run_queue,0}, {uptime,434}] ...done. [root@server-1 rabbitmq]#
添加用户(用户名admin,密码admin)
# rabbitmqctl add_user admin admin
设置用户角色(设置admin用户为管理员角色)
# rabbitmqctl set_user_tags admin administrator
设置用户权限(设置admin用户配置、写、读的权限)
# rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
删除用户(删除guest用户)
# rabbitmqctl delete_user guest
注意:rabbitmq从3.3.0开始禁止使用guest/guest权限通过除localhost外的访问。
如果想使用guest/guest通过远程机器访问,需要在rabbitmq配置文件中(/etc/rabbitmq/rabbitmq.config)中设置loopback_users为[]。
[{rabbit, [{loopback_users, []}]}].