文章目录

  • 一、详细报错信息
  • 二、原因分析
    • 原因1:`service.vgroupMapping`配置的服务组名称不符合Seata默认要求;
    • 原因2:`service.vgroupMapping`配置的seata集群名称没有对应的grouplist
  • 三、解决方案
    • 方案1、将file.conf中service.vgroupMapping配置调整为`${spring.application.name}-seata-service-group`;
    • 方案二、在application.yml中指定`seata.tx-service-group`
      • spring.cloud.alibaba.seata.tx-service-group 和 seata.tx-service-group
  • 四、seata集群名称的坑

一、详细报错信息

springcloud 集成 seata1.3.0 时报错:

2022-08-04 00:00:00.000 ERROR 78958 --- [eoutChecker_2_1] i.s.c.r.netty.NettyClientChannelManager  : Failed to get available servers: endpoint format should like ip:portjava.lang.IllegalArgumentException: endpoint format should like ip:portat io.seata.discovery.registry.FileRegistryServiceImpl.lookup(FileRegistryServiceImpl.java:95) ~[seata-all-1.3.0.jar:1.3.0]at io.seata.core.rpc.netty.NettyClientChannelManager.getAvailServerList(NettyClientChannelManager.java:217) ~[seata-all-1.3.0.jar:1.3.0]at io.seata.core.rpc.netty.NettyClientChannelManager.reconnect(NettyClientChannelManager.java:162) ~[seata-all-1.3.0.jar:1.3.0]at io.seata.core.rpc.netty.AbstractNettyRemotingClient$1.run(AbstractNettyRemotingClient.java:106) [seata-all-1.3.0.jar:1.3.0]at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_275]at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_275]at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_275]at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_275]at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_275]at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_275]at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.58.Final.jar:4.1.58.Final]at java.lang.Thread.run(Thread.java:748) [na:1.8.0_275]

二、原因分析

本文基于seata1.3.0版本,代表这1.X的版本,0.x版本的略有不同。

在文件类型的注册服务时,会通过FileRegistryServiceImpl#lookup(String)方法根据VgroupMapping的key去寻找可用的Seata-server实例;报错的体现正是无法根据service.VgroupMapping这个配置找到具体的Seata实例(IP:PORT信息);

几个字符串常量值如下:

        String PREFIX_SERVICE_MAPPING = "vgroupMapping.";String PREFIX_SERVICE_ROOT = "service";String CONFIG_SPLIT_CHAR = ".";private static final String POSTFIX_GROUPLIST = ".grouplist";private static final String ENDPOINT_SPLIT_CHAR = ";";private static final String IP_PORT_SPLIT_CHAR = ":";

获取当前服务组名称对应的seata集群名称的代码逻辑如下:

针对 service.vgroupMapping,官方案例:Spring Cloud 快速集成 Seata是这么说的:

划重点:需要注意的是 service.vgroupMapping这个配置,在 Spring Cloud 中默认是${spring.application.name}-fescar-service-group

再看博主debug时的默认 service.vgroupMapping配置,居然是${spring.application.name}-seata-service-group

  • 我程序的spring.application.nametrade-center
  • service.vgroupMapping的配置为trade-center-seata-service-group不说好的是${spring.application.name}-fescar-service-group吗!!!!!!!

等下我们再继续说,先让我喷一会:***********,官方文档不更新的吗?不注意版本之间的差异吗?不标明版本差异吗?******

所以原因本质上只有一个:无法根据service.VgroupMapping这个配置找到具体的Seata实例(IP:PORT信息);但导致该原因产生的方式会有很多种;

原因1:service.vgroupMapping配置的服务组名称不符合Seata默认要求;

前提:不在application.yml配置文件中手动通过seata.tx-service-group属性指定seata服务组名称。

默认 service.vgroupMapping这个配置,在 Spring Cloud 中默认是${spring.application.name}-seata-service-group

所以,当我们未按${spring.application.name}-seata-service-group这个规则配置service.vgroupMapping时会报错。

报错配置样例:

解决方案对应下面的方案一、方案二。

原因2:service.vgroupMapping配置的seata集群名称没有对应的grouplist

比如:这里我配置的service.vgroupMapping值为seata-server-sh,而配置的grouplist是属于default的;

所以报错是因为通过service.vgroupMapping配置找到seata集群名称seata-server-sh,但是seata-server-sh没有对应的grouplist,即seata实例信息。

解决方案:把grouplist的的所属方调整为和service.vgroupMapping配置的seata集群名称一致;

三、解决方案

方案1、将file.conf中service.vgroupMapping配置调整为${spring.application.name}-seata-service-group

就博主程序而言,application.yml、file.conf配置如下:

1> application.yml:

spring:application:name: trade-center

2> file.conf关键配置:

方案二、在application.yml中指定seata.tx-service-group

就博主程序而言,application.yml、file.conf配置如下:

1> application.yml:

spring:application:name: trade-center
seata:# tx-service-group的值一定要和file.conf中service.vgroupMapping配置对应上tx-service-group: saint_trade_tx_group

或者使用:

spring:application:name: trade-centercloud:alibaba:seata:# tx-service-group的值一定要和file.conf中service.vgroupMapping配置对应上tx-service-group: saint_trade_tx_group

2> file.conf关键配置:

我们注意到可以使用spring.cloud.alibaba.seata.tx-service-groupseata.tx-service-group 属性指定service.vgroupMapping配置,为啥呢?

spring.cloud.alibaba.seata.tx-service-group 和 seata.tx-service-group

spring.cloud.alibaba.seata.tx-service-group 属于SpringCloudAlibabaConfiguration类:

seata.tx-service-group 属性属于SeataProperties类:

SeataProperties类又被注解@EnableConfigurationProperties(SpringCloudAlibabaConfiguration.class)标注,所以会使SpringCloudAlibabaConfiguration的配置生效;又SeataProperties类中通过@Autowired的方式组合了SpringCloudAlibabaConfiguration,在通过getTxServiceGroup()方法获取txServiceGroup属性时如果SeataProperties类自己没有配置txServiceGroup,则从SpringCloudAlibabaConfiguration中获取;

简单来说;就是优先取 seata.tx-service-group 属性值,没有则再取spring.cloud.alibaba.seata.tx-service-group属性值。

四、seata集群名称的坑

seata-server和 项目程序 部署在不同的机器上时,可能会出现 can not connect to services-server

如果配置的 default.grouplist = “192.168.7.254:8091”,则并不会生效,default.grouplist读取的还是默认的127.0.0.1:8091

建议把seata集群名称调整为非dafault,例如:

service {vgroupMapping.saint_trade_tx_group = "seata-server-sh"seata-server-sh.grouplist = "127.0.0.1:8091"
}

Seata Failed to get available servers: endpoint format should like ip:port 报错原因/解决方案汇总版(看完本文必解决问题)相关推荐

  1. seata: endpoint format should like ip:port

    springcloud 集成 seata1.3.0 报错endpoint format should like ip:port. 不瞒各位说,搞了我一下午. 1. 错误日志 2021-03-02 16 ...

  2. Seata异常:endpoint format should like ip:port

    报错信息 Failed to get available servers: endpoint format should like ip:portjava.lang.IllegalArgumentEx ...

  3. exec failed: exec failed..... exec: “ip“(Docker容器没有ip addr命令:ex(Docker容器没有ip addr命令:exec ip addr 报错)

    一.报错 1.报错信息1: OCI runtime exec failed: exec failed: container_linux.go:380: starting container proce ...

  4. 视觉SLAM十四讲 报错ch13 问题汇总 /usr/bin/ld: /usr/local/lib/libfmt.a(format.cc.o)

    视觉SLAM十四讲 报错ch13 /usr/bin/ld: /usr/local/lib/libfmt.a 1. 问题1:未链接fmt库 1.1 解决方案 2. 问题2:-fPIC 2.1 解决方案 ...

  5. pandas.read_csv() 报错 OSError: Initializing from file failed,报错原因分析和解决方法

    今天调用pandas读取csv文件时,突然报错" OSError: Initializing from file failed ",我是有点奇怪的,以前用的好好的,read_csv ...

  6. Laravel 发送邮件报错的解决方案:PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.

    在搭建好私人邮箱服务器后,正好做了一个共享主机的产品,就需要在申请共享主机后给用户发通知,遇到这个报错: PHP Warning: stream_socket_enable_crypto(): SSL ...

  7. Error: Loading chunk * failed,Vue Router懒加载报错问题解决方案

    最近vue项目路由改成了懒加载方式,刚开始并没有什么问题,清空项目文件,重新下载配置运行后,就发现控制台报以下错误: [vue-router] Failed to resolve async comp ...

  8. This application failed to start because no Qt platform plugin could be initialized. 报错解决方法

    类似This application failed to start because no Qt platform plugin could be initialized 这种情况的报错,网络上会给出 ...

  9. 关于custom validator check failed for prop “dataSource“.的报错原因

    报错:custom validator check failed for prop "dataSource". 问题来源:最近在使用antdv的穿梭框时,在嵌套树形结构时候报了这个 ...

最新文章

  1. 大厂程序员和北京户口教师女友买房分歧,要求分配产权怕离婚扯皮
  2. 四十一、Vue项目上手 | 用户管理系统 实现用户修改和删除功能(完成篇)
  3. JAVA面试题(part4)--控制跳转语句
  4. recycleview 使用详解,添加头部尾部,混合item,侧滑菜单,跳转到指定位置,实现九宫格布局
  5. tu-ctf-2016:re-for-50-plz-50
  6. for循环使用后contains方法失去效果
  7. 吉珠计算机科学 2a,2B院校 ∣ 让数据告诉你,考上插本难不难?
  8. 数字逻辑电路中的逻辑运算法则--与、或、非、与非、或非、异或、同或
  9. 零粉丝直播带货,日赚两万是真是假?最新抖音直播玩法!
  10. 仿携程oracle课程设计,一个不错的仿携程自定义数据下拉选择select
  11. 常见的请求错误HTTP状态码
  12. 硅谷“钢铁侠”:最不爱钱的人,却成了最有钱的人!
  13. 大数据开发之常用软件
  14. StatusBarUtil 状态栏工具类
  15. DTcmsV4.0分析学习——(1)数据库结构分析
  16. 一到冬天就手脚冰凉是怎么回事?宝宝手脚冰凉怎么办?
  17. 删除重复数据只保留一条数据
  18. Mac OS X 背后的故事(六)Cordell Ratzlaff 引发的 Aqua 革命
  19. 怎样用计算机打出Abc,电脑智能ABC输入法怎么设置输入功能?
  20. 计算机基础教学计划百度云,计算机基础教学计划(最新版).doc

热门文章

  1. 用ros输出hello,world(c++版)
  2. SDHC (High Capacity SD Memory Card)
  3. ## STM32——闪烁灯程序
  4. DDR5 trainning
  5. 写作活动第三期!让我们再挣200元稿费吧!
  6. python列表逆序
  7. Qt示例解析 【Callout】
  8. 中医针灸学综合练习题库【12】
  9. HTTP:SSL证书简介!
  10. 干货满满!解密阿里云RPA (机器人流程自动化)的产品架构和商业化发展