rabbitmq 启动异常问题排查
rabbitmq 启动异常问题排查
[root@localhost sbin]# systemctl status rabbitmq -l
● rabbitmq.service - RabbitMQ Server
Loaded: loaded (/etc/systemd/system/rabbitmq.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 二 2024-11-26 10:13:30 CST; 1min 4s ago
Process: 26452 ExecStart=/usr/local/dhtech/rabbitmq/sbin/rabbitmq-server (code=exited, status=0/SUCCESS)
Main PID: 26452 (code=exited, status=0/SUCCESS)
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> trap_exit: true
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> status: running
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> heap_size: 987
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> stack_size: 28
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> reductions: 237
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0> neighbours:
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.596744+08:00 [erro] <0.127.0>
11月 26 10:13:28 localhost.localdomain rabbitmq-server[26452]: 2024-11-26 10:13:28.599509+08:00 [noti] <0.44.0> Application rabbitmq_prelaunch exited with reason: {{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Failed to create cookie file '/home/rabbitmq/.erlang.cookie': enoent",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_26457@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,supervisor,[erl_distribution]}}}}}},{rabbit_prelaunch_app,start,[normal,[]]}}
11月 26 10:13:30 localhost.localdomain rabbitmq-server[26452]: {"Kernel pid terminated",application_controller,"{application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{\"Failed to create cookie file '/home/rabbitmq/.erlang.cookie': enoent\",[{auth,init_no_setcookie,0,[{file,\"auth.erl\"},{line,313}]},{auth,init,1,[{file,\"auth.erl\"},{line,165}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,423}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_26457@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,supervisor,[erl_distribution]}}}}}},{rabbit_prelaunch_app,start,[normal,[]]}}}"}
11月 26 10:13:30 localhost.localdomain rabbitmq-server[26452]: Kernel pid terminated (application_controller) ({application_start_failure,rabbitmq_prelaunch,{{shutdown,{failed_to_start_child,prelaunch,{badmatch,{error,{{shutdown,{failed_to_start_child,auth,{"Failed to create cookie file '/home/rabbitmq/.erlang.cookie': enoent",[{auth,init_no_setcookie,0,[{file,"auth.erl"},{line,313}]},{auth,init,1,[{file,"auth.erl"},{line,165}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,423}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,390}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}},{child,undefined,net_sup_dynamic,{erl_distribution,start_link,[#{clean_halt => false,name => rabbit_prelaunch_26457@localhost,name_domain => shortnames,net_tickintensity => 4,net_ticktime => 60,supervisor => net_sup_dynamic}]},permanent,false,1000,supervisor,[erl_distribution]}}}}}},{rabbit_prelaunch_app,start,[normal,[]]}}})
解决方法:
- 查看是否存在文件夹
ls -ld /home/rabbitmq
- 没有就创建
sudo mkdir -p /home/rabbitmq - 授予权限
sudo chown -R rabbitmq:rabbitmq /home/rabbitmq
重启后出现新的问题
[root@localhost home]# systemctl status rabbitmq -l
● rabbitmq.service - RabbitMQ Server
Loaded: loaded (/etc/systemd/system/rabbitmq.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 二 2024-11-26 10:17:50 CST; 6s ago
Process: 26801 ExecStart=/usr/local/dhtech/rabbitmq/sbin/rabbitmq-server (code=exited, status=0/SUCCESS)
Main PID: 26801 (code=exited, status=0/SUCCESS)
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> trap_exit: true
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> status: running
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> heap_size: 987
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> stack_size: 28
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> reductions: 206
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0> neighbours:
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.219046+08:00 [erro] <0.226.0>
11月 26 10:17:49 localhost.localdomain rabbitmq-server[26801]: 2024-11-26 10:17:49.230097+08:00 [noti] <0.44.0> Application rabbit exited with reason: {{cannot_log_to_file,"/usr/local/dhtech/rabbitmq/var/log/rabbitmq/rabbit@localhost.log",eacces},{rabbit,start,[normal,[]]}}
11月 26 10:17:50 localhost.localdomain rabbitmq-server[26801]: {"Kernel pid terminated",application_controller,"{application_start_failure,rabbit,{{cannot_log_to_file,\"/usr/local/dhtech/rabbitmq/var/log/rabbitmq/rabbit@localhost.log\",eacces},{rabbit,start,[normal,[]]}}}"}
11月 26 10:17:50 localhost.localdomain rabbitmq-server[26801]: Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{{cannot_log_to_file,"/usr/local/dhtech/rabbitmq/var/log/rabbitmq/rabbit@localhost.log",eacces},{rabbit,start,[normal,[]]}}})
解决办法:
sudo chown -R rabbitmq:rabbitmq /usr/local/dhtech/rabbitmq/var/log/rabbitmq
重启问题如下:
systemctl status rabbitmq -l
● rabbitmq.service - RabbitMQ Server
Loaded: loaded (/etc/systemd/system/rabbitmq.service; enabled; vendor preset: disabled)
Active: inactive (dead) since 二 2024-11-26 10:18:56 CST; 1s ago
Process: 26920 ExecStart=/usr/local/dhtech/rabbitmq/sbin/rabbitmq-server (code=exited, status=0/SUCCESS)
Main PID: 26920 (code=exited, status=0/SUCCESS)
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: 2024-11-26 10:18:53.638986+08:00 [noti] <0.227.0> Logging: switching to configured handler(s); following messages may not be visible in this log output
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: BOOT FAILED
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: ===========
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: Error during startup: {error,
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: {could_not_write_file,
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: "/usr/local/dhtech/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost/cluster_nodes.config",
11月 26 10:18:53 localhost.localdomain rabbitmq-server[26920]: eacces}}
11月 26 10:18:56 localhost.localdomain rabbitmq-server[26920]: {"Kernel pid terminated",application_controller,"{application_start_failure,rabbit,{{could_not_write_file,\"/usr/local/dhtech/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost/cluster_nodes.config\",eacces},{rabbit,start,[normal,[]]}}}"}
11月 26 10:18:56 localhost.localdomain rabbitmq-server[26920]: Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{{could_not_write_file,"/usr/local/dhtech/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost/cluster_nodes.config",eacces},{rabbit,start,[normal,[]]}}})
11月 26 10:18:56 localhost.localdomain rabbitmq-server[26920]: Crash dump is being written to: /usr/local/dhtech/rabbitmq/var/log/rabbitmq/erl_crash.dump...done
解决办法:
- 设置权限
sudo chown -R rabbitmq:rabbitmq /usr/local/dhtech/rabbitmq/var/lib/rabbitmq/mnesia
sudo chmod -R 755 /usr/local/dhtech/rabbitmq/var/lib/rabbitmq/mnesia
重启
sudo systemctl start rabbitmq
systemctl status rabbitmq -l
至此Rabbit MQ正常启动
[root@localhost home]# systemctl status rabbitmq -l
● rabbitmq.service - RabbitMQ Server
Loaded: loaded (/etc/systemd/system/rabbitmq.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2024-11-26 10:21:05 CST; 4s ago
Main PID: 27064 (rabbitmq-server)
CGroup: /system.slice/rabbitmq.service
├─27064 /bin/sh /usr/local/dhtech/rabbitmq/sbin/rabbitmq-server
├─27069 /usr/local/lib/erlang/erts-12.3/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -sbwt none -sbwtdcpu none -sbwtdio none -B i -- -root /usr/local/lib/erlang -progname erl -- -home /home/rabbitmq -- -pa -noshell -noinput -s rabbit boot -boot start_sasl -syslog logger [] -syslog syslog_error_logger false -kernel prevent_overlapping_partitions false
├─27076 erl_child_setup 1024
├─27103 /usr/local/lib/erlang/erts-12.3/bin/epmd -daemon
├─27128 inet_gethost 4
└─27129 inet_gethost 4
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: TLS Library: OpenSSL - OpenSSL 1.0.2k-fips 26 Jan 2017
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Doc guides: https://rabbitmq.com/documentation.html
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Support: https://rabbitmq.com/contact.html
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Tutorials: https://rabbitmq.com/getstarted.html
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Monitoring: https://rabbitmq.com/monitoring.html
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Logs: /usr/local/dhtech/rabbitmq/var/log/rabbitmq/rabbit@localhost.log
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: /usr/local/dhtech/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: <stdout>
11月 26 10:21:07 localhost.localdomain rabbitmq-server[27064]: Config file(s): (none)
11月 26 10:21:08 localhost.localdomain rabbitmq-server[27064]: Starting broker... completed with 3 plugins.