RabbitMQ是一個在AMQP基礎上完整的,可複用的企業消息系統。他遵循Mozilla Public License開源協議。python
MQ全稱爲Message Queue, 消息隊列(MQ)是一種應用程序對應用程序的通訊方法。應用程序經過讀寫出入隊列的消息(針對應用程序的數據)來通訊,而無需專用鏈接來連接它們。消息傳遞指的是程序之間經過在消息中發送數據進行通訊,而不是經過直接調用彼此來通訊,直接調用一般是用於諸如遠程過程調用的技術。排隊指的是應用程序經過隊列來通訊。隊列的使用除去了接收和發送應用程序同時執行的要求。RabbitMQ能夠,多個程序同時使用RabbitMQ ,可是必須隊列名稱不同。採用erlang語言,屬於愛立信公司開發的。ide
新增用戶 rabbitmqctl add_user Username Passwordspa
刪除用戶 rabbitmqctl delete_user Usernamecode
修改用戶的密碼 rabbitmqctl change_password Username Newpasswordhtm
爲用戶分配角色 rabbitmqctl set_user_tags username administrator #Tags 能夠是:administrator 管理員, monitoring 監控 , management 管理blog
查看當前用戶列表 rabbitmqctl list_usersrabbitmq
查看當前虛擬主機 rabbitmqctl list_vhosts隊列
查看用戶權限 rabbitmqctl list_user_permissions Username開發
設置用戶訪問權限 rabbitmqctl set_permissions -p vhostname username ".*" ".*" ".*" ##後邊三個.*分別表明:配置權限、寫權限、讀權限 「/」是rabbitmq默認的虛擬機,默認鏈接get
清除用戶權限 rabbitmqctl clear_permissions Username
新建virtual_host: rabbitmqctl add_vhost xxx
撤銷virtual_host: rabbitmqctl delete_vhost xxx
查看列表:rabbitmqctl list_vhosts
查看當前隊列信息:rabbitmqctl list_queues
清除全部隊列:rabbitmqctl reset
[root@local ~]# rabbitmqctl add_user admin passwd ###添加用戶 Creating user "admin" ... ...done. [root@local ~]# rabbitmqctl change_password admin pswd1234 ###修改用戶密碼 Changing password for user "admin" ... ...done. [root@local ~]# rabbitmqctl set_user_tags admin management ###分配用戶角色 Setting tags for user "admin" to [management] ... ...done. [root@local ~]# rabbitmqctl list_users ###用戶列表 Listing users ... admin [management] guest [administrator] ningnan [administrator] ...done. [root@local ~]# rabbitmqctl delete_user admin ###刪除用戶 Deleting user "admin" ... ...done.
[root@local ~]# rabbitmqctl list_user_permissions guest Listing permissions for user "guest" ... / .* .* .* ...done. [root@local ~]# rabbitmqctl set_permissions -p / ningnan ".*" ".*" ".*" Setting permissions for user "ningnan" in vhost "/" ... ...done. [root@local ~]# rabbitmqctl list_user_permissions ningnan Listing permissions for user "ningnan" ... / .* .* .* ...done. [root@local ~]# rabbitmqctl clear_permissions ningnan ##清除用戶權限 Clearing permissions for user "ningnan" in vhost "/" ... ...done. [root@local ~]# rabbitmqctl list_user_permissions ningnan Listing permissions for user "ningnan" ... ...done.
[root@local service_hcloud]# MQ Receive Statistics Version 1.0
Initiate log ...
init read config file ...
QueueName : STATI
Host : 192.168.0.3
userName : guest
PassWord : bs******
2019/03/18 11:26:28 dialing "amqp://192.168.0.3:5672/"
2019/03/18 11:26:31 Dial: Exception (403) Reason: "username or password not allowed"
2019/03/18 11:26:31 running forever
發現是由於服務配置文件寫的有問題. 如圖: