Erlang和RabbitMQ的部署

Erlang和RabbitMQ的部署

1 erlang环境的部署

RabbitMQ依赖Erlang, 所以需要先安装Erlang

1.1 下载erlang安装包

官网:https://www.erlang.org/
官网下载比较慢,推荐使用百度云下载

1.2 安装erlang

(1)解压安装包:

tar -zxf otp_src_22.3.tar.gz
mv otp_src_22.3 erlang

(2)创建安装目录:mkdir /usr/local/erlang

(3)解决依赖

 yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel

(4)进入erlang目录并编译:

 cd  /root/erlang
 ./configure --prefix=/usr/local/erlang
  • 编译过程中遇到下面的问题可以忽略

Erlang和RabbitMQ的部署(5)安装erlang:make install

Erlang和RabbitMQ的部署Erlang和RabbitMQ的部署(6)配置环境变量

echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
source /etc/profile  ## 是更改的配置生效

(7)验证erlang是否安装成功

[root@server1 erlang]# erl  ##验证是否安装成功
Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [hipe]

Eshell V10.7  (abort with ^G)
1> halt().  ##退出
[root@server1 erlang]# 

2 RabbitMQ的安装

2.1 Erlang和RabbitMQ版本的对应

查询最新版本对应关系:https://www.rabbitmq.com/which-erlang.html
Erlang和RabbitMQ的部署

主机 Erlang Rabbitmq
server1 22.3 3.8.15
server2 22.3 3.8.15

2.2 下载RabbitMQ

下载RabbitMQ的rpm安装包

2.3 RabbitMQ的部署

(1)解决依赖并安装rabbitmq

yum -y install epel-release
yum -y install socat
rpm -ivh --nodeps --force  rabbitmq-server-3.8.15-1.el7.noarch.rpm ##忽略依赖安装

Erlang和RabbitMQ的部署
Erlang和RabbitMQ的部署

  • rabbitmq安装成功

Erlang和RabbitMQ的部署

(2)启动RabbitMQ:service rabbitmq-server star
Erlang和RabbitMQ的部署

出错原因:

/usr/lib/rabbitmq/bin/rabbitmq-server: line 82: exec: erl: not found
/usr/lib/rabbitmq/bin/rabbitmq-env: line 189: exec: erl: not found

Erlang和RabbitMQ的部署

根据提示解决错误:

  • 添加erlang环境变量:vim /usr/lib/rabbitmq/bin/rabbitmq-server
 export PATH=$PATH:/usr/local/erlang/bin

Erlang和RabbitMQ的部署

  • 添加erlang环境变量:vim /usr/lib/rabbitmq/bin/rabbitmq-env
export PATH=$PATH:/usr/local/erlang/bin

Erlang和RabbitMQ的部署重启rabbitmq,出错解决

service rabbitmq-server restart
service rabbitmq-server status
service rabbitmq-server enable

Erlang和RabbitMQ的部署
(3)查看rabbitmq的进程:ps -ef | grep rabbitmq

  • 查看rabbitmq的监听端口是否开启: netstat -anplt | grep 5672

Erlang和RabbitMQ的部署

(4)开启web管理接口:rabbitmq-plugins enable rabbitmq_management

[root@server1 ~]# netstat -anplt | grep 15672
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      12386/beam.smp      
  • 在浏览器验证:
http://172.25.12.1:15672/

Erlang和RabbitMQ的部署
(5)列出rabbitmq的用户:

rabbitmqctl list_users

Erlang和RabbitMQ的部署

(6)解决rabbitmq默认用户guest无法登录"User can only log in via localhost"问题

Erlang和RabbitMQ的部署

vim /etc/rabbitmq/rabbitmq.conf
loopback_users = none
  • 重启服务:service rabbitmq-server restart ,默认的guest用户可以登陆,默认密码也是guest

Erlang和RabbitMQ的部署

上一篇:win10安装rabbitmq流程


下一篇:Erlang日志打印写入文件&映射tomcat