avatar
童琦杰
Aug 3, 2017Technology

RabbitMQ - Ubuntu安装、使用

安装RabbitMQ

bash
echo 'deb http://www.rabbitmq.com/debian/ stable 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

日志目录: /var/log/rabbitmq/

配置文件: /etc/rabbitmq/rabbitmq.conf

修改监听端口

/etc/rabbitmq/rabbitmq.conf
bash
listeners.tcp.default = 35673

启动RabbitMQ服务

bash
systemctl status rabbitmq-server.service

systemctl start rabbitmq-server.service

systemctl stop rabbitmq-server.service

打开防火墙端口(如果需要)

bash
sudo ufw allow 5672/tcp

添加远程访问用户

bash
rabbitmqctl add_user '用户名' '密码'

删除用户

bash
rabbitmqctl delete_user '用户名'

设置用户权限

  • First ".*" for configure permission on every entity

  • Second ".*" for write permission on every entity

  • Third ".*" for read permission on every entity

bash
rabbitmqctl set_permissions -p 'virtual host' '用户名' '.*' '.*' '.*'

查询队列信息

  • name: 名称

  • messages: 待处理的消息总数

  • consumers: 消费者数量

  • memory: 占用的内存(单位字节)

bash
rabbitmqctl list_queues name messages consumers memory

删除队列

  • --if-unused: 如果没有消费者时删除
bash
delete_queue [queue_name] --if-unused
© 2015-2022 tongqijie.com 版权所有沪ICP备17000682号