Rabbitmq 安装启动中遇到的坑

Rabbitmq 安装启动中遇到的坑

在做消息投递和消费的并发测试的时候,Rabbitmq 崩了,管理页面无法访问,消息无法投递,也不能消息。

想到的解决方法是重启,但输入命令:servicre rabbitmq-server stop

1
ERROR: node with name "rabbit" already running on "localhost"

无论restart、stop、start都报这个错。原因是RabbitMQ已在localhost里运行了,但是停止不了。解决记录如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
zhangguoyedeMacBook-Pro:~ zhangguoye$ rabbitmq-server
ERROR: node with name "rabbit" already running on "localhost"

zhangguoyedeMacBook-Pro:~ zhangguoye$ ps aux|grep epmd
zhangguoye 35736 0.0 0.0 4328468 676 ?? S 四03下午 0:00.08 /usr/local/Cellar/erlang/22.0.2/lib/erlang/erts-10.4.1/bin/epmd -daemon
zhangguoye 67752 0.0 0.0 4268036 804 s009 S+ 10:05上午 0:00.00 grep epmd

zhangguoyedeMacBook-Pro:~ zhangguoye$ ps aux|grep erl
zhangguoye 65864 0.1 0.5 5517096 84836 s009 S 10:00上午 0:09.27 /usr/local/Cellar/erlang/22.0.2/lib/erlang/erts-10.4.1/bin/beam.smp -W w -A 128 -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -B i -- -root /usr/local/Cellar/erlang/22.0.2/lib/erlang -progname erl -- -home /Users/zhangguoye -- -pa /usr/local/Cellar/rabbitmq/3.7.15/ebin -noshell -noinput -s rabbit boot -sname rabbit@localhost -boot /usr/local/opt/erlang/lib/erlang/bin/start_clean -kernel inet_default_connect_options [{nodelay,true}] -rabbit tcp_listeners [{"127.0.0.1",5672}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit lager_log_root "/usr/local/var/log/rabbitmq" -rabbit lager_default_file "/usr/local/var/log/rabbitmq/rabbit@localhost.log" -rabbit lager_upgrade_file "/usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log" -rabbit enabled_plugins_file "/usr/local/etc/rabbitmq/enabled_plugins" -rabbit plugins_dir "/usr/local/Cellar/rabbitmq/3.7.15/plugins" -rabbit plugins_expand_dir "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost-plugins-expand" -os_mon start_cpu_sup false -os_mon start_disksup false -os_mon start_memsup false -mnesia dir "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost" -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672
zhangguoye 35736 0.0 0.0 4328468 688 ?? S 四03下午 0:00.08 /usr/local/Cellar/erlang/22.0.2/lib/erlang/erts-10.4.1/bin/epmd -daemon
zhangguoye 68953 0.0 0.0 4268036 804 s009 S+ 10:11上午 0:00.00 grep erl
zhangguoye 65877 0.0 0.0 4270068 828 ?? Ss 10:00上午 0:00.36 erl_child_setup 7168

zhangguoyedeMacBook-Pro:~ zhangguoye$ kill -9 65864

zhangguoyedeMacBook-Pro:~ zhangguoye$ rabbitmq-server

## ##
## ## RabbitMQ 3.7.15. Copyright (C) 2007-2019 Pivotal Software, Inc.
########## Licensed under the MPL. See https://www.rabbitmq.com/
###### ##
########## Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log
/usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log

Starting broker...
completed with 6 plugins.

但是上述的启动方式会因为退出而关闭。

采用如下方式可以解决

1
2
[root]# /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server -detached
Warning: PID file not written; -detached was passed.

但是输入命令,提示没有权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root]# 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]
[root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 4.2G 43G 9% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 24K 1.9G 1% /dev/shm
tmpfs 1.9G 556K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs 379M 0 379M 0% /run/user/0
[root]# chkconfig --list

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.

netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rabbitmq-server 0:off 1:off 2:on 3:on 4:on 5:on 6:off

想要加入系统自启动,却怎么也不行。

1
2
3
4
[  sbin]# chkconfig rabbitmq-server on
[ sbin]# systemctl enable rabbitmq-server.service
rabbitmq-server.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig rabbitmq-server on

打开 cat /usr/sbin/chkconfig 又是乱码

还有提出建立一个软连接的,也不行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[  sbin]# chkconfig rabbitmq-server on
[ sbin]# systemctl enable rabbitmq-server.service
rabbitmq-server.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig rabbitmq-server on
[ sbin]# In -s /usr/lib/rabbitmq/bin/rabbitmq-server /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server
-bash: In: command not found
[ sbin]# ln -s /usr/lib/rabbitmq/bin/rabbitmq-server /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server
ln: failed to create symbolic link ‘/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server’: File exists
[ sbin]# ln -s /usr/lib/rabbitmq/bin/rabbitmq-server /sbin/rabbitmq-server
ln: failed to create symbolic link ‘/sbin/rabbitmq-server’: File exists
[ sbin]# systemctl enable rabbitmq-server.service
rabbitmq-server.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig rabbitmq-server on
[ sbin]# find / -name rabbitma-service
[ sbin]# ^C
[ sbin]# find / -name rabbitmq-service
[ sbin]# find / -name rabbitmq-server
/etc/logrotate.d/rabbitmq-server
/etc/rc.d/init.d/rabbitmq-server
/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server
/usr/lib/rabbitmq/bin/rabbitmq-server
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/usr/sbin/rabbitmq-server
[ sbin]# ln -s /usr/lib/rabbitmq/bin/rabbitmq-server /usr/sbin/rabbitmq-server
ln: failed to create symbolic link ‘/usr/sbin/rabbitmq-server’: File exists

使用find命令查询按照目录:

1
2
3
4
5
6
7
[  sbin]# find / -name rabbitmq-server
/etc/logrotate.d/rabbitmq-server
/etc/rc.d/init.d/rabbitmq-server
/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server
/usr/lib/rabbitmq/bin/rabbitmq-server
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/usr/sbin/rabbitmq-server

没有明白怎么会有这么多安装路径。

想要通过命令添加用户,发现网上教程也都是按照rabbitmqctl 的方式添加。由于没有添加systemctl成功,不再折腾。

最后按照-detached 启动的方式启动,不在折腾。

1
2
[  sbin]# /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/sbin/rabbitmq-server -detached
Warning: PID file not written; -detached was passed.

参考: ERROR: node with name “rabbit” already running on “localhost” https://segmentfault.com/a/1190000019439609?utm_source=tag-newest

CentOS7.2安装RabbitMQ笔记 https://www.cnblogs.com/ylsforever/p/6600925.html

centos7安装rabbitmq(几乎所有的坑都遇到了) https://blog.csdn.net/junxieshiguan/article/details/84547918