背景

Alibaba Seata版本采用的是:1.4.0

一、下载

具体地址:https://github.com/seata/seata/releases/tag/v1.4.0

二、配置

官方新人参考文档地址:
http://seata.io/zh-cn/docs/ops/deploy-guide-beginner.html

解压后,找到conf目录,把 file.conf 和 registry.conf 先备份一份。
如图:
image.png
打开 file.conf 修改:

  1. ## transaction log store, only used in seata-server
  2. store {
  3. ## store mode: file、db、redis
  4. #mode = "file"
  5. #修改为DB模式
  6. mode = "db"
  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. ## database store property
  23. db {
  24. ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
  25. datasource = "druid"
  26. ## mysql/oracle/postgresql/h2/oceanbase etc.
  27. dbType = "mysql"
  28. driverClassName = "com.mysql.jdbc.Driver"
  29. #这里修改成为自己的数据地址
  30. url = "jdbc:mysql://127.0.0.1:3308/seata_config?serverTimezone=UTC"
  31. #自己数据库的用户名
  32. user = "root"
  33. #自己数据库的密码
  34. password = "123456"
  35. minConn = 5
  36. maxConn = 100
  37. #这里需要的脚本文件在官方文档里有
  38. globalTable = "global_table"
  39. branchTable = "branch_table"
  40. lockTable = "lock_table"
  41. queryLimit = 100
  42. maxWait = 5000
  43. }
  44. ## redis store property
  45. redis {
  46. host = "127.0.0.1"
  47. port = "6379"
  48. password = ""
  49. database = "0"
  50. minConn = 1
  51. maxConn = 10
  52. maxTotal = 100
  53. queryLimit = 100
  54. }
  55. }

file.conf 文件 db 模式中需要的脚本
官方地址:https://github.com/seata/seata/tree/1.4.0/script/server/db
具体 mysql 版的地址:https://github.com/seata/seata/blob/develop/script/server/db/mysql.sql
将脚本复制到数据库中去执行。

打开 registry.conf 文件修改:

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  #type = "file"
  #修改类型为nacos注册,如果需要的是文件类型则不需要修改
  type = "nacos"
  loadBalance = "RandomLoadBalance"
  loadBalanceVirtualNodes = 10

  nacos {
    application = "seata-server"
    serverAddr = "127.0.0.1:8848"
    group = "SEATA_GROUP"
    namespace = ""
    cluster = "default"
    username = ""
    password = ""
  }
  eureka {
    serviceUrl = "http://localhost:8761/eureka"
    application = "default"
    weight = "1"
  }
  redis {
    serverAddr = "localhost:6379"
    db = 0
    password = ""
    cluster = "default"
    timeout = 0
  }
  zk {
    cluster = "default"
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
  }
  consul {
    cluster = "default"
    serverAddr = "127.0.0.1:8500"
  }
  etcd3 {
    cluster = "default"
    serverAddr = "http://localhost:2379"
  }
  sofa {
    serverAddr = "127.0.0.1:9603"
    application = "default"
    region = "DEFAULT_ZONE"
    datacenter = "DefaultDataCenter"
    cluster = "default"
    group = "SEATA_GROUP"
    addressWaitTime = "3000"
  }
  file {
    name = "file.conf"
  }
}

config {
  # file、nacos 、apollo、zk、consul、etcd3
  type = "file"

  nacos {
    serverAddr = "127.0.0.1:8848"
    namespace = ""
    group = "SEATA_GROUP"
    username = ""
    password = ""
  }
  consul {
    serverAddr = "127.0.0.1:8500"
  }
  apollo {
    appId = "seata-server"
    apolloMeta = "http://192.168.1.204:8801"
    namespace = "application"
    apolloAccesskeySecret = ""
  }
  zk {
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
  }
  etcd3 {
    serverAddr = "http://localhost:2379"
  }
  file {
    name = "file.conf"
  }
}

由于这里是注册到 Nacos 的,所以先启动 Nacos 服务,再启动 Seata 服务。
image.png
Nacos 依旧采用单机版方式启动完毕后,再启动 Sataa 服务。
image.png
至此出现监听端口,Seata 服务端启动成功。