<返回更多

RabbitMQ环境搭建

2021-04-14  今日头条  码农老蒋
加入收藏

RabbitMQ环境搭建

erlang和RabbitMQ版本对应关系:https://www.rabbitmq.com/which-erlang.html

erlang环境安装

yum方式安装

  1. yum源配置

[root@iyeed RabbitMQ]# curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

  1. yum安装erlang

[root@iyeed RabbitMQ]# yum install erlang

  1. 校验erlang安装是否成功
    • 执行erl命令

[root@iyeed ~]# erl
Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Eshell V11.1.8 (abort with ^G)
1>

上面是输入erl命令后显示的信息。

erlErlang/OPT 23:代表的是erlang版本信息,对应的erlang和RabbitMQ对照表中,查找对应的RabbitMQ安装即可

    • erlang输出消息

1> io:format("hello, world!~n").
hello, world!
ok
2>

    • 退出erl命令行

2> halt().

完整操作过程如下:

[root@iyeed ~]# erl
Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Eshell V11.1.8 (abort with ^G)
1> io:format("hello, world!~n").
hello, world!
ok
2> halt().

RabbitMQ安装

导入key

[root@iyeed RabbitMQ]# rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
[root@iyeed RabbitMQ]# rpm --import https://packagecloud.io/gpg.key

以上执行后,没有任何消息反馈,表明导入key成功

安装RabbitMQ的前置配置

[root@iyeed RabbitMQ]# curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

下载RabbitMQ

[root@iyeed RabbitMQ]# wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.14/rabbitmq-server-3.8.14-1.el7.noarch.rpm

安装RabbitMQ

[root@iyeed RabbitMQ]# rpm -ivh rabbitmq-server-3.8.14-1.el7.noarch.rpm
warning: rabbitmq-server-3.8.14-1.el7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
socat is needed by rabbitmq-server-3.8.14-1.el7.noarch

此处安装时产生了一些问题,原因是缺少key,只需要导入key和安装socat即可

  • 导入key

[root@iyeed RabbitMQ]# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc

如执行如下命令后,没有任何输出,则表明导入key成功

  • 安装socat

[root@iyeed RabbitMQ]# yum -y install epel-release
[root@iyeed RabbitMQ]# yum -y install socat

  • 再次执行rabbitmq的安装命令即可

[root@iyeed RabbitMQ]# rpm -ivh rabbitmq-server-3.8.14-1.el7.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.8.14-1.el7 ################################# [100%]

启动 可视化插件 方便管理 rabbitMQ

[root@iyeed RabbitMQ]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@iyeed:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@iyeed...
The following plugins have been enabled:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch

set 3 plugins.
Offline change; changes will take effect at broker restart.

启动RabbitMQ

[root@iyeed RabbitMQ]# systemctl start rabbitmq-server

访问控制台页面

输入http://(服务器地址):15672(本示例:http://192.168.0.31:15672/),此时会出现如下UI画面

RabbitMQ环境搭建

 

如果没有出现 请检查防火墙 配置 确认是否开启端口5672和15672,如果没有开启 则无法访问

用户登录和vhost配置

账号密码默认是guest,此时登录会:

RabbitMQ环境搭建

 

RabbitMQ3.3以后,guest账号只能在本机登录,可以通过配置修改,但是太麻烦,此处就创建一个新的账号:

创建admin用户

如创建用户名为admin,密码为admin123的用户

[root@iyeed ~]# rabbitmqctl add_user admin admin123
Adding user "admin" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.

设置admin为超级管理员

[root@iyeed ~]# rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

授权admin远程访问

[root@iyeed ~]# rabbitmqctl set_permissions -p / admin "." "." ".*"
Setting permissions for user "admin" in vhost "/" ...

创建完成后,重启RabbitMQ

[root@iyeed ~]# systemctl restart rabbitmq-server

此时就完成 rabbitMQ 的安装了 用户的添加 和 权限的配置 也可以在 ui界面中完成

RabbitMQ环境搭建

 

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>