seata环境搭建以及官方示例的坑

1、seataserver搭建(windows)

在建seata服务之前请搭建好nacos服务

官方的最新的为2.0.0版的,这个版本暂时有些问题,管理分布式事务时会报错。所以建议使用1.8的。

下载地址Releases · apache/incubator-seata (github.com)https://github.com/apache/incubator-seata/releases

下下来的报也有问题,解压后注意将低版本的包删掉

seata环境搭建以及官方示例的坑_第1张图片

修改其配置文件

D:\soft\seata-server-1.8.0\seata\conf\application.yml

seata:

  # nacos配置

  config:

    type: nacos

    nacos:

      server-addr: 172.25.212.71:8848

      namespace:

      group: SEATA_GROUP

      username: nacos

      password: nacos

      context-path:

      data-id: seata.properties

      ##if use MSE Nacos with auth, mutex with username/password attribute

      #access-key:

      #secret-key:

  registry:

    # nacos配置

    type: nacos

    nacos:

      application: seata-server

      server-addr: 172.25.212.71:8848

      group: SEATA_GROUP

      namespace:

      cluster: default

      username: nacos

      password: nacos

  # store:

  #   # support: file 、 db 、 redis

  #   mode: file

#  server:

#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'

2、新建数据库以及相关表

这个根据官网配置即可

3、新建nacos配置

seata.properties

#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html

#Transport configuration, for client and server

transport.type=TCP

transport.server=NIO

transport.heartbeat=true

transport.enableTmClientBatchSendRequest=false

transport.enableRmClientBatchSendRequest=true

transport.enableTcServerBatchSendResponse=false

transport.rpcRmRequestTimeout=30000

transport.rpcTmRequestTimeout=30000

transport.rpcTcRequestTimeout=30000

transport.threadFactory.bossThreadPrefix=NettyBoss

transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker

transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler

transport.threadFactory.shareBossWorker=false

transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector

transport.threadFactory.clientSelectorThreadSize=1

transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread

transport.threadFactory.bossThreadSize=1

transport.threadFactory.workerThreadSize=default

transport.shutdown.wait=3

transport.serialization=seata

transport.compressor=none

#Transaction routing rules configuration, only for the client

service.vgroupMapping.default_tx_group=default

service.vgroupMapping.order-service-tx-group=default

service.vgroupMapping.account-service-tx-group=default

service.vgroupMapping.business-service-tx-group=default

service.vgroupMapping.storage-service-tx-group=default

#If you use a registry, you can ignore it

service.default.grouplist=127.0.0.1:8091

service.enableDegrade=false

service.disableGlobalTransaction=false

#Transaction rule configuration, only for the client

client.rm.asyncCommitBufferLimit=10000

client.rm.lock.retryInterval=10

client.rm.lock.retryTimes=30

client.rm.lock.retryPolicyBranchRollbackOnConflict=true

client.rm.reportRetryCount=5

client.rm.tableMetaCheckEnable=true

client.rm.tableMetaCheckerInterval=60000

client.rm.sqlParserType=druid

client.rm.reportSuccessEnable=false

client.rm.sagaBranchRegisterEnable=false

client.rm.sagaJsonParser=fastjson

client.rm.tccActionInterceptorOrder=-2147482648

client.tm.commitRetryCount=5

client.tm.rollbackRetryCount=5

client.tm.defaultGlobalTransactionTimeout=60000

client.tm.degradeCheck=false

client.tm.degradeCheckAllowTimes=10

client.tm.degradeCheckPeriod=2000

client.tm.interceptorOrder=-2147482648

client.undo.dataValidation=true

client.undo.logSerialization=jackson

client.undo.onlyCareUpdateColumns=true

server.undo.logSaveDays=7

server.undo.logDeletePeriod=86400000

client.undo.logTable=undo_log

client.undo.compress.enable=true

client.undo.compress.type=zip

client.undo.compress.threshold=64k

#For TCC transaction mode

tcc.fence.logTableName=tcc_fence_log

tcc.fence.cleanPeriod=1h

#Log rule configuration, for client and server

log.exceptionRate=100

#Transaction storage configuration, only for the server. The file, DB, and redis configuration values are optional.

store.mode=db

store.lock.mode=db

store.session.mode=db

#Used for password encryption

store.publicKey=



 

#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.

store.db.datasource=druid

store.db.dbType=mysql

store.db.driverClassName=com.mysql.jdbc.Driver

store.db.url=jdbc:mysql://192.168.100.199:3306/seata_server?useSSL=false&useUnicode=true&rewriteBatchedStatements=true

store.db.user=root

store.db.password=123456

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

#Transaction rule configuration, only for the server

server.recovery.committingRetryPeriod=1000

server.recovery.asynCommittingRetryPeriod=1000

server.recovery.rollbackingRetryPeriod=1000

server.recovery.timeoutRetryPeriod=1000

server.maxCommitRetryTimeout=-1

server.maxRollbackRetryTimeout=-1

server.rollbackRetryTimeoutUnlockEnable=false

server.distributedLockExpireTime=10000

server.xaerNotaRetryTimeout=60000

server.session.branchAsyncQueueSize=5000

server.session.enableBranchAsyncRemove=false

server.raft.server-addr=127.0.0.1:7091,127.0.0.1:7092,127.0.0.1:7093

server.raft.snapshotInterval=600

server.raft.applyBatch=32

server.raft.maxAppendBufferSize=262144

server.raft.maxReplicatorInflightMsgs=256

server.raft.disruptorBufferSize=16384

server.raft.electionTimeoutMs=2000

server.raft.reporterEnabled=false

server.raft.reporterInitialDelay=60

server.raft.serialization=jackson

server.raft.compressor=none

server.raft.sync=true

#Metrics configuration, only for the server

metrics.enabled=false

metrics.registryType=compact

metrics.exporterList=prometheus

metrics.exporterPrometheusPort=9898

4、点击启动脚本

seata环境搭建以及官方示例的坑_第2张图片

5、部署服务

根据官网建好数据库表,将文章顶部的压缩包解压后,修改配置即可

你可能感兴趣的:(java,spring,boot,spring,cloud)