OpenCloudOS 8 安装rabbitMQ 和Docker

文章目录

  • 安装环境 Docker-CE
  • 安装rabbitMq
      • 安装步骤:
        • 1 引入签名
        • 2 为 RabbitMQ 和 Modern Erlang 添加 Yum 仓库 。
        • 3 更新yum元数据 & 缓存rabbitmq相关的仓库数据
        • 4 yum安装依赖库
        • 5 yum安装 Erlang 和 rabbitMq服务
        • 6 创建用户 开始使用
      • RabbitMQ常用命令

安装环境 Docker-CE

服务器:腾讯云 轻量应用服务器
操作系统:OpenCloudOS 8
参考过程:1.搭建Docke   2.配置加速

配置包仓库

  1. 配置包仓库
dnf config-manager --add-repo=http://mirrors.tencent.com/docker-ce/linux/centos/docker-ce.repo
  1. 安装dockerCE dnf install -y docker-ce --nobest
    这里可以看到,涉及的依赖都被自动安装了。
    在这里插入图片描述
  2. 启动 systemctl start docker
  3. 设置自启动 systemctl enable docker.service



安装rabbitMq

参考官网文档:https://www.rabbitmq.com/install-rpm.html#cloudsmith
官方安装方式:

  1. 体验一下,可以直接使用docker安装 docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.10-management
  2. 通过厂商自带的rpm仓库安装,但是各家操作系统的仓库可能版本很老了
  3. 推荐使用 Cloudsmith Yum 仓库安装或者PackageCloud仓库安装
    1. 他们的仓库提供了一键安装的脚本,但是来自网络的脚本需要慎重执行。
    2. 一步一步配置和下载进行显式安装

安装步骤:

1 引入签名

为啥要引入呢? 原文:Yum will verify signatures of any packages it installs, therefore the first step in the process is to import the signing key

## primary RabbitMQ signing key
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
## modern Erlang repository
rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key'
## RabbitMQ server repository
rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key'

2 为 RabbitMQ 和 Modern Erlang 添加 Yum 仓库 。

为了使用 Yum 存储库,需要一个 .Repo 文件(例如 rabbitmq.repo)必须添加到/etc/yum.rep.d/目录下。这个文件的内容在不同的发行版(例如 CentOS Stream 9、 CentOS Stream 8或 OpenSUSE)之间会有所不同。

# In /etc/yum.repos.d/rabbitmq.repo

##
## Zero dependency Erlang RPM
##

[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/8/$basearch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
       https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq_erlang-noarch]
name=rabbitmq_erlang-noarch
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/8/noarch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
       https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq_erlang-source]
name=rabbitmq_erlang-source
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/8/SRPMS
repo_gpgcheck=1
enabled=1
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key
gpgcheck=0
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md


##
## RabbitMQ Server
##

[rabbitmq_server]
name=rabbitmq_server
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/8/$basearch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key
       https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq_server-noarch]
name=rabbitmq_server-noarch
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/8/noarch
repo_gpgcheck=1
enabled=1
# Cloudsmith's repository key and RabbitMQ package signing key
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key
       https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
gpgcheck=1
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

[rabbitmq_server-source]
name=rabbitmq_server-source
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/8/SRPMS
repo_gpgcheck=1
enabled=1
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key
gpgcheck=0
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
pkg_gpgcheck=1
autorefresh=1
type=rpm-md

3 更新yum元数据 & 缓存rabbitmq相关的仓库数据

# Update Yum package metadata
yum update -y
#缓存仓库数据
yum -q makecache -y --disablerepo='*' --enablerepo='rabbitmq_erlang-noarch' --enablerepo='rabbitmq_server-noarch'

4 yum安装依赖库

RabbitMQ依赖 socat和logrotate,logrotate操作系统中已经存在了,只需要安装socat就可以了。直接从操作系统带的标准库安装就完事儿了

## install these dependencies from standard OS repositories
yum install socat logrotate -y

5 yum安装 Erlang 和 rabbitMq服务

RabbitMQ的安装需要首先安装Erlang,因为它是基于Erlang的VM运行的,这里一条命令搞定。官方的原话就是从上面配置的仓库里安装,忽略其他任何的标准库。

## install RabbitMQ and zero dependency Erlang from the above repositories,
## ignoring any versions provided by the standard repositories
yum install --repo rabbitmq_erlang --repo rabbitmq_server-noarch erlang rabbitmq-server

6 创建用户 开始使用

安装完成后 服务名称为 rabbitmq-server

  1. 设置开机启动
[root@VM-4-11-opencloudos yum.repos.d]# systemctl enable rabbitmq-server
Created symlink /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service → /usr/lib/systemd/system/rabbitmq-server.service.
  1. 启动服务

sytemctl start rabbitmq-server.service

  1. 创建用户 root

rabbitmqctl add_user root 密码写这儿啊

[root@VM-4-11-opencloudos yum.repos.d]# rabbitmqctl add_user root 密码写这儿啊
Adding user "root" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.

可以看到创建完成,还提醒我们不要忘记设置虚拟主机的权限,下一步就给他安排上。

  1. 设置虚拟主机权限 这里 配置、写、读 的权限都打开。

rabbitmqctl set_permissions root -p / ".*" ".*" ".*"

  1. 给用户设置上标签

rabbitmqctl set_user_tags root administrator
可选的标签有这些
OpenCloudOS 8 安装rabbitMQ 和Docker_第1张图片

  1. 启用rabbitMq的管理平台插件

rabbitmq-plugins enable rabbitmq_management

  1. 开始使用

访问rabbitMq的管理页面的默认端口为 15672 自身端口为 4369

OpenCloudOS 8 安装rabbitMQ 和Docker_第2张图片

RabbitMQ常用命令

# 前台启动Erlang VM和RabbitMQ
rabbitmq-server
# 后台启动
rabbitmq-server -detached
# 停止RabbitMQ和Erlang VM
rabbitmqctl stop
# 查看所有队列
rabbitmqctl list_queues
# 查看所有虚拟主机
rabbitmqctl list_vhosts
# 在Erlang VM运行的情况下启动RabbitMQ应用
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 stop_app 之后使用:
rabbitmqctl reset

你可能感兴趣的:(软件安装,rabbitmq,docker,分布式)