还是要练习看第一手资料,国内的很多博客文档写的一塌糊涂。相对自己在官网上查看,虽然开始慢一点,但是成功率相对看国内博客要高得多。
yum安装rabbitmq-server需要手动安装几个包:
//erl、socat、logrotate
yum -y install socat
1、下载rabbtmq-server
第一次使用rabbitmq,所以需要先安装server。
1、官方文档:https://www.rabbitmq.com/
官网首页宣称:RabbitMQ is the most widely deployed open source message broker.
(吹吹牛B不犯法)。
安装最新版(3.8.11稳定版,不要用beta),找到The Latest Release。https://github.com/rabbitmq/rabbitmq-server/releases
注意:
This release no longer supports Erlang 21.3.
Erlang 21.3 is no longer supported.22.3 or 23.2 releases are recommended.
2、下载页:https://www.rabbitmq.com/download.html
,rabbitmq-server包通过rpm管理
https://www.rabbitmq.com/install-rpm.html#downloads 选择阿里云对应的系统版本
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.11/rabbitmq-server-3.8.11-1.el7.noarch.rpm
2、安装erl
1、rabbitmq是erlang语言写的,所以要先安装环境。有三种安装方式,我们选择一种rabbitmq提供的方案
Before installing RabbitMQ, you must install a supported version of Erlang/OTP. There are three commonly used sources for Erlang packages on RPM-based distributions.
https://github.com/rabbitmq/erlang-rpm提供了解决方案,找到centos7 的通用脚本
# In /etc/yum.repos.d/rabbitmq_erlang.repo
[rabbitmq_erlang]
name=rabbitmq_erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
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
执行脚本yum install erlang
重新安装erl
如果第一次安装失败,需要先卸载之前的安装包
yum list|grep erlang
yum remove erlang*
whereis erlang
rm -rf /usr/lib64/erlang
卸载后,再次执行脚本yum install erlang
安装成功,测试脚本erl
,然后执行halt().
退出
---------至此erl安装完成-----
3、安装rabbitmq-server并启动
同样的,安装rabbitmq-server也由于多种方式,我选择Using Bintray Yum Repository
In order to use the Yum repository, a .repo file (e.g. rabbitmq.repo) has to be added under the /etc/yum.repos.d/ directory.
1、执行rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
2、创建文件/etc/yum.repos.d/rabbitmq.repo
[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1
3、启动(系统重启时自动启动)
chkconfig rabbitmq-server on
/sbin/service rabbitmq-server start
/sbin/service rabbitmq-server stop
4、端口被占用(5672/25672)
netstat -ntlp|grep 25672
kill -9 12312
5、重启
4、安装web管理插件
rabbitmq-plugins enable rabbitmq_management
阿里云开放端口5672/15672即可。
5、管控台权限控制
默认管控台只能通过guest访问本地服务,怎么添加用户并删除guest?
# root权限
rabbitmqctl add_user username pwd //添加用户,后面两个参数分别是用户名和密码
rabbitmqctl set_permissions -p / username ".*" ".*" ".*" //添加权限
rabbitmqctl set_user_tags username administrator //修改用户角色,将用户设为管理员
更多权限操作参考:
https://www.rabbitmq.com/access-control.html
https://www.cnblogs.com/cwp-bg/p/10070467.html