由于rabbitmq是基于erlang语言开发的,所以必须先安装erlang。
==> Erlang和RabbitMQ的版本对应关系
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel
wget
下载Erlang OTP或通过【官网下载地址|otp仓库地址】下载后上传到服务器wget http://erlang.org/download/otp_src_22.0.tar.gz
tar -zxvf otp_src_22.0.tar.gz
mv otp_src_22.0 /usr/local/
cd /usr/local/otp_src_22.0/
mkdir ../erlang
./otp_build: line 319: autoconf: command not found
,需要yum install -y autoconf
)./otp_build autoconf
./configure --prefix=/usr/local/erlang
如果遇到这个错 就假装没看到
make install
ll /usr/local/erlang/bin
echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
如果在进行
configure
命令的时候没有配置添加prefix
则默认安装在/usr/local/lib/erlang/bin
source /etc/profile
erl
试运行,成功则输入halt().
命令退出来(点号别忘记) curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
#默认安装最新
yum install -y erlang
#制定云存储库中的rpm包
yum install erlang-23.0.3-1.el7.x86_64
wget
下载wget --content-disposition https://packagecloud.io/rabbitmq/erlang/packages/el/7/erlang-23.0.3-1.el7.x86_64.rpm/download.rpm
新老版本都有
- Erlang官网软件包:https://www.erlang-solutions.com/resources/download.html
- github仓库地址:https://github.com/rabbitmq/erlang-rpm/tree/v23.0.3
- github下载地址(推荐):https://github.com/rabbitmq/erlang-rpm/releases
- package cloud地址(推荐):https://packagecloud.io/rabbitmq/erlang
- Bintray 地址:https://bintray.com/rabbitmq-erlang/rpm/erlang
旧版本
- RabbitMQ官网的Release仓库:https://www.rabbitmq.com/releases/erlang/
- 国内地址:https://zysd-shanghai.oss-cn-shanghai.aliyuncs.com/software/linux/erlang/erlang-21.1-1.el7.centos.x86_64.rpm
rpm -ivh erlang-23.0.3-1.el7.x86_64.rpm
wget
下载或通过【GitHub开源仓库】下载后上传到服务器(noarch为适用所有CPU)wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.15/rabbitmq-server-generic-unix-3.7.15.tar.xz
- 第一次解压(由于是tar.xz格式的所以需要用到xz,没有的话就先安装 `yum install -y xz`)
/bin/xz -d rabbitmq-server-generic-unix-3.8.5.tar.xz
tar -xvf rabbitmq-server-generic-unix-3.8.5.tar
# 移动到/usr/local/目录下(注意要移动的文件夹后就不在加'/')移动到同级local文件下(新文件要加'/')
mv rabbitmq_server-3.8.5/ /usr/local/
# 改名为rabbitmq
mv /usr/local/rabbitmq_server-3.8.5 /usr/local/rabbitmq
echo 'export PATH=$PATH:/usr/local/rabbitmq/sbin' >> /etc/profile
source /etc/profile
mkdir /etc/rabbitmq
1、先导入两个key,没报错就表示正常。
# Package Cloud signs distributed packages using their own GPG keys. As of late 2018 Package Cloud is undergoing a signing key migration. Instead of relying on a "master key", projects will migrate to use repository-specific signing keys. Before the migration is completed, both old and new key must be imported for forward compatibility:
# 包云使用它们自己的GPG密钥对分布式包进行签名。到2018年底,包云正在进行签名密钥迁移。项目将迁移到使用存储库特定的签名键,而不是依赖于“主键”。在迁移完成之前,为了向前兼容,必须同时导入新旧密钥:
# import the new PackageCloud key that will be used starting December 1st, 2018 (GMT)
# 导入将于2018年12月1日起使用的新PackageCloud密钥(GMT)
rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
# import the old PackageCloud key that will be discontinued on December 1st, 2018 (GMT)
# 进口将于2018年12月1日停产的旧PackageCloud密钥
rpm --import https://packagecloud.io/gpg.key
2、完成RabbitMQ的前置条件配置 ==>执行云存储库快速脚本
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
3、下载RabbitMQ的RPM安装包
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.5/rabbitmq-server-3.8.5-1.el7.noarch.rpm
wget --content-disposition https://packagecloud.io/rabbitmq/rabbitmq-server/packages/el/7/rabbitmq-server-3.8.5-1.el7.noarch.rpm/download.rpm
**RabbitMQ官网安装文档:**https://www.rabbitmq.com/download.html(根据需要点击右侧的In This Section或看主文档)
GitHub仓库地址(推荐):https://github.com/rabbitmq/rabbitmq-server/releases/
package cloud地址(推荐):https://packagecloud.io/rabbitmq
Bintray 地址:https://dl.bintray.com/rabbitmq/all/rabbitmq-server/
RabbitMQ官网的Release仓库:https://www.rabbitmq.com/releases/rabbitmq-server/
国内地址:https://zysd-shanghai.oss-cn-shanghai.aliyuncs.com/software/linux/rabbitmq/rabbitmq-server-3.7.8-1.el7.noarch.rpm
4、下载成功后,上传到服务器,然后使用命名安装。(二选一)
rpm -ivh rabbitmq-server-3.8.5-1.el7.noarch.rpm
yum install rabbitmq-server-3.8.5-1.el7.noarch.rpm
5、查找rabbitmq
whereis rabbitmq
6、列出rabbitmq执行文件
ll /usr/sbin/ | grep 'rabbit'
# 方法一
rabbitmq-server -detached
# 方法二
systemctl start rabbitmq-server
service rabbitmq-server start
rabbitmqctl stop
rabbitmqctl status
- 如果出现这样的问题,则说明rabbitmq还未完全启动
- 未启动则提示:
Error: unable to connect to node rabbit@wangzaiplus: nodedown
5672
和15672
等问题ps -ef | grep rabbitmq
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins disable rabbitmq_management
rabbitmq-plugins list
5672
15672
25672
4369
rabbitmqctl list_users
rabbitmqctl add_user zhaobl 123456
rabbitmqctl set_permissions -p "/" zhaobl ".*" ".*" ".*"
rabbitmqctl list_user_permissions zhaobl
administrator,monitoring,management
)rabbitmqctl set_user_tags zhaobl administrator
rabbitmqctl delete_user guest
systemctl restart rabbitmq-server
设置开机自启
chkconfig rabbitmq-server on
systemctl enable rabbitmq-server.service
为了让 guest 用户能够远程访问
- 方法一:新建配置文件配置
loopback_users
即可(rabbitmq.config配置文件需手动创建), 步骤如下:
cd /etc/rabbitmq
# 新建配置文件
touch rabbitmq.config
vim rabbitmq.config
#写入并保存
[{
rabbit, [{
loopback_users, []}]}].
#重启服务
service rabbitmq-server restart
#重新以guest登录, OK
- 方法二:把
/usr/share/doc/rabbitmq-server-3.7.15/rabbitmq.config.example
拷贝到/etc/rabbitmq/
下并且重命名,去掉后缀.example
就行,移除前面的 %% 代表注释 以及 最后的 逗号,这个是代表运行 guest 默认用户可以在非本地环境登录
%% The default "guest" user is only permitted to access the server
%% via a loopback interface (e.g. localhost).
%% {loopback_users, [<<"guest">>]},
%%
%% Uncomment the following line if you want to allow access to the
%% guest user from anywhere on the network.
%%{loopback_users, []},
修改为
%% The default "guest" user is only permitted to access the server
%% via a loopback interface (e.g. localhost).
%% {loopback_users, [<<"guest">>]},
%%
%% Uncomment the following line if you want to allow access to the
%% guest user from anywhere on the network.
{loopback_users, []}
[ ]:https://www.cnblogs.com/fengyumeng/p/11133924.html
[ ]: https://blog.csdn.net/weixin_40584261/article/details/106826044
[ ]:https://blog.csdn.net/yisangwu/article/details/107715240
[ ]:https://www.jianshu.com/p/ee9f7594212b
[ ]:https://blog.csdn.net/qq_31803503/article/details/94009837
已经安装了Erlang varsion21.3 但还是报这个错误,这个时候可以使用命令
++rpm -ivh --nodeps rabbitmq-server-3.5.7-1.noarch.rpm++
详情:stackoverflow
–nodeps
就是安装时不检查依赖关系,比如你这个rpm需要A,但是你没装A,这样你的包就装不上,用了–nodeps你就能装上了。
–force
就是强制安装,比如你装过这个rpm的版本1,如果你想装这个rpm的版本2,就需要用–force强制安装
yum
出现以下问题:通过erl查看,发现已经安装了21.0的erl,这时需要重新安装最新的erlang
1.手动配置erlang的repo源
vi /etc/yum.repos.d/rabbitmq-erlang.repo
在文件中加入以下内容:# In /etc/yum.repos.d/rabbitmq-erlang.repo [rabbitmq-erlang] name=rabbitmq-erlang baseurl=https://dl.bintray.com/rabbitmq/rpm/erlang/20/el/7 gpgcheck=1 gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc repo_gpgcheck=0 enabled=1
2.清理rpm文件缓存
yum clean all yum makecache
3.查看已有的源文件
yum list |grep erlang
此时发现有一个21.3的文件可以用,我们就安装这个文件yum install erlang.x86_64
完成后继续执行
yum install rabbitmq-server-3.7.18-1.el7.noarch.rpm
提示成功
journalctl -ex
,查看到有报如下信息的时候1.这时候用
rabbitmqctl status
查看一下,如果有错误的话会显示如下信息2.这时候要第一行的红色圈起来的字直接用
echo 192.168.174.131 rabbitmq>>/etc/hosts
其中的IP是服务器的IP,写入后的效果如下3.这时候再重启一下Rabbitmq,就可以快速启动了,启动完后再用,这时候用 rabbitmqctl status查看一下,这时候就会显示正确的信息了