解决Rabbitmq启动报“line 80: erl: command not found”
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决Rabbitmq启动报“line 80: erl: command not found”相关的知识,希望对你有一定的参考价值。
问题描述:
部署一套新环境,因为该环境的机器规定不能连外网,rabbitmq采用离线部署的方式。
将本地yum下载的rabbitmq所需rpm包手动上传到该环境的机器离线部署。所有的rpm包都和本地在线安装都是一样的,本地测试机上部署和启动正常,但是在新环境机器上启动rabbitmq的时候出现了“/usr/lib/rabbitmq/bin/rabbitmq-server: line 80: erl: command not found”的报错。报错信息如下:
[[email protected] ~]# rabbitmq-server
/usr/lib/rabbitmq/bin/rabbitmq-server: line 80: erl: command not found
[[email protected] ~]#
分析过程:
1、根据报错说“erl: command not found”,就单独执行了一下erl,发现并没有什么问题:
[[email protected] ~]# erl
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.3 (abort with ^G)
1>
2、查看了/etc/profile文件,看了一下配置的路径,也是和本地测试机实验的时候配置是一样的,路径什么的都是正确的,并没有配错误:
[[email protected] ~]# cat /etc/profile
# /etc/profile
...... #省略若干行
export PATH=$PATH:/usr/local/erlang/bin
export PATH=$PATH:/usr/lib/rabbitmq/bin
[[email protected] ~]#
3、试着直接执行报错的文档启动,发现是可以的,服务也能启动:
[[email protected] ~]# sh /usr/lib/rabbitmq/bin/rabbitmq-server
RabbitMQ 3.6.12. Copyright (C) 2007-2017 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /var/log/rabbitmq/[email protected]
###### ## /var/log/rabbitmq/[email protected]
##########
Starting broker...
completed with 0 plugins.
那么启动执行的脚本可能不是这个脚本,所以想到替换一下启动脚本试试,或许有用。
解决过程:
1、找到rabbitmq-server命令执行的脚本的位置:
[[email protected] ~]# which rabbitmq-server
/sbin/rabbitmq-server
[[email protected] ~]#
2、比较两个文档,发现并不是同一个文件。于是把可以执行的/usr/lib/rabbitmq/bin/rabbitmq-server做软个连接到/sbin下面去替代原来执行报错的/sbin/rabbitmq-server文件:
[[email protected] sbin]# mv /sbin/rabbitmq-server /sbin/rabbitmq-server.bak
[[email protected] sbin]# ln -s /usr/lib/rabbitmq/bin/rabbitmq-server /sbin/rabbitmq-server
3、再次执行rabbitmq-server命令启动,发现还在报错:
[[email protected] sbin]# rabbitmq-server
/sbin/rabbitmq-server: line 22: /sbin/rabbitmq-env: No such file or directory
[[email protected] sbin]#
4、把报错缺少的文件rabbitmq-env再做一个软链接到/sbin下面:
[[email protected] sbin]# ln -s /usr/lib/rabbitmq/bin/rabbitmq-env /sbin/rabbitmq-env
5、再执行rabbitmq-server命令来启动服务,发现可以启动了:
[[email protected] sbin]# rabbitmq-server #这种启动方法只能前台启动,Ctrl+c,进程就没了。所以在正式启动的时候我用的nohup rabbitmq-server >/dev/null 2>&1 & 这个命令启动
RabbitMQ 3.6.12. Copyright (C) 2007-2017 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /var/log/rabbitmq/[email protected]
###### ## /var/log/rabbitmq/[email protected]
##########
Starting broker...
completed with 0 plugins.
然后查看进程,发现进程和端口号都已经起来了:
[[email protected] sbin]# ps -ef|grep rabbitmq
root 16778 1 0 Jul03 ? 00:32:36 /usr/local/erlang/lib/erlang/erts-8.3/bin/beam.smp -W w -A 128 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/local/erlang/lib/erlang -progname erl -- -home /root -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/ebin -noshell -noinput -s rabbit boot -sname [email protected] -boot start_sasl -config /etc/rabbitmq/rabbitmq -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/[email protected]"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/[email protected]"} -rabbit enabled_plugins_file "/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/lib/rabbitmq/plugins:/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.12/plugins" -rabbit plugins_expand_dir "/var/lib/rabbitmq/mnesia/[email protected]" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/var/lib/rabbitmq/mnesia/[email protected]" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672 -noshell -noinput
root 27708 25767 0 09:12 pts/1 00:00:00 grep --color=auto rabbitmq
[[email protected] sbin]#
[[email protected] sbin]# netstat -tlunp|grep 15672
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 16778/beam.smp
[[email protected] sbin]#
6、安装插件:
[[email protected] sbin]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to [email protected] started 6 plugins.
[[email protected] sbin]#
[[email protected] sbin]#
特别说明:
本文的这种解决方法,使用rabbitmq-server方法可以启动服务,但是使用另一种service rabbitmq-server start的方法启动,发现还是启动不了,会报这个错:
[[email protected] sbin]# service rabbitmq-server start
Starting rabbitmq-server (via systemctl): Job for rabbitmq-server.service failed because the control process exited with error code. See "systemctl status rabbitmq-server.service" and "journalctl -xe" for details.
[FAILED]
查看报错详情:
[[email protected] sbin]# systemctl status rabbitmq-server.service
a— rabbitmq-server.service - LSB: Enable AMQP service provided by RabbitMQ broker
Loaded: loaded (/etc/rc.d/init.d/rabbitmq-server; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2018-07-03 11:26:58 CST; 22s ago
Docs: man:systemd-sysv-generator(8)
Process: 10985 ExecStart=/etc/rc.d/init.d/rabbitmq-server start (code=exited, status=1/FAILURE)
Jul 03 11:26:58 host1 systemd[1]: Starting LSB: Enable AMQP service provided by RabbitMQ broker...
Jul 03 11:26:58 host1 su[11076]: (to rabbitmq) root on none
Jul 03 11:26:58 host1 su[11208]: (to rabbitmq) root on none
Jul 03 11:26:58 host1 rabbitmq-server[10985]: Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
Jul 03 11:26:58 host1 rabbitmq-server[10985]: rabbitmq-server.
Jul 03 11:26:58 host1 systemd[1]: rabbitmq-server.service: control process exited, code=exited status=1
Jul 03 11:26:58 host1 systemd[1]: Failed to start LSB: Enable AMQP service provided by RabbitMQ broker.
Jul 03 11:26:58 host1 systemd[1]: Unit rabbitmq-server.service entered failed state.
Jul 03 11:26:58 host1 systemd[1]: rabbitmq-server.service failed.
[[email protected] sbin]#
查看报错日志:
[[email protected] sbin]# cat /var/log/rabbitmq/startup_err
erlexec: HOME must be set
[[email protected] sbin]#
这个问题暂时还没找到怎么解决的方法,后续解决了再补上。
后记:
遇到报错“/usr/lib/rabbitmq/bin/rabbitmq-server: line 80: erl: command not found”,在网上查了很多解决方法,主要说法有两种:
1、在/usr/lib/rabbitmq/bin/rabbitmq-server文件的80行添加erl的环境变量;
2、修改/etc/profile修改环境变量,加上类似export HOME=/usr/lib/rabbitmq的配置
这两种方法都试过了,对我的问题不奏效,但记下来作为借鉴。
以上是关于解决Rabbitmq启动报“line 80: erl: command not found”的主要内容,如果未能解决你的问题,请参考以下文章
RabbitMQ 安装及启动报错 Error description: noproc 解决办法
(记录)整合spring cloud bus+rabbitmq后,config server/client启动报错及解决方式
RabbitMQ 启动报错 ERROR: epmd error for host xxx: timeout (timed out)
SpringBoot+RabbitMQ启动出现报错问题总结org.springframework.amqp.AmqpConnectException: java.net.ConnectExceptio