标签:try space mini 信道 队列 linu 重启 ons 用户
启动rabbitmq
docker run -d --name myrabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.7-management
查看已经启动的容器
root@ecs-s6-medium-2-linux-20191230105810:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED NAMES
db7c0ab13d8a rabbitmq:3-management "docker-entrypoint.s…" About a min72/tcp, 0.0.0.0:15672->15672/tcp rabbitmq
docker查看所有,已经运行 和 没有运行的容器:
root@ecs-s6-medium-2-linux-20191230105810:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
efb63b8f5654 rabbitmq:3.7-management "docker-entrypoint.s…" 4 minutes ago Exited (0) 2 minutes ago
进入容器
root@ecs-s6-medium-2-linux-20191230105810:~# docker exec -it db7c0ab13d8a /bin/bash
root@testrabbit:/#
root@testrabbit:/# rabbitmqctl
查看队列
root@testrabbit:/# rabbitmqctl list_queues
Timeout: 60.0 seconds ...
Listing queues for vhost / ...
给rabbitmq设置用户和密码后,需要重启rabbitmq服务
root@testrabbit:/# rabbitmqctl add_user test 123456
Adding user "test" ...
root@testrabbit:/# rabbitmqctl set_user_tags test administrator
Setting tags for user "test" to [administrator] ...
root@testrabbit:/# rabbitmqctl set_permissions -p ‘/‘ test ‘.‘ ‘.‘ ‘.‘
Setting permissions for user "test" in vhost "/" ...
执行了rabbimqctl stop后整个容器都停止了,所以要重启rabbitmq就重启容器就行了;重新启动过程如下:
^Croot@ecs-s6-medium-2-linux-20191230105810:~# docker run -d -p 5672:5672 -p 15672:15672 rabbitmq:3.7-management
dc5317126d0d48b46bfceba64e654b5e5647659be9c514fa7138d23e62f705dc
root@ecs-s6-medium-2-linux-20191230105810:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dc5317126d0d rabbitmq:3.7-management "docker-entrypoint.s…" 8 seconds ago Up 8 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp friendly_davinci
root@ecs-s6-medium-2-linux-20191230105810:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dc5317126d0d rabbitmq:3.7-management "docker-entrypoint.s…" 8 seconds ago Up 8 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp friendly_davinci
root@ecs-s6-medium-2-linux-20191230105810:~# docker exec -t dc5317126d0d /bin/bash
root@dc5317126d0d:/# rabbitmq
设置用户test好像没有设置成功, python pika连接信道,可以用默认的用户名密码 guest
列出消息队列中全部的队列和交换机
root@dc5317126d0d:/# rabbitmqctl list_queues
Timeout: 60.0 seconds ...
Listing queues for vhost / ...
root@dc5317126d0d:/#
root@dc5317126d0d:/#
root@dc5317126d0d:/# rabbitmqctl list_exchanges
Listing exchanges for vhost / ...
name type
amq.rabbitmq.trace topic
amq.direct direct
amq.headers headers
amq.topic topic
amq.fanout fanout
amq.match headers
direct
hello-exchange direct
标签:try space mini 信道 队列 linu 重启 ons 用户
原文地址:https://www.cnblogs.com/harryTree/p/12945766.html