apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.23k stars 8.76k forks source link

关于配置seata.service.grouplist的问题 #2907

Open vhelp6512 opened 4 years ago

vhelp6512 commented 4 years ago

问题1: seata1.3.0客户端一定要配置 seata.service.grouplist.seata-server=xx.xx.xx.xx:8091 问题在于 seata集群以后这个位置应该怎么填写。 问题2: seata1.1.0之后客户端已经支持用yaml文件替代xx.cong文件。可是配置了yaml后还是报错。

tanzzj commented 4 years ago

grouplist应该用于file模式,集群模式请使用注册中心,微服务通过注册中心拿到server地址

vhelp6512 commented 4 years ago

grouplist应该用于文件模式,移植模式请使用注册中心,微服务通过注册中心拿到服务器地址

我也很奇怪我设置都是是nacos模式 不配seata.service.grouplist.seata-server=xxx.xx.xx.xxx:8091这个参数就会抛错 java.lang.IllegalArgumentException: seata-server.grouplist is required

li-qr commented 4 years ago

io.seata.discovery.registry.FileRegistryServiceImpl#lookup

    @Override
    public List<InetSocketAddress> lookup(String key) throws Exception {
        String clusterName = getServiceGroup(key);
        if (clusterName == null) {
            return null;
        }
        String endpointStr = CONFIG.getConfig(
            PREFIX_SERVICE_ROOT + CONFIG_SPLIT_CHAR + clusterName + POSTFIX_GROUPLIST);
        if (StringUtils.isNullOrEmpty(endpointStr)) {
            throw new IllegalArgumentException(clusterName + POSTFIX_GROUPLIST + " is required");   
        }  
        String[] endpoints = endpointStr.split(ENDPOINT_SPLIT_CHAR);
        List<InetSocketAddress> inetSocketAddresses = new ArrayList<>();
        for (String endpoint : endpoints) {
            String[] ipAndPort = endpoint.split(IP_PORT_SPLIT_CHAR);
            if (ipAndPort.length != 2) {
                throw new IllegalArgumentException("endpoint format should like ip:port");
            }
            inetSocketAddresses.add(new InetSocketAddress(ipAndPort[0], Integer.parseInt(ipAndPort[1])));
        }
        return inetSocketAddresses;
    }

io/seata/config/ConfigurationFactory.java:47

    static {
        String seataConfigName = System.getProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME);
        if (seataConfigName == null) {
            seataConfigName = System.getenv(ENV_SEATA_CONFIG_NAME);
        }
        if (seataConfigName == null) {
            seataConfigName = REGISTRY_CONF_PREFIX;
        }
        String envValue = System.getProperty(ENV_PROPERTY_KEY);
        if (envValue == null) {
            envValue = System.getenv(ENV_SYSTEM_KEY);
        }
        Configuration configuration = (envValue == null) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX,
            false) : new FileConfiguration(seataConfigName + "-" + envValue + REGISTRY_CONF_SUFFIX, false);
        Configuration extConfiguration = null;
        try {
            extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration);
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("load Configuration:{}", extConfiguration == null ? configuration.getClass().getSimpleName()
                    : extConfiguration.getClass().getSimpleName());
            }
        } catch (EnhancedServiceNotFoundException ignore) {

        } catch (Exception e) {
            LOGGER.error("failed to load extConfiguration:{}", e.getMessage(), e);
        }
        CURRENT_FILE_INSTANCE = extConfiguration == null ? configuration : extConfiguration;
    }

1,从代码上看读的还是xx.conf文件 2,从报错上看使用的还是file模式,也就是说你配置的nacos可能没有生效

BoyceMa commented 4 years ago

grouplist应该用于文件模式,移植模式请使用注册中心,微服务通过注册中心拿到服务器地址

我也很奇怪我设置都是是nacos模式 不配seata.service.grouplist.seata-server=xxx.xx.xx.xxx:8091这个参数就会抛错 java.lang.IllegalArgumentException: seata-server.grouplist is required

registry.conf > config > type 需要配置:”nacos“

vhelp6512 commented 4 years ago

io.seata.discovery.registry.FileRegistryServiceImpl#lookup

    @覆盖
    公共 列表< 的InetSocketAddress >查找(字符串键)抛出异常 {
         字符串 CLUSTERNAME = getServiceGroup(键);
        如果(clusterName ==  null){
             返回 null ;
        }
        字符串 endpointStr =  CONFIG 。getConfig(
             PREFIX_SERVICE_ROOT  +  CONFIG_SPLIT_CHAR  + clusterName +  POSTFIX_GROUPLIST);
        如果(StringUtils的。 isNullOrEmpty(endpointStr)){
             抛出 新 抛出:IllegalArgumentException(CLUSTERNAME +  POSTFIX_GROUPLIST  +  “需要”);   
        }  
        字符串 []端点= endpointStr 。split(ENDPOINT_SPLIT_CHAR);
        List < InetSocketAddress > inetSocketAddresses =  new  ArrayList <>();
        for(字符串端点:端点){
             字符串 [] ipAndPort =端点。分割(IP_PORT_SPLIT_CHAR);
            如果(ipAndPort 。长!=  2){
                 抛出 新的 抛出:IllegalArgumentException(“端点格式应该像ip:port ”);
            }
            inetSocketAddresses 。添加(新 的InetSocketAddress(ipAndPort [ 0 ],整数。 parseInt函数(ipAndPort [ 1 ])));
        }
        返回 inetSocketAddresses;
    }

io / seata / config / ConfigurationFactory.java:47

    静态 {
         字符串 seataConfigName =  System 。getProperty(SYSTEM_PROPERTY_SEATA_CONFIG_NAME);
        如果(seataConfigName ==  null){
            seataConfigName =  系统。getenv(ENV_SEATA_CONFIG_NAME);
        }
        如果(seataConfigName ==  null){
            seataConfigName =  REGISTRY_CONF_PREFIX ;
        }
        字符串 envValue =  System 。getProperty(ENV_PROPERTY_KEY);
        如果(envValue ==  null){
            envValue =  系统。getenv(ENV_SYSTEM_KEY);
        }
        配置的配置=(envValue ==  空)? 新的 FileConfiguration(seataConfigName +  REGISTRY_CONF_SUFFIX,
             false): 新的 FileConfiguration(seataConfigName +  “ - ”  + envValue +  REGISTRY_CONF_SUFFIX,false);
        配置 extConfiguration =  null ;
        尝试 {
            extConfiguration =  EnhancedServiceLoader 。负载(ExtConfigurationProvider 。类)。提供(配置);
            如果(记录器。 isInfoEnabled()){
                 LOGGER 。信息(“负载配置:{} ”,extConfiguration ==  空 ?配置。的getClass() 。 getSimpleName()
                    : extConfiguration 。的getClass() 。 getSimpleName());
            }
        } catch(EnhancedServiceNotFoundException忽略){

        } catch(异常 e){
             LOGGER 。误差(“未能加载extConfiguration:{} ”,E 。的getMessage()中,e);
        }
        CURRENT_FILE_INSTANCE  = extConfiguration ==  空 吗?配置: extConfiguration;
    }

1,从代码上看读的还是xx.conf文件 2,从报错上看使用的还是文件模式,从而你配置的nacos可能没有生效

registry {  type = "nacos"  nacos {    application = "seata-server"    serverAddr = "nacos.xxxxx.top" #域名听过 nginx转发    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    cluster = "default"    username = "nacos"    password = "nacos" } } config {  type = "nacos"  nacos {    serverAddr = "nacos.xxxxx.top"    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    group = "SEATA_GROUP"    username = "nacos"    password = "nacos" } } 我已经使用nacos了并确定已经使用nacos上的配置了。也是很纠结 搭建方式:nacos1.3.1 集群 搭建方式:setat:1.3.0 集群

客户端配置 spring.cloud.alibaba.seata.tx-service-group=luckdraw-service-group seata.service.vgroupMapping.luckdraw-service-group=seata-server seata.service.grouplist.seata-server=106.53.xxx.xxx:8091 #这个不配会报错正常市场nacos后可以不用配置

还是会出现上面那个问题

vhelp6512 commented 4 years ago

grouplist应该用于文件模式,移植模式请使用注册中心,微服务通过注册中心拿到服务器地址

我也很奇怪我设置都是nacos模式 不配seata.service.grouplist.seata-server = xxx.xx.xx.xxx:8091这个参数就会抛错 java.lang.IllegalArgumentException:seata-server.grouplist是必需的

Registry.conf>配置>类型需要配置:“ nacos”

registry {  type = "nacos"  nacos {    application = "seata-server"    serverAddr = "nacos.xxxxx.top" #域名听过 nginx转发    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    cluster = "default"    username = "nacos"    password = "nacos" } } config {  type = "nacos"  nacos {    serverAddr = "nacos.xxxxx.top"    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    group = "SEATA_GROUP"    username = "nacos"    password = "nacos" } } 我已经使用nacos了并确定已经使用nacos上的配置了。也是很纠结 搭建方式:nacos1.3.1 集群 搭建方式:setat:1.3.0 集群

客户端配置 spring.cloud.alibaba.seata.tx-service-group=luckdraw-service-group seata.service.vgroupMapping.luckdraw-service-group=seata-server seata.service.grouplist.seata-server=106.53.xxx.xxx:8091 #这个不配会报错正常市场nacos后可以不用配置

还是会出现上面那个问题

BoyceMa commented 4 years ago

grouplist应该用于文件模式,移植模式请使用注册中心,微服务通过注册中心拿到服务器地址

我也很奇怪我设置都是nacos模式 不配seata.service.grouplist.seata-server = xxx.xx.xx.xxx:8091这个参数就会抛错 java.lang.IllegalArgumentException:seata-server.grouplist是必需的

Registry.conf>配置>类型需要配置:“ nacos”

registry {  type = "nacos"  nacos {    application = "seata-server"    serverAddr = "nacos.xxxxx.top" #域名听过 nginx转发    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    cluster = "default"    username = "nacos"    password = "nacos" } } config {  type = "nacos"  nacos {    serverAddr = "nacos.xxxxx.top"    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    group = "SEATA_GROUP"    username = "nacos"    password = "nacos" } } 我已经使用nacos了并确定已经使用nacos上的配置了。也是很纠结 搭建方式:nacos1.3.1 集群 搭建方式:setat:1.3.0 集群

客户端配置 spring.cloud.alibaba.seata.tx-service-group=luckdraw-service-group seata.service.vgroupMapping.luckdraw-service-group=seata-server seata.service.grouplist.seata-server=106.53.xxx.xxx:8091 #这个不配会报错正常市场nacos后可以不用配置

还是会出现上面那个问题

image 这个是客户端registry.conf里面的配置吗?

vhelp6512 commented 4 years ago

grouplist应该用于文件模式,移植模式请使用注册中心,微服务通过注册中心拿到服务器地址

我也很奇怪我设置都是nacos模式 不配seata.service.grouplist.seata-server = xxx.xx.xx.xxx:8091这个参数就会抛错 java.lang.IllegalArgumentException:seata-server.grouplist是必需的

Registry.conf>配置>类型需要配置:“ nacos”

registry {  type = "nacos"  nacos {    application = "seata-server"    serverAddr = "nacos.xxxxx.top" #域名听过 nginx转发    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    cluster = "default"    username = "nacos"    password = "nacos" } } config {  type = "nacos"  nacos {    serverAddr = "nacos.xxxxx.top"    namespace = "eb81b17f-e9df-4904-b73c-bd0340124762"    group = "SEATA_GROUP"    username = "nacos"    password = "nacos" } } 我已经使用nacos了并确定已经使用nacos上的配置了。也是很纠结 搭建方式:nacos1.3.1 集群 搭建方式:setat:1.3.0 集群 客户端配置 spring.cloud.alibaba.seata.tx-service-group=luckdraw-service-group seata.service.vgroupMapping.luckdraw-service-group=seata-server seata.service.grouplist.seata-server=106.53.xxx.xxx:8091 #这个不配会报错正常市场nacos后可以不用配置 还是会出现上面那个问题

image 这个是客户端registry.conf里面的配置吗?

是的。

LiuPing95 commented 4 years ago

用yml时需要导入的依赖不一样

zhihaoHappyeveryday commented 3 years ago

用yml时需要导入的依赖不一样

怎么不一样, 我也是遇到了这个问题, 2个都要配置, registry.type=是等于nacos的, 但是还是需要2个地方都需要配置, 其中一个没配置就报连接不上seata服务, 默认去连本地了。 错误信息: `2020-10-27 18:37:58.859 ERROR 2944 --- [ main] i.s.c.r.netty.NettyClientChannelManager : 0101 can not connect to 127.0.0.1:8091 cause:can not register RM,err:can not connect to services-server.

io.seata.common.exception.FrameworkException: can not register RM,err:can not connect to services-server.`

AngusZhang commented 3 years ago

用yml时需要导入的依赖不一样

补充下这个兄弟的回复 引入 starter 之后,文件配置会被 yml 配置覆盖,如果 yml 文件中没有相关配置,registry.conf 中的配置会被默认配置覆盖,也就是 config.type 会变成file。 如果只需要使用 registry.conf 中的内容,可以参照下面配置

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-seata</artifactId>
    <version>2.1.0.RELEASE</version>
    <exclusions>
        <exclusion>
            <artifactId>seata-all</artifactId>
            <groupId>io.seata</groupId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>io.seata</groupId>
    <artifactId>seata-all</artifactId>
    <version>1.3.0</version>
</dependency>
2608027102 commented 3 years ago

grouplist应该用于file模式,集群模式请使用注册中心,微服务通过注册中心拿到server地址

你好,请教一个问题,我本地使用nacos做注册中心,但是并不想使用他的配置中心功能,所以我本地客户端是这样配置的

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"

  nacos {
    application="seata-server"
    serverAddr = "localhost:8848"
    namespace = ""
    cluster = "default"
    group="SEATA_GROUP"
    username="nacos"
    password="nacos"
  }
}

config {
  # file、nacos 、apollo、zk、consul、etcd3、springCloudConfig
  type = "file"

  file {
    name = "file.conf"
  }
}

按照我的理解,既然已经配置了注册中心了,为什么服务不能从注册中心获取tc地址呢?为什么还需要在file.conf中人工指定tc的地址。

transport {
  # tcp udt unix-domain-socket
  type = "TCP"
  #NIO NATIVE
  server = "NIO"
  #enable heartbeat
  heartbeat = true
  # the client batch send request enable
  enableClientBatchSendRequest = true
  #thread factory for netty
  threadFactory {
    bossThreadPrefix = "NettyBoss"
    workerThreadPrefix = "NettyServerNIOWorker"
    serverExecutorThread-prefix = "NettyServerBizHandler"
    shareBossWorker = false
    clientSelectorThreadPrefix = "NettyClientSelector"
    clientSelectorThreadSize = 1
    clientWorkerThreadPrefix = "NettyClientWorkerThread"
    # netty boss thread size,will not be used for UDT
    bossThreadSize = 1
    #auto default pin or 8
    workerThreadSize = "default"
  }
  shutdown {
    # when destroy server, wait seconds
    wait = 3
  }
  serialization = "seata"
  compressor = "none"
}

service {
  #transaction service group mapping
  vgroupMapping.my_group = "seata-server"
  #only support when registry.type=file, please don't set multiple addresses
#     vgroup-mapping.my_group = "storage-service"
#   storage-service.grouplist = "seata-server"
# 为什么这里还需要人工指定tc的地址???
  seata-server.grouplist = "172.24.53.136:18091"
  #degrade, current not support
  enableDegrade = false
  #disable seata
  disableGlobalTransaction = false
}

client {
  rm {
    asyncCommitBufferLimit = 10000
    lock {
      retryInterval = 10
      retryTimes = 30
      retryPolicyBranchRollbackOnConflict = true
    }
    reportRetryCount = 5
    tableMetaCheckEnable = false
    reportSuccessEnable = false
  }
  tm {
    commitRetryCount = 5
    rollbackRetryCount = 5
  }
  undo {
    dataValidation = true
    logSerialization = "jackson"
    logTable = "undo_log"
  }
  log {
    exceptionRate = 100
  }
}
fangyawei-next commented 2 months ago

回复:引入 starter 之后,文件配置会被 yml 配置覆盖,如果 yml 文件中没有相关配置,registry.conf 中的配置会被默认配置覆盖,也就是 config.type 会变成file

为什么呀,脑壳痛,不用start就好了,之前grouplist还死活配不上,吐了。是不是代表引入start可以直接在里面配seata的配置,反正都会覆盖,还配什么seata配置