CentOS7下使用rpm安装RabbitMQ

CentOS下安装RabbitMQ

安装Erlang

1.安装依赖环境

yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixODBC-devel

2.下载Erlang

wget http://erlang.org/download/otp_src_21.3.tar.gz

3.解压&&构建

# 解压
tar -xvzf otp_src_21.0.tar.gz

# 进入解压后的Erlang目录
cd otp_src_21.3

# 构建
./otp_build autoconf
# 如果出现 ./otp_build: line 319: autoconf: command not found ,需要yum install -y autoconf

4.配置安装

./configure
make
make install

7.配置环境变量

vim /etc/profile

# 末尾添加
export ERLANG_HOME=/usr/local/lib/erlang
export PATH=$PATH:$ERLANG_HOME/bin

# 重新加载环境变量
source /etc/profile

# 查看版本号
erl

安装RabbitMQ

1.下载RabbitMQ

RabbitMQ-server-3.7.15

wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.15/rabbitmq-server-3.7.15-1.el7.noarch.rpm

2.导入相关的秘钥

# 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

3.执行云存储库快速脚本

详情可到 云存储库https://packagecloud.io/rabbitmq/rabbitmq-server/install#bash-rpm

# quick install  快速安装
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

以下提示安装成功:

Complete!
Generating yum cache for rabbitmq_rabbitmq-server...
Importing GPG key 0x4D206F89:
 Userid     : "https://packagecloud.io/rabbitmq/rabbitmq-server (https://packagecloud.io/docs#gpg_signing) "
 Fingerprint: 8c69 5b02 19af deb0 4a05 8ed8 f4e7 8920 4d20 6f89
 From       : https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
Generating yum cache for rabbitmq_rabbitmq-server-source...

The repository is setup! You can now install packages.

4.安装RabbitMQ

# 安装
rpm -ivh rabbitmq-server-3.7.15-1.el7.noarch.rpm

遇到错误:

[root@haha installed]# rpm -ivh rabbitmq-server-3.7.15-1.el7.noarch.rpm 
error: Failed dependencies:
        erlang >= 20.3 is needed by rabbitmq-server-3.7.15-1.el7.noarch
        socat is needed by rabbitmq-server-3.7.15-1.el7.noarch

解决方式:

  1. erlang >= 20.3 is needed by rabbitmq-server-3.7.15-1.el7.noarch 问题

我已经安装了Erlang varsion21.3 了,还是给我报这个错误,这个时候可以使用 ++rpm -ivh --nodeps rabbitmq-server-3.5.7-1.noarch.rpm++ 命令。详情:stackoverflow

  1. socat is needed by rabbitmq-server-3.7.15-1.el7.noarch 问题

yum install socat

成功后:

[root@haha installed]# rpm -ivh --nodeps rabbitmq-server-3.7.15-1.el7.noarch.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:rabbitmq-server-3.7.15-1.el7     ################################# [100%]
[root@haha installed]# 


[root@haha installed]# cd /etc/rabbitmq/
[root@haha rabbitmq]# ls
[root@haha rabbitmq]# cd ..
[root@haha etc]# cd /usr/share/doc/rabbitmq-server-3.7.15/
[root@haha rabbitmq-server-3.7.15]# ls
LICENSE                         LICENSE-ISC-cowboy           LICENSE-MIT-Sammy060
LICENSE-APACHE2                 LICENSE-MIT-EJS              LICENSE-MPL2
LICENSE-APACHE2-excanvas        LICENSE-MIT-EJS10            LICENSE-MPL-RabbitMQ
LICENSE-APACHE2-ExplorerCanvas  LICENSE-MIT-Erlware-Commons  LICENSE-rabbitmq_aws
LICENSE-APL2-Stomp-Websocket    LICENSE-MIT-Flot             rabbitmq.config.example
LICENSE-BSD-base64js            LICENSE-MIT-jQuery           README
LICENSE-BSD-recon               LICENSE-MIT-jQuery164        set_rabbitmq_policy.sh.example
LICENSE-erlcloud                LICENSE-MIT-Mochi
LICENSE-httpc_aws               LICENSE-MIT-Sammy
[root@haha rabbitmq-server-3.7.15]#
  • –nodeps就是安装时不检查依赖关系,比如你这个rpm需要A,但是你没装A,这样你的包就装不上,用了–nodeps你就能装上了。
  • –force就是强制安装,比如你装过这个rpm的版本1,如果你想装这个rpm的版本2,就需要用–force强制安装

5.然后来配置一下rabbitmq才能正式使用

把/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, []}

6.安装后相关配置

# 开机启动
systemctl enable rabbitmq-server.service

# WEB插件
rabbitmq-plugins enable rabbitmq_management

7.到此配置全部结束,最后一步就是启动rabbitmq server了

# 启动
service rabbitmq-server start
# 停止
service rabbitmq-server stop
# 重新启动
service rabbitmq-server restart

访问地址:http://127.0.0.1:15672/

6.配置文件位置

home dir : /var/lib/rabbitmq
/etc/rabbitmq/advanced.config 
/etc/rabbitmq/rabbitmq.conf

你可能感兴趣的:(RabbitMQ)