erlang下载地址:https://www.erlang-solutions.com/resources/download.html
rabbitMQ下载地址:https://github.com/rabbitmq/rabbitmq-server/releases
rabbitmq和erlang的版本匹配:https://www.rabbitmq.com/which-erlang.html
2.1、需要下载的软件
2.2、安装erlang
//安装erlang
rpm -ivh erlang-22.0.7-1.el6.x86_64.rpm
//查看是否安装成功
rpm -qa | grep erlang
安装过程
[root@waggag soft]# ll
total 29168
-rw-r--r--. 1 root root 19425952 Aug 28 22:38 erlang-22.0.7-1.el6.x86_64.rpm
-rw-r--r--. 1 root root 10437791 Aug 28 22:38 rabbitmq-server-3.7.17-1.el6.noarch.rpm
[root@waggag soft]# rpm -ivh erlang-22.0.7-1.el6.x86_64.rpm
warning: erlang-22.0.7-1.el6.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ########################################### [100%]
1:erlang ########################################### [100%]
[root@waggag soft]# rpm -qa | grep erlang
erlang-22.0.7-1.el6.x86_64
2.3、安装RabbitMQ所需的依赖
[root@waggag soft]# rpm -ivh rabbitmq-server-3.7.17-1.el6.noarch.rpm
warning: rabbitmq-server-3.7.17-1.el6.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
socat is needed by rabbitmq-server-3.7.17-1.el6.noarch
报错显示需要依赖socat,我们先来安装scoat,直接使用yum安装
[root@waggag soft]# yum install socat
Loaded plugins: fastestmirror
Setting up Install Process
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:01
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.7 MB 00:09
No package socat available.
Error: Nothing to do
发现yum无法直接查找到scoat的依赖,一般都是因为无法找到epel的依赖。
//安装扩展源
yum install epel-release
//安装socat
yum install socat
安装过程:
[root@waggag soft]# yum install epel-release
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
* base: mirror.bit.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================
Package Arch Version Repository Size
=================================================================================================================
Installing:
epel-release noarch 6-8 extras 14 k
Transaction Summary
=================================================================================================================
Install 1 Package(s)
Total download size: 14 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
epel-release-6-8.noarch.rpm | 14 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key)
Package: centos-release-6-10.el6.centos.12.3.x86_64 (@anaconda-CentOS-201806291108.x86_64/6.10)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : epel-release-6-8.noarch 1/1
Verifying : epel-release-6-8.noarch 1/1
Installed:
epel-release.noarch 0:6-8
Complete!
[root@waggag soft]# yum install socat
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink | 6.4 kB 00:00
* base: mirror.bit.edu.cn
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.aliyun.com
epel | 5.3 kB 00:00
epel/primary_db | 6.1 MB 00:01
Resolving Dependencies
--> Running transaction check
---> Package socat.x86_64 0:1.7.2.3-1.el6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: socat-1.7.2.3-1.el6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================
Package Arch Version Repository Size
=================================================================================================================
Installing:
socat x86_64 1.7.2.3-1.el6 epel 246 k
Installing for dependencies:
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
Transaction Summary
=================================================================================================================
Install 2 Package(s)
Total download size: 375 k
Installed size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): compat-readline5-5.2-17.1.el6.x86_64.rpm | 130 kB 00:00
(2/2): socat-1.7.2.3-1.el6.x86_64.rpm | 246 kB 00:00
-----------------------------------------------------------------------------------------------------------------
Total 364 kB/s | 375 kB 00:01
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid : EPEL (6)
Package: epel-release-6-8.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : compat-readline5-5.2-17.1.el6.x86_64 1/2
Installing : socat-1.7.2.3-1.el6.x86_64 2/2
Verifying : socat-1.7.2.3-1.el6.x86_64 1/2
Verifying : compat-readline5-5.2-17.1.el6.x86_64 2/2
Installed:
socat.x86_64 0:1.7.2.3-1.el6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6
Complete!
[root@waggag soft]#
2.4、安装RabbitMQ
rpm -ivh rabbitmq-server-3.7.17-1.el6.noarch.rpm
//安装过程
[root@waggag soft]# rpm -ivh rabbitmq-server-3.7.17-1.el6.noarch.rpm
warning: rabbitmq-server-3.7.17-1.el6.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
Preparing... ########################################### [100%]
1:rabbitmq-server ########################################### [100%]
2.5、开启Web管理界面
//开启管理页面插件
rabbitmq-plugins enable rabbitmq_management
//重启RabbitMQ
service rabbitmq-server restart
//安装过程
[root@waggag soft]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@waggag:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@waggag...
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.
//重启服务
service rabbitmq-server restart
2.6、打开本地浏览器访问http://localhost:15672/会出现登陆界面。
默认的登录用户和密码都是:guest
2.7、CentOS6特有的操作
2.7.1、服务的开启与关闭
service rabbitmq-server status //查看状态
service rabbitmq-server start //开启服务
service rabbitmq-server restart //重启服务
service rabbitmq-server stop //关闭服务
2.7.2、添加开机启动
chkconfig rabbitmq-server on //开启开机自启服务
chkconfig rabbitmq-server off //关闭开机自启服务
chkconfig --list //查看所有开启自启服务
2.7.3、配置防火墙,开启指定端口
/sbin/iptables -I INPUT -p tcp --dport 15672 -j ACCEPT //开启15672端口
/etc/rc.d/init.d/iptables save //保存防火墙配置
//重启防火墙
service iptables reatart
//开启防火墙
service iptables start
//关闭防火墙
service iptables stop
具体依赖的安装前面都说了,接下来简单的安装下,讲些CentOS7特别需要注意的。
3.1、需要下载的软件
3.2、安装erlang
rpm -ivh erlang-22.0.7-1.el7.x86_64.rpm
3.3、安装所需的依赖(一定要按先后顺序安装,否则socat找不到依赖)
//安装扩展源
yum install epel-release
//安装socat
yum install socat
3.4、安装RabbitMQ
rpm -ivh rabbitmq-server-3.7.17-1.el7.noarch.rpm
3.5、开启RabbitMQ的Web界面
//开启rabbitmq的管理界面
rabbitmq-plugins enable rabbitmq_management
//重启服务
systemctl start rabbitmq-server
3.6、重启服务,本地浏览器访问localhost:15672
3.7、CentOS7特有操作
3.7.1、服务的开启与关闭
systemctl start rabbitmq-server //开启服务
systemctl stop rabbitmq-server //关闭服务
systemctl restart rabbitmq-server //重启服务
systemctl reload rabbitmq-server //重新加载配置文件
systemctl status rabbitmq-server //查看服务状态
3.7.2、添加开机自启
systemctl enable rabbitmq-server //开启RabbitMQ开机自启
systemctl disenable rabbitmq-server //关闭RabbitMQ开机自启
3.7.3、配置防火墙,开启指定端口
//开启15672端口
firewall-cmd --zone=public --add-port=15672/tcp --permanent
//重启防火墙
systemctl restart firewalld
四、RabbitMQ远程访问
4.1、RabbitMQ的远程访问问题
远程访问的问题,RabbitMQ从3.3.0开始禁止使用guest/guest权限通过除localhost外的访问。
4.2、配置RabbitMQ的远程访问
4.2.1、将配置文件模板复制到etc目录
cp /usr/share/doc/rabbitmq-server-3.7.17/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
4.2.2、修改rabbitmq.config
vi /etc/rabbitmq/rabbitmq.config
4.2.3、修改限制访问的用户
将 %% {loopback_users, [<<"guest">>]},
修改为
{loopback_users, []}