问题描述

no available service found in cluster ‘default’, please make sure registry config correct and keep your seata server running

seata客户端找不到可用的集群。

原因

seata客户端和服务端配置不一致导致的,对照着服务端,在代码中把客户端的配置一一修改之后重启项目问题消失了。如图:

  • 客户端配置

# seata配置
seata:
  enabled: true
  # Seata 应用编号,默认为 ${spring.application.name}
  application-id: ${spring.application.name}
  # Seata 事务组编号,用于 TC 集群名
  tx-service-group: ${spring.application.name}-group
  # 关闭自动代理
  enable-auto-data-source-proxy: false
  # 服务配置项
  service:
    # 虚拟组和分组的映射
    vgroup-mapping:
      paas-protocol-group: default
  config:
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
      namespace:
      #可选
      username: nacos
      #可选
      password: nacos
      # 这是默认值
      # data-id: seata.properties
      # 这是默认值
      group: SEATA_GROUP

  registry:
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
      namespace:
      #可选
      username: nacos
      #可选
      password: nacos
      #可选
      application: seata-server
      #默认值和 config 的 SEATA_GROUP 不一样 
      group: SEATA_GROUP
      # 可选  默认
      cluster: default 

  • 服务端配置
registry {
  type = "nacos"
  nacos {
    application = "seata-server"
    serverAddr = "127.0.0.1:8848"
    group = "SEATA_GROUP"
    namespace = ""
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}

config {
  type = "nacos"
  nacos {
    serverAddr = "127.0.0.1:8848"
    namespace = ""
    group = "SEATA_GROUP"
    username = "nacos"
    password = "nacos"
  }
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐