使用rabbitmq出现的问题描述:
1、打开http://ip:15672/#/ 后台管理页面会很慢
2、springboot项目连接mq经常连接不上(偶尔可以连上)
3、报错:AmqpTimeoutException: java.util.concurrent.TimeoutException
4、java.net.SocketException: socket closed
5、An unexpected connection driver error occured
网上很多资料都是设置用户权限和允许远程远程访问的方法:
设置用户权限:
rabbitmqctl set_permissions -p /${user_name} user_admin '.*' '.*' '.*'
允许远程访问,rabbitmq.config配置文件:
[{rabbit, [{loopback_users, []}]}].
如果上诉方法不能解决的可以尝试下面的方法:
1、运行如下命令查看状态:
rabbitmqctl status
错误时会出现如下信息:
Status of node rabbit@jysp ... Error: unable to perform an operation on node 'rabbit@jysp'. 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 http://rabbitmq.com/documentation.html to learn more * Consult server logs on node rabbit@manage01 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools DIAGNOSTICS =========== attempted to contact: [rabbit@jysp] rabbit@jysp: * connected to epmd (port 4369) on manage01 * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic * can't establish TCP connection to the target node, reason: timeout (timed out) * suggestion: check if host 'manage01' resolves, is reachable and ports 25672, 4369 are not blocked by firewall Current node details: * node name: 'rabbitmqcli-27020-rabbit@jysp' * effective user's home directory: /var/lib/rabbitmq * Erlang cookie hash: cuIV6fAR5pI2DAISuXW4IQ==
正确时会出现如下信息:
Status of node rabbit@jysp ... [{pid,28714}, {running_applications, [{rabbitmq_web_mqtt,"RabbitMQ MQTT-over-WebSockets adapter","3.7.12"}, {rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.7.12"}, {rabbitmq_management,"RabbitMQ Management Console","3.7.12"}, {rabbitmq_management_agent,"RabbitMQ Management Agent","3.7.12"}, {rabbitmq_web_stomp,"Rabbit WEB-STOMP - WebSockets to Stomp adapter", "3.7.12"}, {rabbitmq_stomp,"RabbitMQ STOMP plugin","3.7.12"}, {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.7.12"}, {rabbit,"RabbitMQ","3.7.12"}, {amqp_client,"RabbitMQ AMQP Client","3.7.12"}, {rabbit_common, "Modules shared by rabbitmq-server and rabbitmq-erlang-client", "3.7.12"}, {jsx,"a streaming, evented json parsing toolkit","2.9.0"}, {xmerl,"XML parser","1.3.19"}, {os_mon,"CPO CXC 138 46","2.4.7"}, {cowboy,"Small, fast, modern HTTP server.","2.6.1"}, {ranch,"Socket acceptor pool for TCP protocols.","1.7.1"}, {ssl,"Erlang/OTP SSL application","9.1.2"}, {public_key,"Public key infrastructure","1.6.4"}, {asn1,"The Erlang ASN1 compiler version 5.0.8","5.0.8"}, {cowlib,"Support library for manipulating Web protocols.","2.7.0"}, {crypto,"CRYPTO","4.4"}, {inets,"INETS CXC 138 49","7.0.5"}, {sysmon_handler,"Rate-limiting system_monitor event handler","1.1.0"}, {mnesia,"MNESIA CXC 138 12","4.15.5"}, {recon,"Diagnostic tools for production use","2.3.6"}, {lager,"Erlang logging framework","3.6.5"}, {goldrush,"Erlang event stream processor","0.1.9"}, {compiler,"ERTS CXC 138 10","7.3.1"}, {syntax_tools,"Syntax tools","2.1.6"}, {sasl,"SASL CXC 138 11","3.3"}, {stdlib,"ERTS CXC 138 10","3.7.1"}, {kernel,"ERTS CXC 138 10","6.2"}]}, {os,{unix,linux}}, {erlang_version, "Erlang/OTP 21 [erts-10.2.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:128] [hipe]\n"}, {memory, [{connection_readers,0}, {connection_writers,0}, {connection_channels,0}, {connection_other,16596}, {queue_procs,0}, {queue_slave_procs,0}, {plugins,972316}, {other_proc,31715356}, {metrics,206948}, {mgmt_db,161864}, {mnesia,74376}, {other_ets,2853712}, {binary,94816}, {msg_index,28784}, {code,23713613}, {atom,1172689}, {other_system,14120482}, {allocated_unused,15029600}, {reserved_unallocated,0}, {strategy,rss}, {total,[{erlang,75131552},{rss,78036992},{allocated,90161152}]}]}, {alarms,[]}, {listeners, [{clustering,25672,"::"}, {amqp,5672,"::"}, {stomp,61613,"::"}, {'http/web-stomp',15674,"::"}, {http,15672,"::"}, {mqtt,1883,"::"}, {'http/web-mqtt',15675,"::"}]}, {vm_memory_calculation_strategy,rss}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,13390166425}, {disk_free_limit,50000000}, {disk_free,22576242688}, {file_descriptors, [{total_limit,32668}, {total_used,2}, {sockets_limit,29399}, {sockets_used,0}]}, {processes,[{limit,1048576},{used,463}]}, {run_queue,1}, {uptime,26}, {kernel,{net_ticktime,60}}]
主要问题所在:
Status of node rabbit@jysp ...
可以知道rabbitmq中的host是jysp,然后运行如下命令添加hosts配置即可:
echo 127.0.0.1 jysp >> /etc/hosts
PS:127.0.0.1可以是你的IP具体地址,如果是局域网服务器,可以直接写内网地址。
原文链接:https://blog.csdn.net/u014520745/article/details/88247072