# DB 模式

同样打开 application.yml,并修改为db,样例在 application.example

  1. 更改为db 注意:注册的是nacos,所以需要在nacos上增加配置文件
seata:
  config:
    # support: nacos, consul, apollo, zk, etcd3
    type: nacos
    nacos:
      server-addr: 124.222.183.73:8848
      namespace:
      group: SEATA_GROUP
      username:
      password:
      context-path:
      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key:
      #secret-key:
      data-id: seataServer.properties
  registry:
    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    type: nacos
    nacos:
      application: seata-server
      server-addr: 124.222.183.73:8848
      group: SEATA_GROUP
      namespace:
      cluster: default
      username:
      password:
      context-path:
  store:
    # support: file 、 db 、 redis
    mode: file
    db:
      datasource: druid
      db-type: mysql
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://rm-bp1ay69xv1jyb5d4cuo.mysql.rds.aliyuncs.com:3306/seata?rewriteBatchedStatements=true&serverTimezone=GMT+8
      user: rdsadmin
      password: Gao199810
      min-conn: 10
      max-conn: 100
      global-table: global_table
      branch-table: branch_table
      lock-table: lock_table
      distributed-lock-table: distributed_lock
      query-limit: 1000
      max-wait: 5000

  1. Nacos 配置文件 在nacos 上新建配置文件,data-id:seataServer.properties,注意分组名:SEATA_GROUP

配置文件内容在下载的文件里 script/config-center/config.txt

  1. config.txt
    1. 需要注意的是将model 改为db
    2. 将file 注释掉
    3. db 的连接地址
store.mode=db
store.lock.mode=db
store.session.mode=db
#Used for password encryption
store.publicKey=

#If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
#store.file.dir=file_store/data
#store.file.maxBranchSessionSize=16384
#store.file.maxGlobalSessionSize=512
#store.file.fileWriteBufferCacheSize=16384
#store.file.flushDiskMode=async
#store.file.sessionReloadReadSize=100

store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://rm-bp1ay69xv1jyb5d4cuo.mysql.rds.aliyuncs.com:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=rdsadmin
store.db.password=Gao199810
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.distributedLockTable=distributed_lock
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000