解决SpringBoot连接Nacos集群报400问题
问题描述
搭建一个Nacos集群,使用 SpringBoot 程序连接 Nacos 集群,在启动的时候报异常,程序启动失败,而后程序假死。详细控制台日志信息如下:
failed to req API:/nacos/v1/ns/instance after all servers([192.168.1.169:8848]) tried: ErrCode:400, ErrMsg:<html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Tue Feb 08 21:19:48 CST 2022</div><div>There was an unexpected error (type=Bad Request, status=400).</div><div>receive invalid redirect request from peer 127.0.0.1</div></body></html>
at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:556) ~[nacos-client-1.4.1.jar:na]
at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:498) ~[nacos-client-1.4.1.jar:na]
at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:493) ~[nacos-client-1.4.1.jar:na]
at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:246) ~[nacos-client-1.4.1.jar:na]
环境
- NacosServer 版本:2.0.3
- NacosServer集群部署方式:在windows11下启动三个实例,分别运行在8848,8858,8868端口上面,三个实例连接同一个MySQL数据库
- NacosClient为 SpringBoot 程序,使用 SpringInitializr 创建,未引入其他无关依赖
- SpringBoot版本:2.5.3
- SpringCloud版本:2020.0.3
- SpringCloudAlibaba版本:2021.1
- 笔记本:酷睿I5-11代,RAM-16G
集群配置
cluster.conf
127.0.0.1:8848
127.0.0.1:8858
127.0.0.1:8868
解决办法
删除data文件夹重启
Nacos 非常占资源,Windows11 下,启动就能把CPU占到56%(酷睿I5-11代),启动成功之后占了1.7G的内存。此解决方法是百度出来的,首先停止 SpringBoot 程序、Nacos集群;然后删除三个实例下面的 data 文件夹并重新启动集群;最后重新启动 SpringBoot。此时可以正常注册到 Nacos 集群中, 每一个实例中的服务列表中都有该 SpringBoot 服务。
修改cluster.conf文件
本来以为上述方法已经可以解决此问题,毕竟【百度】出来的!可是过了一会之后又报400问题,中间(应该)没有特别特殊的操作,无非(可能)就是重启 SpringBoot 服务,修改 Nacos 的 application.properties 文件和重启集群等等。
重新排查了一遍,发现NacosWebUI中的 集群管理--->节点列表 中多了一个实例,变成了四个,重新查看了集群 cluster.conf, 发现每一个实例此配置文件中都多了一行【192.168.1.169:8858】。这行(好像)不是我加的,但是不管怎么说,这行都是不必须的,所以我决定删除这行。首先停止 SpringBoot 程序、Nacos集群;然后删除三个实例下面的 data 文件夹,删除 cluster.conf 文件中无故(手残添加)增加的那行,并重新启动集群;最后重新启动 SpringBoot。此时可以正常注册到 Nacos 集群中, 每一个实例中的服务列表中都有该 SpringBoot 服务。
原因&原理
//todo
解决SpringBoot连接Nacos集群报400问题的更多相关文章
- Springboot2.x集成lettuce连接redis集群报超时异常Command timed out after 6 second(s)
文/朱季谦 背景:最近在对一新开发Springboot系统做压测,发现刚开始压测时,可以正常对redis集群进行数据存取,但是暂停几分钟后,接着继续用jmeter进行压测时,发现redis就开始突然疯 ...
- redis集群报Jedis does not support password protected Redis Cluster configurations异常解决办法
解决spring-data-redis操作redis集群报“Jedis does not support password protected Redis Cluster configurations ...
- redis客户端可以连接集群,但JedisCluster连接redis集群一直报Could not get a resource from the pool
一,问题描述: (如题目)通过jedis连接redis单机成功,使用JedisCluster连接redis集群一直报Could not get a resource from the pool 但是使 ...
- 通过jedis连接redis单机成功,使用redis客户端可以连接集群,但使用JedisCluster连接redis集群一直报Could not get a resource from the pool
一,问题描述: (如题目)通过jedis连接redis单机成功,使用JedisCluster连接redis集群一直报Could not get a resource from the pool 但是使 ...
- 搭建elsticsearch集群 报错with the same id but is a different node instance解决办法
搭建elsticsearch集群 报错with the same id but is a different node instance解决办法 学习了:https://blog.csdn.net/q ...
- ElasticSearch(八):springboot集成ElasticSearch集群并使用
1. 集群的搭建 见:ElasticSearch(七) 2. springboot配置集群 2.1 创建springboot项目,使用idea创建,不过多介绍(创建项目时候建议不要勾选elastics ...
- myeclipse连接hadoop集群编程及问题解决
原以为搭建一个本地编程测试hadoop程序的环境很简单,没想到还是做得焦头烂额,在此分享步骤和遇到的问题,希望大家顺利. 一.要实现连接hadoop集群并能够编码的目的需要做如下准备: 1.远程had ...
- quartz集群报错but has failed to stop it. This is very likely to create a memory leak.
quartz集群报错but has failed to stop it. This is very likely to create a memory leak. 在一台配置1核2G内存的阿里云服务器 ...
- redis集群报错
写入redis集群报错:(error) MOVED 6918 解决方法:redis-cli -c -p 7001 -h 10.0.0.104
随机推荐
- JVM 内存布局
JVM 内存布局规定了 Java 在运行过程中内存申请.分配.管理的策略,保证了 JVM 的高效稳定运行. 线程是否共享 Heap (堆区) 堆是 OOM 故障最主要的发生区域.它是内存区域中最大的一 ...
- Entropy, relative entropy and mutual information
目录 Entropy Joint Entropy Conditional Entropy Chain rule Mutual Information Relative Entropy Chain Ru ...
- Obfuscated Gradients Give a False Sense of Security: Circumventing Defenses to Adversarial Examples
目录 概 主要内容 Obfuscated Gradients BPDA 特例 一般情形 EOT Reparameterization 具体的案例 Thermometer encoding Input ...
- 剖析Defi之Uinswap_1
学习UniswapERC20,它是交易对的父合约.UniswapV2ERC20 是流动性代币合约,也称为 LP Token.功能主要实习ERC20代币功能以及对线下签名授权. 1 pragma sol ...
- 编写Java程序,创建一个父类交通工具类(Vehicles),以及两个子类,分别是轿车类(Car)和卡车类(Truck)。
返回本章节 返回作业目录 需求说明: 创建一个父类交通工具类(Vehicles),以及两个子类,分别是轿车类(Car)和卡车类(Truck). 父类有属性品牌(brand)和颜色(color). 在父 ...
- 【ElasticSearch】异常 Request cannot be executed; I/O reactor status: STOPPED
Caused by: java.lang.RuntimeException: Request cannot be executed; I/O reactor status: STOPPED at or ...
- mqttfx无法选择证书
mqttfx无法选择证书,无法读取证书 mqttfx也算是挺方便的,但是,有个问题困扰了我很久,就是windows下使用SSL/TLS选择证书路径时,点击后面三个点没有反应(有的同学就没有这个问题) ...
- getRequestDispatcher 中请求转发和请求包含的使用说明
getRequestDispatcher() getRequestDispatcher() 包含两个方法,分别是请求转发和请求包含. RequestDispatcher rd = request.ge ...
- 《python深度学习》(高清、源码).PDF,免费无需任何解压密码
链接:https://pan.baidu.com/s/1zx20XEpPBJeBG2e1IGMc6g 提取码:wub3
- selenium实现并发
for循环和多线程 + selenium 实例一 for循环 # -*- coding: utf-8 -*- """ Datetime: 2019/6/22 Author ...