Centos7.9安装RabbitMQ
一.安装erlang
由于rabbitmq是基于erlang语言开发的,所以必须先安装erlang。
安装依赖
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel
下载(会比较慢,请耐心等待)
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
配置安装路径
./configure --prefix=/usr/local/erlang
安装
make install
查看一下是否安装成功
ll /usr/local/erlang/bin
添加环境变量
echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
刷新环境变量
source /etc/profile
测试erl是否安装成功
erl
瞬间进入了一个未知的世界
在里面输入halt().命令退出来(那个点号别忘记)
二、安装RabbitMQ
1.安装
下载
由于是tar.xz格式的所以需要用到xz,没有的话就先安装
yum install -y xz
第一次解压
/bin/xz -d rabbitmq-server-generic-unix-3.7.15.tar.xz
第二次解压
tar -xvf rabbitmq-server-generic-unix-3.7.15.tar
移走
mv rabbitmq_server-3.7.15/ /usr/local/
改名
mv /usr/local/rabbitmq_server-3.7.15 rabbitmq
配置环境变量
echo 'export PATH=$PATH:/usr/local/rabbitmq/sbin' >> /etc/profile
刷新环境变量
source /etc/profile
2.启动
启动:
rabbitmq-server -detached
停止:
rabbitmqctl stop
状态:
rabbitmqctl status
防火墙之类的请自行处理(5672和15672端口),反正我是从来不开防火墙。
3.web管理
用户管理
查看所有用户
rabbitmqctl list_users
添加一个用户
rabbitmqctl add_user admin admin
配置权限
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
查看用户权限
rabbitmqctl list_user_permissions admin
设置tag
rabbitmqctl set_user_tags admin administrator
删除用户(安全起见,删除默认用户)
rabbitmqctl delete_user guest
配置好后重启rabbitqm,登录后如下图:
设置rabbitmq开机自动启动:
遇到点问题,以后再解决
参考:https://www.cnblogs.com/fengyumeng/p/11133924.html
centos7
第一步:新建yum存储库文件:/etc/yum.repos.d/rabbitmq.repo,安装rabbitmq的时候会来这里找依赖。
cd /etc/yum.repos.d/
vim rabbitmq.repo 内容如下
# In /etc/yum.repos.d/rabbitmq.repo
##
## Zero dependency Erlang
##
[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://github.com/rabbitmq/signing-keys/releases/download/2.0/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
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
##
## RabbitMQ server
##
[rabbitmq_server]
name=rabbitmq_server
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
# PackageCloud's repository key and RabbitMQ package signing key
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
[rabbitmq_server-source]
name=rabbitmq_server-source
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
- 第二步,更新yum
sudo yum update -y
- 第三步,安装 erlang rabbitmq-server
sudo yum install socat logrotate -y
sudo yum install erlang rabbitmq-server -y
设置为开机启动:
systemctl enable rabbitmq-server
启动RabbitMQ:
systemctl start rabbitmq-server
RabbitMQ状态:
rabbitmqctl status
关闭RabbitMQ:
service rabbitmq-server stop
添加admin用户及分配权限
sudo rabbitmqctl add_user admin admin #添加用户 用户名密码都是admin
sudo rabbitmqctl set_user_tags admin administrator #管理员(administrator)权限
sudo rabbitmqctl set_permissions -p "/" admin '.*' '.*' '.*' #设置用户权限
sudo rabbitmqctl list_user_permissions admin #查看用户权限
sudo rabbitmqctl delete_user guest 删除用户
sudo rabbitmqctl list_users 查看所有用户
安装Web管理插件
rabbitmq-plugins enable rabbitmq_management
登录RabbitMQ管理界面
浏览器输入服务器公网IP地址:15672,使用admin/admin登录管理界面