SpringCloudAlibaba——Seata配置文件

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-socket
  type = "TCP"
  #NIO NATIVE
  server = "NIO"
  #enable heartbeat
  heartbeat = true  #clien和server通信心跳检测开关
  #thread factory for netty
  thread-factory {
    boss-thread-prefix = "NettyBoss"
    worker-thread-prefix = "NettyServerNIOWorker"
    server-executor-thread-prefix = "NettyServerBizHandler"
    share-boss-worker = false
    client-selector-thread-prefix = "NettyClientSelector"
    client-selector-thread-size = 1
    client-worker-thread-prefix = "NettyClientWorkerThread"
    # netty boss thread size,will not be used for UDT
    boss-thread-size = 1
    #auto default pin or 8
    worker-thread-size = 8
  }
  shutdown {
    # when destroy server, wait seconds
    wait = 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 = false
  disable = false
  max.commit.retry.timeout = "-1"
  max.rollback.retry.timeout = "-1"
  disableGlobalTransaction = false
}


client {
  async.commit.buffer.limit = 10000
  lock {
    retry.internal = 10
    retry.times = 30
  }
  report.retry.count = 5
  tm.commit.retry.count = 1
  tm.rollback.retry.count = 1
}

## 事务日志存储配置
store {
  ## 存储类型,支持file和db,默认是file
  mode = "db"

  ## file store
  file {
    dir = "sessionStore"

    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
    max-branch-session-size = 16384
    # globe session size , if exceeded throws exceptions
    max-global-session-size = 512
    # file buffer size , if exceeded allocate new buffer
    file-write-buffer-cache-size = 16384
    # when recover batch read size
    session.reload.read_size = 100
    # async, sync
    flush-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 = 1
    max-conn = 3
    global.table = "global_table" #db模式全局事务表名
    branch.table = "branch_table" #db模式分支事务表名
    lock-table = "lock_table"  #db模式全局锁表名
    query-limit = 100  #db模式查询全局事务一次的最大条数
  }
}
lock {
  ## the lock store mode: local、remote
  mode = "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 = true
  undo.log.serialization = "jackson"
  undo.log.save.days = 7 #undo保留天数
  #undo清理线程间隔时间(毫秒)
  undo.log.delete.period = 86400000
  undo.log.table = "undo_log"
}

## metrics settings
metrics {
  enabled = false #是否启用metrics
  registry-type = "compact" #指标注册器类型
  # multi exporters use comma divided
  exporter-list = "prometheus" #指标结果Measurement数据输出器列表
  exporter-prometheus-port = 9898 #prometheus输出器Client端口号
}

support {
  ## spring
  spring {
    # auto proxy the DataSource bean
    datasource.autoproxy = false 
  }
}

你可能感兴趣的:(Seata,配置文件)