SpringCloudAlibaba升级手册-nacos问题记录

目录

一、前言

二、升级过程

1.问题

2.原因

3.出处

4.理论解决

5.测试环境问题

[6.Spring Cloud Alibaba版本对比](#6.Spring Cloud Alibaba版本对比)

[7. Spring Cloud Alibaba适配组件版本对比](#7. Spring Cloud Alibaba适配组件版本对比)

[8.降低Spring Cloud版本](#8.降低Spring Cloud版本)

9.SpringCloud与SpringBoot兼容对比表

10.naocs-client版本对比

三、最终解决


一、前言

背景

项目做改造工作,要符合架构的某些要求,进行的版本升级工作。

技术清单

|------------|--------------------|---------------|-------------------|
| 序号 | 类型 | 版本现状 | 新版本选择 |
| 1 | SpringBoot | 2.3.2.RELEASE | 2.7.18 |
| 2 | SpringCloud | Hoxton.SR9 | 2021.0.9 |
| 3 | SpringCloudAlibaba | 2.2.6.RELEASE | 2021.0.5.0 |
| 4 | nacos-client | 1.4.2 | 2021.0.5.0内嵌2.2.0 |
| 5 | Nacos 服务端 | 2.2.3 | 不变 |

Nacos2.0的服务端完全兼容1.X客户端。Nacos2.0客户端由于使用了gRPC,无法兼容Nacos1.X服务端,请勿使用2.0以上版本客户端连接Nacos1.X服务端。

二、升级过程

1.问题

等其他兼容性问题,编译问题解决完,启动时,报错,错误信息:

Client not connected, current status:STARTING

2.原因

Nacos2.0版本相比1.X新增了gRPC的通信方式,因此需要增加2个端口,9848,9849。

3.出处

Nacos 2.0.0 兼容性文档:

Nacos 2.0.0 兼容性文档

4.理论解决

本地开通了访问处于测试环境的nacos服务端的9848端口,本地服务成功注册到测试环境nacos上。

5.测试环境问题

把项目打包部署到测试linux环境,依然报这个错误,随后在已开通9848端口防火墙的基础上又开通了9849,7848两个接口,(注:测试环境是单台单节点服务部署),依然不行。

6. Spring Cloud Alibaba 版本对比

排查了各种网络问题后,最后不得不从版本兼容性考虑,又仔细阅读了spring-cloud-alibaba的版本说明文档。

版本说明 · alibaba/spring-cloud-alibaba Wiki · GitHub

由于 Spring Boot 3.0,Spring Boot 2.7~2.4 和 2.4 以下版本之间变化较大,目前企业级客户老项目相关 Spring Boot 版本仍停留在 Spring Boot 2.4 以下,为了同时满足存量用户和新用户不同需求,社区以 Spring Boot 3.0 和 2.4 分别为分界线,同时维护 2022.x、2021.x、2.2.x 三个分支迭代。如果不想跨分支升级,如需使用新特性,请升级为对应分支的新版本。 为了规避相关构建过程中的依赖冲突问题。

我们项目使用了Spring Boot 2.7.x,然后选择spring-cloud-alibaba2021.x,2021.x 分支适配 Spring Boot 2.4,Spring Cloud 2021.x 版本及以上的 Spring Cloud Alibaba 版本按从新到旧排列如下表(最新版本用*标记):

|--------------------------------------|------------------------------|-----------------------------|
| Spring Cloud Alibaba Version | Spring Cloud Version | Spring Boot Version |
| 2021.0.5.0* | Spring Cloud 2021.0.5 | 2.6.13 |
| 2021.0.4.0 | Spring Cloud 2021.0.4 | 2.6.11 |
| 2021.0.1.0 | Spring Cloud 2021.0.1 | 2.6.3 |
| 2021.1 | Spring Cloud 2020.0.1 | 2.4.2 |

7. Spring Cloud Alibaba 适配 组件版本对比

每个 Spring Cloud Alibaba 版本及其自身所适配的各组件对应版本如下表所示:

|-----------------------------------------------------------|--------------------------|-----------------------|--------------------------|-----------------------|-----------------------|
| Spring Cloud Alibaba Version | Sentinel Version | Nacos Version | RocketMQ Version | Dubbo Version | Seata Version |
| 2022.0.0.0 | 1.8.6 | 2.2.1 | 4.9.4 | ~ | 1.7.0 |
| 2022.0.0.0-RC2 | 1.8.6 | 2.2.1 | 4.9.4 | ~ | 1.7.0-native-rc2 |
| 2021.0.5.0 | 1.8.6 | 2.2.0 | 4.9.4 | ~ | 1.6.1 |
| 2.2.10-RC1 | 1.8.6 | 2.2.0 | 4.9.4 | ~ | 1.6.1 |
| 2022.0.0.0-RC1 | 1.8.6 | 2.2.1-RC | 4.9.4 | ~ | 1.6.1 |
| 2.2.9.RELEASE | 1.8.5 | 2.1.0 | 4.9.4 | ~ | 1.5.2 |
| 2021.0.4.0 | 1.8.5 | 2.0.4 | 4.9.4 | ~ | 1.5.2 |
| 2.2.8.RELEASE | 1.8.4 | 2.1.0 | 4.9.3 | ~ | 1.5.1 |
| 2021.0.1.0 | 1.8.3 | 1.4.2 | 4.9.2 | ~ | 1.4.2 |
| 2.2.7.RELEASE | 1.8.1 | 2.0.3 | 4.6.1 | 2.7.13 | 1.3.0 |
| 2.2.6.RELEASE | 1.8.1 | 1.4.2 | 4.4.0 | 2.7.8 | 1.3.0 |
| 2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE | 1.8.0 | 1.4.1 | 4.4.0 | 2.7.8 | 1.3.0 |

如图所示,如果Springboot是2.7.x,选择SpringCloudAlibaba的版本为2021.0.5.0较为合适,实际到了测试环境,项目启动不成功的,难道对SpringCloud的小版本有敏感要求?

8.降低 Spring Cloud 版本

把SpringCloud 2021.0.9改为表中的Spring Cloud 2021.0.5,不行。剩下的是Springboot版本不一致了,项目用的2.7.18,Spring Cloud Alibaba版本对比中,要求Springboot是2.6.13,那这个做不到,架构受限要求,去SpringCloud官网查找SpringCloud与SpringBoot的版本兼容。

9.SpringCloud与SpringBoot兼容对比表

Spring Cloud官网

|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| Release Train | Spring Boot Generation |
| 2024.0.x aka Moorgate | 3.4.x |
| 2023.0.x aka Leyton | 3.3.x, 3.2.x |
| 2022.0.x aka Kilburn | 3.0.x, 3.1.x (Starting with 2022.0.3) |
| 2021.0.x aka Jubilee | 2.6.x, 2.7.x (Starting with 2021.0.3) |
| 2020.0.x aka Ilford | 2.4.x, 2.5.x (Starting with 2020.0.3) |
| Hoxton | 2.2.x, 2.3.x (Starting with SR5) |
| Greenwich | 2.1.x |
| Finchley | 2.0.x |
| Edgware | 1.5.x |
| Dalston | 1.5.x |

Spring Cloud 2021.0.5对springBoot2.7.x是兼容的,Spring Cloud Alibaba只认2.6.13?

剩下的还有一个Alibaba自己组件版本不同的地方,Spring Cloud 2021.0.5要求Naocs版本是2.2.0,而我们系统的是2.2.3,难道让我卸载高版本Nacos服务端换成低版本的,生产环境集群也是2.2.3,测试环境换成了nacos2.2.0。

好像还是启动失败,但是Nacos兼容性文档里说,高版本的Nacos服务端是兼容低版本的客户端的。

10.naocs-client版本对比

|----------------------------------------|------------------------|---------------------------------|
| Spring Cloud Alibaba版本 | nacos-client版本 | Spring Cloud 版本 |
| 2021.0.5.0 | 2.2.0 | 2021.0.5 |
| 2021.0.4.0 | 2.0.4 | 2021.0.4 |
| 2021.0.1.0 | 1.4.2 | 2021.0.1 |
| 2021.1 | 1.4.1 | 2020.0.1 |

三、 最终解决

SpringCloud依然使用规定的2021.0.9,把SpringCloudAlibaba的版本降到2021.0.1.0,使用nacos-client1.4.2,不用什么gRPC协议替换http协议,条件满足后,卸载Nacos改为consul。

Maven中央仓库下载地址:

https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-discovery

能提供思路的技术博客:

项目启动不了网关模块解决:Client not connected, current status:STARTING_client not connected current status-CSDN博客

https://zhuanlan.zhihu.com/p/675727483?utm_campaign=shareopn&utm_medium=social&utm_psn=1854727891834761217&utm_source=wechat_session

https://zhuanlan.zhihu.com/p/709652782?utm_campaign=shareopn&utm_medium=social&utm_psn=1854729147697487872&utm_source=wechat_session

nacos错误:com.alibaba.nacos.api.exception.NacosException: failed to req API:/nacos/v1/ns/instance_nacos清除缓存-CSDN博客

相关推荐
非 白10 小时前
【Java分布式】Nacos注册中心
java·开发语言·nacos·注册中心
@明明不知道10 天前
spring cloud 微服务部署(2025年)第一章:Nacos、LoadBalancer、GateWay、Ribbon集成之Nacos部署
spring cloud·微服务·nacos·gateway·loadbalancer
@明明不知道12 天前
spring cloud 微服务部署(2025年)第四章:Nacos、LoadBalancer、GateWay、Ribbon集成之跨服务调用ribbon
spring cloud·微服务·nacos·gateway·loadbalancer
Rotion_深19 天前
基于 .NET 8.0 gRPC通讯架构设计讲解,客户端+服务端
c#·grpc
2的n次方_23 天前
Nacos 的介绍和使用
java·spring boot·spring cloud·微服务·云原生·nacos
麻辣香蝈蝈1 个月前
【Java】微服务找不到问题记录can not find user-service
java·微服务·nacos
S-X-S1 个月前
项目集成Nacos
java·nacos
小白的一叶扁舟1 个月前
Nacos 2.5.0 全文详解及配置(并解决WebServerException: Unable to start mbedded Tomcat)
java·spring cloud·nacos
命运之手1 个月前
[ Spring ] Nacos Config Auto Refresh 2025
spring·nacos·kotlin·config·refresh
Rinai_R1 个月前
【Golang/gRPC/Nacos】在golang中将gRPC和Nacos结合使用
经验分享·笔记·学习·微服务·nacos·golang·服务发现