部署单节点RabbitMQ
|Word Count:923|Reading Time:5mins|Post Views:
原来开发一直使用Ubuntu+Docker的形式来部署MQ,这次用RockyLinux有点问题。我连上去一看,他用阿里云的镜像库拉到的RabbitMQ都是两年前的版本了。既然是长期使用的专用节点,就没必要秋裤套棉裤了,直接本地部署吧。
这次使用RockyLInux9.4实现RabbitMQ的单节点部署。
2024.05 摄于大运河博物馆·三星堆特展
系统准备
1 2
| # 添加Github访问路径 sh -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts'
|
导入密钥
1 2 3 4 5 6
| # rpm --import 'https://github.com/rabbitmq/signing-keys/releases/download/3.0/rabbitmq-release-signing-key.asc' # rpm --import 'https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key' # rpm --import 'https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key'
|
添加Yum库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| cat > /etc/yum.repos.d/rabbitmq.repo << 'EOF' # In /etc/yum.repos.d/rabbitmq.repo
# # # [modern-erlang] name=modern-erlang-el9 # uses a Cloudsmith mirror @ yum.novemberain.com. # Unlike Cloudsmith, it does not have any traffic quotas baseurl=https://yum1.novemberain.com/erlang/el/9/$basearch https://yum2.novemberain.com/erlang/el/9/$basearch https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/9/$basearch repo_gpgcheck=1 enabled=1 gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key gpgcheck=1 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md
[modern-erlang-noarch] name=modern-erlang-el9-noarch # uses a Cloudsmith mirror @ yum.novemberain.com. # Unlike Cloudsmith, it does not have any traffic quotas baseurl=https://yum1.novemberain.com/erlang/el/9/noarch https://yum2.novemberain.com/erlang/el/9/noarch https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/9/noarch repo_gpgcheck=1 enabled=1 gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key https://github.com/rabbitmq/signing-keys/releases/download/3.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
[modern-erlang-source] name=modern-erlang-el9-source # uses a Cloudsmith mirror @ yum.novemberain.com. # Unlike Cloudsmith, it does not have any traffic quotas baseurl=https://yum1.novemberain.com/erlang/el/9/SRPMS https://yum2.novemberain.com/erlang/el/9/SRPMS https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/9/SRPMS repo_gpgcheck=1 enabled=1 gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key https://github.com/rabbitmq/signing-keys/releases/download/3.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
# # # [rabbitmq-el9] name=rabbitmq-el9 baseurl=https://yum2.novemberain.com/rabbitmq/el/9/$basearch https://yum1.novemberain.com/rabbitmq/el/9/$basearch https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/9/$basearch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key https://github.com/rabbitmq/signing-keys/releases/download/3.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-el9-noarch] name=rabbitmq-el9-noarch baseurl=https://yum2.novemberain.com/rabbitmq/el/9/noarch https://yum1.novemberain.com/rabbitmq/el/9/noarch https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/9/noarch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key https://github.com/rabbitmq/signing-keys/releases/download/3.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-el9-source] name=rabbitmq-el9-source baseurl=https://yum2.novemberain.com/rabbitmq/el/9/SRPMS https://yum1.novemberain.com/rabbitmq/el/9/SRPMS https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/9/SRPMS repo_gpgcheck=1 enabled=1 gpgkey=https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.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 EOF
|
安装软件
1 2 3
| dnf makecache dnf install -y socat logrotate dnf install -y erlang rabbitmq-server
|
锁定版本
1 2
| dnf install -y python3-dnf-plugin-versionlock dnf versionlock add erlang rabbitmq-server
|
开启服务
1 2 3 4 5 6
| systemctl enable --now rabbitmq-server systemctl enable --now firewalld.service firewall-cmd --permanent --add-port={15672/tcp,5672/tcp} firewall-cmd --reload
rabbitmq-plugins enable rabbitmq_management
|
基础设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| # 添加用户 rabbitmqctl add_user rabbitmq password # 变更强密码 rabbitmqctl change_password rabbitmq QQ2211~~ # 添加虚拟主机 rabbitmqctl add_vhost /rabbitmq # 设置权限 rabbitmqctl set_permissions -p /rabbitmq rabbitmq ".*" ".*" ".*" rabbitmqctl set_user_tags rabbitmq administrator
# 查看用户全新 rabbitmqadmin list users +----------+--------------------------------+--------------------------------------------------+---------------+ | name | hashing_algorithm | password_hash | tags | +----------+--------------------------------+--------------------------------------------------+---------------+ | guest | rabbit_password_hashing_sha256 | nFhfYd5VXZh1GQnHUgCi0zEmdWoGyl772lz6LiLCrKP9C0fy | administrator | | rabbitmq | rabbit_password_hashing_sha256 | mUtXjrNVYv4/RlKtZ+tcKom/GLDj+d+u0kKTxEvJeCBWjRcz | administrator | +----------+--------------------------------+--------------------------------------------------+---------------+ # 查看虚拟主机 rabbitmqadmin list vhosts +-----------+----------+ | name | messages | +-----------+----------+ | / | | | /rabbitmq | | +-----------+----------+
|
Web管理
- 登录
2. 界面