使用docker部署

  1. docker run --name seata-server \
  2. -p 8091:8091 \
  3. -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \
  4. -v /PATH/TO/CONFIG_FILE:/root/seata-config \
  5. seataio/seata-server:1.4.2

在nacos配置中心配置

image.png

seataServer.properties

  1. transport.type=TCP
  2. transport.server=NIO
  3. transport.heartbeat=true
  4. transport.enableClientBatchSendRequest=false
  5. transport.threadFactory.bossThreadPrefix=NettyBoss
  6. transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
  7. transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
  8. transport.threadFactory.shareBossWorker=false
  9. transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
  10. transport.threadFactory.clientSelectorThreadSize=1
  11. transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
  12. transport.threadFactory.bossThreadSize=1
  13. transport.threadFactory.workerThreadSize=default
  14. transport.shutdown.wait=3
  15. service.vgroupMapping.my_test_tx_group=default
  16. service.default.grouplist=192.168.2.20:32422
  17. service.enableDegrade=false
  18. service.disableGlobalTransaction=false
  19. client.rm.asyncCommitBufferLimit=10000
  20. client.rm.lock.retryInterval=10
  21. client.rm.lock.retryTimes=30
  22. client.rm.lock.retryPolicyBranchRollbackOnConflict=true
  23. client.rm.reportRetryCount=5
  24. client.rm.tableMetaCheckEnable=false
  25. client.rm.tableMetaCheckerInterval=60000
  26. client.rm.sqlParserType=druid
  27. client.rm.reportSuccessEnable=false
  28. client.rm.sagaBranchRegisterEnable=false
  29. client.tm.commitRetryCount=5
  30. client.tm.rollbackRetryCount=5
  31. client.tm.defaultGlobalTransactionTimeout=60000
  32. client.tm.degradeCheck=false
  33. client.tm.degradeCheckAllowTimes=10
  34. client.tm.degradeCheckPeriod=2000
  35. store.mode=db
  36. store.publicKey=
  37. store.file.dir=file_store/data
  38. store.file.maxBranchSessionSize=16384
  39. store.file.maxGlobalSessionSize=512
  40. store.file.fileWriteBufferCacheSize=16384
  41. store.file.flushDiskMode=async
  42. store.file.sessionReloadReadSize=100
  43. store.db.datasource=druid
  44. store.db.dbType=mysql
  45. store.db.driverClassName=com.mysql.jdbc.Driver
  46. store.db.url=jdbc:mysql://192.168.2.20:30569/seata?useUnicode=true&rewriteBatchedStatements=true
  47. store.db.user=root
  48. store.db.password=root
  49. store.db.minConn=5
  50. store.db.maxConn=30
  51. store.db.globalTable=global_table
  52. store.db.branchTable=branch_table
  53. store.db.queryLimit=100
  54. store.db.lockTable=lock_table
  55. store.db.maxWait=5000
  56. store.redis.mode=single
  57. store.redis.single.host=127.0.0.1
  58. store.redis.single.port=6379
  59. store.redis.sentinel.masterName=
  60. store.redis.sentinel.sentinelHosts=
  61. store.redis.maxConn=10
  62. store.redis.minConn=1
  63. store.redis.maxTotal=100
  64. store.redis.database=0
  65. store.redis.password=
  66. store.redis.queryLimit=100
  67. server.recovery.committingRetryPeriod=1000
  68. server.recovery.asynCommittingRetryPeriod=1000
  69. server.recovery.rollbackingRetryPeriod=1000
  70. server.recovery.timeoutRetryPeriod=1000
  71. server.maxCommitRetryTimeout=-1
  72. server.maxRollbackRetryTimeout=-1
  73. server.rollbackRetryTimeoutUnlockEnable=false
  74. client.undo.dataValidation=true
  75. client.undo.logSerialization=jackson
  76. client.undo.onlyCareUpdateColumns=true
  77. server.undo.logSaveDays=7
  78. server.undo.logDeletePeriod=86400000
  79. client.undo.logTable=undo_log
  80. client.undo.compress.enable=true
  81. client.undo.compress.type=zip
  82. client.undo.compress.threshold=64k
  83. log.exceptionRate=100
  84. transport.serialization=seata
  85. transport.compressor=none
  86. metrics.enabled=false
  87. metrics.registryType=compact
  88. metrics.exporterList=prometheus
  89. metrics.exporterPrometheusPort=9898

使用kubesphere部署

dockerhub

seataio/seata-server:1.4.2

资源分配

image.png

端口配置

image.png

同步主机时区

image.png

配置文件子路径挂载

* 默认使用路径挂载会覆盖容器内所有配置,所以如果只需要覆盖个别配置可以使用子路径)

/seata-server/resources/registry.conf

image.png

/seata-server/resources/file.confimage.png

configMap

seata-conf

file.conf

sql脚本在seata源码seata-1.4.2\script\server\db中

  1. ## transaction log store, only used in seata-server
  2. store {
  3. ## store mode: file、db、redis
  4. mode = "db"
  5. ## rsa decryption public key
  6. publicKey = ""
  7. ## file store property
  8. file {
  9. ## store location dir
  10. dir = "sessionStore"
  11. # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
  12. maxBranchSessionSize = 16384
  13. # globe session size , if exceeded throws exceptions
  14. maxGlobalSessionSize = 512
  15. # file buffer size , if exceeded allocate new buffer
  16. fileWriteBufferCacheSize = 16384
  17. # when recover batch read size
  18. sessionReloadReadSize = 100
  19. # async, sync
  20. flushDiskMode = async
  21. }
  22. service {
  23. #transaction service group mapping
  24. vgroupMapping.my_test_tx_group = "default"
  25. #only support when registry.type=file, please don't set multiple addresses
  26. default.grouplist = "192.168.2.20:32422"
  27. #degrade, current not support
  28. enableDegrade = false
  29. #disable seata
  30. disableGlobalTransaction = false
  31. }
  32. ## database store property
  33. db {
  34. ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
  35. datasource = "druid"
  36. ## mysql/oracle/postgresql/h2/oceanbase etc.
  37. dbType = "mysql"
  38. driverClassName = "com.mysql.jdbc.Driver"
  39. ## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
  40. url = "jdbc:mysql://192.168.2.20:30569/seata?rewriteBatchedStatements=true"
  41. user = "root"
  42. password = "root"
  43. minConn = 5
  44. maxConn = 100
  45. globalTable = "global_table"
  46. branchTable = "branch_table"
  47. lockTable = "lock_table"
  48. queryLimit = 100
  49. maxWait = 5000
  50. }
  51. ## redis store property
  52. redis {
  53. ## redis mode: single、sentinel
  54. mode = "single"
  55. ## single mode property
  56. single {
  57. host = "127.0.0.1"
  58. port = "6379"
  59. }
  60. ## sentinel mode property
  61. sentinel {
  62. masterName = ""
  63. ## such as "10.28.235.65:26379,10.28.235.65:26380,10.28.235.65:26381"
  64. sentinelHosts = ""
  65. }
  66. password = ""
  67. database = "0"
  68. minConn = 1
  69. maxConn = 10
  70. maxTotal = 100
  71. queryLimit = 100
  72. }
  73. }

registry.conf

  1. registry {
  2. # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  3. type = "nacos"
  4. nacos {
  5. application = "seata-server"
  6. serverAddr = "192.168.2.20:30010"
  7. group = "SEATA_GROUP"
  8. namespace = ""
  9. cluster = "default"
  10. username = "nacos"
  11. password = "nacos"
  12. }
  13. eureka {
  14. serviceUrl = "http://localhost:8761/eureka"
  15. application = "default"
  16. weight = "1"
  17. }
  18. redis {
  19. serverAddr = "localhost:6379"
  20. db = 0
  21. password = ""
  22. cluster = "default"
  23. timeout = 0
  24. }
  25. zk {
  26. cluster = "default"
  27. serverAddr = "127.0.0.1:2181"
  28. sessionTimeout = 6000
  29. connectTimeout = 2000
  30. username = ""
  31. password = ""
  32. }
  33. consul {
  34. cluster = "default"
  35. serverAddr = "127.0.0.1:8500"
  36. aclToken = ""
  37. }
  38. etcd3 {
  39. cluster = "default"
  40. serverAddr = "http://localhost:2379"
  41. }
  42. sofa {
  43. serverAddr = "127.0.0.1:9603"
  44. application = "default"
  45. region = "DEFAULT_ZONE"
  46. datacenter = "DefaultDataCenter"
  47. cluster = "default"
  48. group = "SEATA_GROUP"
  49. addressWaitTime = "3000"
  50. }
  51. file {
  52. name = "file.conf"
  53. }
  54. }
  55. config {
  56. # file、nacos 、apollo、zk、consul、etcd3
  57. type = "nacos"
  58. nacos {
  59. serverAddr = "192.168.2.20:30010"
  60. namespace = ""
  61. group = "SEATA_GROUP"
  62. username = "nacos"
  63. password = "nacos"
  64. dataId = "seataServer.properties"
  65. }
  66. consul {
  67. serverAddr = "127.0.0.1:8500"
  68. aclToken = ""
  69. }
  70. apollo {
  71. appId = "seata-server"
  72. ## apolloConfigService will cover apolloMeta
  73. apolloMeta = "http://192.168.1.204:8801"
  74. apolloConfigService = "http://192.168.1.204:8080"
  75. namespace = "application"
  76. apolloAccesskeySecret = ""
  77. cluster = "seata"
  78. }
  79. zk {
  80. serverAddr = "127.0.0.1:2181"
  81. sessionTimeout = 6000
  82. connectTimeout = 2000
  83. username = ""
  84. password = ""
  85. nodePath = "/seata/seata.properties"
  86. }
  87. etcd3 {
  88. serverAddr = "http://localhost:2379"
  89. }
  90. file {
  91. name = "file.conf"
  92. }
  93. }