在CentOS 7 Fedora 32/31/30上安装Erlang和RabbitMQ。
时间:2020-02-23 14:31:21 来源:igfitidea点击:
在这篇博文中,我将带我们逐步了解如何在CentOS 7上安装Erlang和RabbitMQ。 Fedora 32/31/30/29. RabbitMQ是实现高级消息队列协议(AMQP)的开源消息代理软件。它从发布者(发布它们的应用程序)接收消息,并将其路由到使用者(处理它们的应用程序)。
在CentOS 7 Fedora 32/31/30上安装Erlang
在安装RabbitMQ之前,必须安装受支持的Erlang/OTP版本。
添加YUM存储库:
sudo tee /etc/yum.repos.d/rabbitmq_erlang.repo<<EOF [rabbitmq_erlang] name=rabbitmq_erlang baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/x86_64 repo_gpgcheck=1 gpgcheck=1 enabled=1 # PackageCloud's repository key and RabbitMQ package signing key gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 [rabbitmq_erlang-source] name=rabbitmq_erlang-source baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS repo_gpgcheck=1 gpgcheck=0 enabled=1 # PackageCloud's repository key and RabbitMQ package signing key gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 EOF
安装Erlang:
sudo dnf -y install erlang
通过运行erl
命令确认安装:
$erl Erlang/OTP 23 [erts-11.0.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe] Eshell V11.0.4 (abort with ^G) 1>
第2步:添加PackageCloud RabbitMQ Yum存储库
PackageCloud可提供带有RabbitMQ软件包的Yum存储库。
为RabbitMQ创建一个新的存储库文件。
sudo tee /etc/yum.repos.d/rabbitmq_rabbitmq-server.repo<<EOF [rabbitmq_rabbitmq-server] name=rabbitmq_rabbitmq-server baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/x86_64 repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 [rabbitmq_rabbitmq-server-source] name=rabbitmq_rabbitmq-server-source baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 EOF
在CentOS 7 Fedora 32/31/30上安装RabbitMQ
最后一步是RabbitMQ的实际安装:
sudo yum install rabbitmq-server
确认安装的RabbitMQ版本:
$rpm -qi rabbitmq-server Name : rabbitmq-server Version : 3.8.8 Release : 1.el7 Architecture: noarch Install Date: Tue 22 Sep 2017 10:10:52 PM UTC Group : Development/Libraries Size : 16056314 License : MPLv2.0 and MIT and ASL 2.0 and BSD Signature : RSA/SHA256, Thu 03 Sep 2017 05:23:01 PM UTC, Key ID 6b73a36e6026dfca Source RPM : rabbitmq-server-3.8.8-1.el7.src.rpm Build Date : Thu 03 Sep 2017 05:22:59 PM UTC Build Host : 6a1ce918-e5fc-4f1f-6ad7-01a6fb206d97 Relocations : (not relocatable) URL : https://www.rabbitmq.com/ Summary : The RabbitMQ server Description : RabbitMQ is an open source multi-protocol messaging broker.
启动RabbitMQ服务
现在,我们已经在Fedora上安装了RabbitMQ,启动并启用该服务以在系统启动时启动:
sudo systemctl start rabbitmq-server sudo systemctl enable rabbitmq-server
启用RabbitMQ管理仪表板(可选)
我们可以选择启用RabbitMQ管理Web仪表板以便于管理:
sudo rabbitmq-plugins enable rabbitmq_management
Web服务应在TCP端口15672上侦听
# ss -tunelp | grep 15672 tcp LISTEN 0 128 0.0.0.0:15672 0.0.0.0:* users:(("beam.smp",pid=9525,fd=71)) uid:111 ino:39934 sk:9 <->
如果我们有活动的防火墙服务,请允许端口" 5672"和" 15672":
sudo firewall-cmd --add-port={5672,15672}/tcp --permanent sudo firewall-cmd --reload
通过打开服务器IP或者主机名端口15672对其进行访问。
默认情况下,guestuser存在,并且只能从localhost连接。我们可以使用密码guest在本地用该用户登录
为了能够在网络上登录,请创建一个如下的管理员用户:
sudo rabbitmqctl add_user admin StrongPassword sudo rabbitmqctl set_user_tags admin administrator
使用此管理员用户名和分配的密码登录。
RabbitMQ用户管理命令
删除用户:
rabbitmqctl delete_user user
更改用户密码:
rabbitmqctl change_password user strongpassword
创建新的虚拟主机:
rabbitmqctl add_vhost /my_vhost
列出可用的虚拟主机:
rabbitmqctl list_vhosts
删除虚拟主机:
rabbitmqctl delete_vhost /myvhost
授予用户对vhost的权限:
rabbitmqctl set_permissions -p /myvhost user ".*" ".*" ".*"
列出虚拟主机权限:
rabbitmqctl list_permissions -p /myvhost
列出用户权限:
rabbitmqctl list_user_permissions user
删除用户权限:
rabbitmqctl clear_permissions -p /myvhost user