dockerRabbitMQalready

docker安装rabbitmq

2022-10-10  本文已影响0人  阿畅00000

最近购入一台新服务器,以前都是通过离线安装,现在尝试使用docker安装,下面是我安装RabbitMQ的具体步骤:

[root@nightmare-01 ~]# docker -v
Docker version 20.10.18, build b40c2f6

一、RabbitMQ安装
1.使用docker查询rabbitmq的镜像

[root@nightmare-01 ~]# docker search rabbitmq

2.安装镜像
安装name为rabbitmq的这里是直接安装最新的,如果需要安装其他版本在rabbitmq后面跟上版本号即可

[root@nightmare-01 ~]# docker pull rabbitmq
Using default tag: latest
latest: Pulling from library/rabbitmq
fb0b3276a519: Pull complete
4b7e2bc6e42d: Pull complete
498446f27344: Pull complete
b2df5a4d5834: Pull complete
2dfb57eb3a37: Pull complete
e62da47353ea: Pull complete
cb81e266b02f: Pull complete
a71f8bd3b746: Pull complete
6126e39c0e78: Pull complete
Digest: sha256:588974c4b11c390a702839cd065f746870c91c4a4d951b05a2a33f485e4bab4a
Status: Downloaded newer image for rabbitmq:latest
[docker.io/library/rabbitmq:latest](http://docker.io/library/rabbitmq:latest)

3.启动RabbitMQ。
需要注意的是-p 5673:5672 解释:-p 外网端口:docker的内部端口 ,你们可以改成自己的外网端口号,我这里映射的外网端口是5673那么程序连接端口就是用5673

[root@nightmare-01 ~]# docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5673:5672 rabbitmq
5fdcd2e3d91adbf7b0e0ec8dbda261e28e76d203340ad880b4c43a659b422268

4.查看容器运行应用:.

[root@nightmare-01 ~]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                                                                                                                                      NAMES
5fdcd2e3d91a   rabbitmq   "docker-entrypoint.s…"   29 seconds ago   Up 28 seconds   4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:5673->5672/tcp, :::5673->5672/tcp   rabbit

5.添加rabbitmq插件

[root@nightmare-01 ~]# docker exec -it 5fdcd2e3d91a /bin/bash
root@my-rabbit:/# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@my-rabbit:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_prometheus
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@my-rabbit...
The following plugins have been enabled:
  rabbitmq_management
started 1 plugins.

二、RabbitMQ的密码修改
1.进入 Docker 容器

docker exec -it 容器ID bash

2.查看当前用户列表

root@my-rabbit:/bin# rabbitmqctl list_users
Listing users ...
user tags
guest [administrator]

3.修改密码

rabbitmqctl  change_password  Username  'Newpassword'

Username:对应不同用户,NewPassword:需设置的新密码
例如:

rabbitmqctl  change_password  guest  'wu1234'
上一篇 下一篇

猜你喜欢

热点阅读