1. 官网
https://www.rabbitmq.com/
2. erlang与rabbitmq版本对应关系
官方网址:https://www.rabbitmq.com/which-erlang.html
3.rpm安装erlang
$ yum install -y epel-release
$ wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm
$ rpm -Uvh erlang-solutions-2.0-1.noarch.rpm
$ yum list erlang
$ yum install -y erlang
$ erl -version
$ rpm -aq | grep erlang
4. 安装socat
$ yum install -y socat
5. 安装rabbitmq
$ wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.4/rabbitmq-server-3.9.4-1.el7.noarch.rpm
$ rpm -ivh rabbitmq-server-3.9.4-1.el7.noarch.rpm
6.rabbitmq常用命令
$ rabbitmq-server -detached
$ rabbitmqctl status
$ systemctl status rabbitmq-server
$ rabbitmqctl start_app
$ systemctl start rabbitmq-server
$ rabbitmqctl restart_vhost
Trying to restart vhost '/' on node 'rabbit@maxwell' ...
Vhost '/' is already running on node 'rabbit@maxwell'
$ systemctl status rabbitmq-server
$
$ rabbitmq-plugins enable rabbitmq_management
$ rabbitmq-plugins list
7. 用户管理
rabbitmqctl list_users
rabbitmqctl set_permissions -p "/" <username> ".*" ".*" ".*"
rabbitmqctl list_user_permissions <username>
rabbitmqctl add_user <username> <password>
rabbitmqctl delete_user <username>
rabbitmqctl change_password <username> <newpassword>
rabbitmqctl clear_password <username>
rabbitmqctl authenticate_user <username> <password>
rabbitmqctl set_user_tags <username> <tag> ...
8. 日志
在安装的时候,每个人会遇到每个人不同的问题,有没有通用的方法解决所有的问题? 多查日志,分析,定位问题,解决问题。
$ journalctl -xe
$ systemctl status rabbitmq-server.service
9.我安装时候遇到的坑
问题描述:根据日志显示,主机名连接超时 原因:我把/etc/hosts文件修改了,ip 主机名 域名没有对应对,导致ping主机名一直平不通,最终也导致rabbimq启动不了, 解决办法:修改/etc/hosts文件,根据自己的ip addr ,改成对的配置。
10. 一键脚本
功能:安装rabbitmq,放开firewall对应端口:5672,15672,25672,设置管理用户Maxwell,密码123456,启动rabbitmq进程。http://ip:15672
#!/bin/bash
blue(){
echo -e "\033[34m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
clear
green "=========================================================="
blue "支持:centos7+"
blue "网站:https://blog.csdn.net/qq_40016729/article/details/119823995 "
blue "作者:\033[5mMaxwell\033[0m "
green "=========================================================="
red "简介:本脚本为Rabbitmq安装,转载请注明出处!"
green "=========================================================="
read -s -n1 -p "若同意上述协议,请按任意键继续 ... "
echo
set -x
yum install -y epel-release
wget https://packages.erlang-solutions.com/erlang-solutions-2.0-1.noarch.rpm
rpm -Uvh erlang-solutions-2.0-1.noarch.rpm
yum install -y erlang
yum install -y socat
firewall-cmd --permanent --add-port=5672/tcp
firewall-cmd --permanent --add-port=15672/tcp
firewall-cmd --permanent --add-port=25672/tcp
firewall-cmd --reload
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.4/rabbitmq-server-3.9.4-1.el7.noarch.rpm
rpm -ivh rabbitmq-server-3.9.4-1.el7.noarch.rpm
systemctl start rabbitmq-server
systemctl status rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user Maxwell 123456
rabbitmqctl set_user_tags Maxwell administrator
rabbitmqctl set_permissions -p "/" Maxwell ".*" ".*" ".*"
rabbitmqctl delete_user guest
systemctl restart rabbitmq-server
rm -f rabbitmq-server-3.9.4-1.el7.noarch.rpm erlang-solutions-2.0-1.noarch.rpm
rabbitmqctl status
set +x
IP=`ip addr | grep inet | egrep 'ens|eth0' | awk '{print $2}' | sed 's/...$//'`
green "URL:http://${IP}:15672"
green "Rabbitmq后台管理,用户:\033[5mMaxwell\033[0m\033[32m\033[01m,密码:123456\033[0m"
脚本运行结果
10. 祝你学习成长愉快
talk less,do more!
|