当前位置: 代码迷 >> 综合 >> SpringCloudAlibaba——Seata配置文件
  详细解决方案

SpringCloudAlibaba——Seata配置文件

热度:2   发布时间:2024-02-12 00:32:24.0

Seata配置文件详解

${SEATA_HOME}\conf目录下有两个配置文件,分别是registry.conf和file.conf。

registry.conf

registry.conf包含两项配置:

registry:表示配置Seata服务注册的地址,支持目前市面上所有主流的注册中心组件。它的配置非常简单,通过type指定注册中心的类型,然后根据指定的类型对应的服务地址信息,比如当type=nacos时,则匹配到Nacos的配置项如下:

type="nacos"
nacos {serverAddr = "localhost:8848" #指定自己的nacos地址namespace = ""cluster = "default"}

type默认为file,它表示不依赖于配置中心,在file类型下,可以不依赖第三方配置中心快速集成Seata,不过file类型不具备注册中心的动态发现和动态配置功能。

config:用于配置Seata服务端的配置文件地址,也就是可以通过config配置指定Seata服务端的配置信息的加载位置,它支持从远程配置中心读取和本地文件读取良好总方式。如果配置为远程配置中心,可以使用type指定,配置形式和registry相同:

type="nacos"
nacos {serverAddr = "localhost"namespace = ""
}

在默认情况下type=file,它会加载file.conf文件中的配置信息。

file.conf

file.conf存储的是Seata服务端的配置信息,完成配置如下。它包含transport、server、metrics,分别表示协议配置、服务端配置、监控:

transport {# tcp udt unix-domain-sockettype = "TCP"#NIO NATIVEserver = "NIO"#enable heartbeatheartbeat = true  #clien和server通信心跳检测开关#thread factory for nettythread-factory {boss-thread-prefix = "NettyBoss"worker-thread-prefix = "NettyServerNIOWorker"server-executor-thread-prefix = "NettyServerBizHandler"share-boss-worker = falseclient-selector-thread-prefix = "NettyClientSelector"client-selector-thread-size = 1client-worker-thread-prefix = "NettyClientWorkerThread"# netty boss thread size,will not be used for UDTboss-thread-size = 1#auto default pin or 8worker-thread-size = 8}shutdown {# when destroy server, wait secondswait = 3}serialization = "seata" #client和server通信编解码方式compressor = "none" #client和server通信数据压缩方式(none、gzip、默认为none)
}service {vgroup_mapping.fsp_tx_group = "default" #修改自定义事务组名称default.grouplist = "127.0.0.1:8091"enableDegrade = falsedisable = falsemax.commit.retry.timeout = "-1"max.rollback.retry.timeout = "-1"disableGlobalTransaction = false
}client {async.commit.buffer.limit = 10000lock {retry.internal = 10retry.times = 30}report.retry.count = 5tm.commit.retry.count = 1tm.rollback.retry.count = 1
}## 事务日志存储配置
store {## 存储类型,支持file和db,默认是filemode = "db"## file storefile {dir = "sessionStore"# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptionsmax-branch-session-size = 16384# globe session size , if exceeded throws exceptionsmax-global-session-size = 512# file buffer size , if exceeded allocate new bufferfile-write-buffer-cache-size = 16384# when recover batch read sizesession.reload.read_size = 100# async, syncflush-disk-mode = async}## 数据库存储的配置属性db {## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.datasource = "dbcp"## mysql/oracle/h2/oceanbase etc.db-type = "mysql"driver-class-name = "com.mysql.jdbc.Driver"url = "jdbc:mysql://127.0.0.1:3306/seata"user = "root"password = "123456"min-conn = 1max-conn = 3global.table = "global_table" #db模式全局事务表名branch.table = "branch_table" #db模式分支事务表名lock-table = "lock_table"  #db模式全局锁表名query-limit = 100  #db模式查询全局事务一次的最大条数}
}
lock {## the lock store mode: local、remotemode = "remote"local {## store locks in user's database}remote {## store locks in the seata's server}
}
recovery {#二段提交未完成状态全局事务重试提交线程间隔时间committing-retry-period = 1000#二阶段异步提交状态 重试提交线程间隔时间asyn-committing-retry-period = 1000#二阶段回滚状态 重试回滚线程间隔时间rollbacking-retry-period = 1000#超时状态监测重试线程间隔时间timeout-retry-period = 1000
}transaction {undo.data.validation = trueundo.log.serialization = "jackson"undo.log.save.days = 7 #undo保留天数#undo清理线程间隔时间(毫秒)undo.log.delete.period = 86400000undo.log.table = "undo_log"
}## metrics settings
metrics {enabled = false #是否启用metricsregistry-type = "compact" #指标注册器类型# multi exporters use comma dividedexporter-list = "prometheus" #指标结果Measurement数据输出器列表exporter-prometheus-port = 9898 #prometheus输出器Client端口号
}support {## springspring {# auto proxy the DataSource beandatasource.autoproxy = false }
}
  相关解决方案