安装环境: Alibaba Cloud Linux
安装erlang命令:
rpm --import https://packages.erlang-solutions.com/rpm/erlang_solutions.asc
yum install erlang -y
查看erl版本命令:
erl -version
查看具体erl的版本命令:
erl
会出现以下信息:
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe] Eshell V10.4.4 (abort with ^G)
将看到Erlang/OTP 22这样一行信息,说明erlang版本为Erlang/OTP 22
然后通过 https://www.rabbitmq.com/which-erlang.html 找到对应兼容rabbitmq的版本号,然后选择版本进行下载rabbitmq,我这边下载的rabbmit版本号为3.8.3
下载rabbitmq命令:
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.3/rabbitmq-server-3.8.3-1.el7.noarch.rpm
安装rabbitmq命令:
yum install -y rabbitmq-server-3.8.3-1.el7.noarch.rpm
启动rabbitmq命令:
rabbitmqctl start_app
开启rabbitmq界面管理命令:
rabbitmq-plugins enable rabbitmq_management
添加新用户命令(第一个admin为账户名,第二个admin为密码):
rabbitmqctl add_user admin admin
给admin用户添加标签命令:
rabbitmqctl set_user_tags admin administrator
给admin用户授权命令:
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
关闭rabbitmq命令:
rabbitmqctl stop
开启rabbitmq命令:
rabbitmqctl start_app
阿里云服务器需注意开启端口,设置安全组
15672、5672
设置完成,重启阿里云服务器即可
浏览器地址输入 http://阿里云服务器公网ip:15672
输入之前创建的用户名和密码(admin/admin),就可以看到rabbitmq的管理界面了。
ps:
如果想卸载erlang版本就输入:
rpm -qa | grep erlang | xargs rpm -e --nodeps
另外我在另外一台服务器按照这个步骤安装的时候,发现执行
rabbitmqctl start_app
启动rabbitmq的命令时候,会出现以下异常:
Error: unable to perform an operation on node 'rabbit@iZbp138tf0alwpZ'. Please see diagnostics information and suggestions below. Most common reasons for this are: * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues) * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server) * Target node is not running In addition to the diagnostics info below: * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more * Consult server logs on node rabbit@iZbp138tf0alwpZ * If target node is configured to use long node names, don't forget to use --longnames with CLI tools DIAGNOSTICS =========== attempted to contact: [rabbit@iZbp138tf0alwpZ] rabbit@iZbp138tf0alwpZ: * connected to epmd (port 4369) on iZbp138tf0alwpZ * epmd reports: node 'rabbit' not running at all no other nodes on iZbp138tf0alwpZ * suggestion: start the node Current node details: * node name: 'rabbitmqcli-1180384-rabbit@iZbp138tf0alwpZ' * effective user's home directory: /var/lib/rabbitmq * Erlang cookie hash: PH2aegzBB8pInmMp3ar8Jg==
根据上述信息,翻阅资料,最后执行
echo 192.168.1.101 iZbp138tf0alwpZ>>/etc/hosts
192.168.1.101 为服务器IP
iZbp138tf0alwpZ 为服务器主机名,也是上述错误信息rabbit@iZbp138tf0alwpZ中后面一截字符串
意思就是把服务器IP和主机名写入到host文件,这样就可以解析成功。
然后继续执行,重启rabbitmq服务
service rabbitmq-server restart
接着上面的 开启rabbitmq界面管理命令 步骤继续执行即可。