安装
sudo echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install rabbitmq-server
停止&启动
invoke-rc.d rabbitmq-server stop/start
常用命令配置
创建用户
sudo rabbitmqctl add_user {username} {password}
设置用户角色,角色可以为administrator、monitoring、management
sudo rabbitmqctl set_user_tags {username} {administrator& monitoring& management}
删除用户
sudo rabbitmqctl delete_user {username}
修改密码
sudo rabbimqctl change_password {username} {newpassword}
创建vhost
sudo rabbitmqctl add_vhost {vhostname}
删除vhost
sudo rabbitmqctl delete_vhost {vhostname}
权限赋予
sudo rabbitmqctl set_permissions [-p vhost] {user} {conf} {write} {read}
conf参数提供一个正则表达式match哪些配置资源能够被该用户配置
write参数提供一个正则表达式match哪些配置资源能够被该用户写
read参数提供一个正则表达式match哪些配置资源能够被该用户读
具体实例
- 创建test用户并定义其为administrator角色
sudo rabbitmqctl add_user test 123456
sudo rabbitmqctl set_user_tags test administrator - 创建Virtual host名字为test_vhost
sudo rabbitmqctl add_vhost test_vhost - 赋予test用户该vhost权限
sudo rabbitmqctl set_permissions -p "test_vhost" test "." "." ".*" - 打开web管理界面插件
sudo rabbitmq-plugins enable rabbitmq_management - 访问web管理界面,端口为15672
http://127.0.0.1:15672 - 创建exchange&queues(图形界面此处略)