ubuntu20.04安装RabbitMQ以及常用命令
一、RabbitMQ消息中间件
1. 机制分析
2. ubuntu下的安装
安装rabbitmq-server
安装erlang
sudo apt-get install erlang-nox
添加公钥
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
安装rabbitmq
sudo apt-get install rabbitmq-server
安装rabbitmq的管理插件
sudo rabbitmq-plugins enable rabbitmq_management
下载rabbitmqadmin
wget localhost localhost:15672/cli/rabbitmqadmin
创建两个exchange
python3 rabbitmqadmin declare exchange name=apiServers type=fanout
python3 rabbitmqadmin declare exchange name=dataServers type=fanout
添加用户test和密码test
sudo rabbitmqctl add_user test test
添加用户访问所有exchange的权限
sudo rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
为新用户创建tag
sudo rabbitmqctl set_user_tags test administrator
查看所有用户
rabbitmqctl list_users
查看端口是否开启
netstat -tnlp
3.rabbit常用命令
sudo service rabbitmq-server start
sudo service rabbitmq-server stop
sudo service rabbitmq-server restart
rabbitmq-server
rabbitmq-server -detached
rabbitmqctl stop
rabbitmqctl list_queues
rabbitmqctl list_vhosts
rabbitmqctl start_app
rabbitmqctl stop_app
rabbitmqctl status
rabbitmq-plugins list
rabbitmq-plugins enable <plugin-name>
rabbitmq-plugins disable <plugin-name>
rabbitmqctl add_user username password
rabbitmqctl list_users
rabbitmqctl delete_user username
rabbitmqctl clear_permissions -p vhostpath username
rabbitmqctl list_user_permissions username
rabbitmqctl change_password username newpassword
rabbitmqctl set_permissions -p vhostpath username ".*" ".*" ".*"
rabbitmqctl add_vhost vhostpath
rabbitmqctl list_vhosts
rabbitmqctl list_permissions -p vhostpath
rabbitmqctl delete_vhost vhost vhostpath
rabbitmqctl reset