Spring Cloud Alibaba Seata-Server 下载

官方下载地址:https://github.com/seata/seata/releases

image20220112191252083.png

下载完成之后需要解压

image20220112191449051.png

Seata-Server配置

  1. 需要打开conf目录

image20220112192512498.png

  1. 先配置registry.conf配置文件,修改Seata的注册中心和配置中心为Nacos

image20220112192010321.png

image20220112192038314.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
registry {
 # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
 type = "nacos"

 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"
   aclToken = ""
}
 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 = "nacos"

 nacos {
   serverAddr = "127.0.0.1:8848"
   namespace = ""
   group = "SEATA_GROUP"
   username = ""
   password = ""
   dataId = "seataServer.properties"
}
 consul {
   serverAddr = "127.0.0.1:8500"
   aclToken = ""
}
 apollo {
   appId = "seata-server"
   ## apolloConfigService will cover apolloMeta
   apolloMeta = "http://192.168.1.204:8801"
   apolloConfigService = "http://192.168.1.204:8080"
   namespace = "application"
   apolloAccesskeySecret = ""
   cluster = "seata"
}
 zk {
   serverAddr = "127.0.0.1:2181"
   sessionTimeout = 6000
   connectTimeout = 2000
   username = ""
   password = ""
   nodePath = "/seata/seata.properties"
}
 etcd3 {
   serverAddr = "http://localhost:2379"
}
 file {
   name = "file.conf"
}
}
  1. 接着我们需要修改Seata的存储模式,修改file.conf文件,把Seata的默认存储模式修改为数据库”DB”,同时需要配置JDBC

image20220112192451611.png

image20220112192620774.png

image20220112193120164.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## transaction log store, only used in seata-server
store {
 ## store mode: file、db、redis
 mode = "db"
 ## rsa decryption public key
 publicKey = ""
 ## file store property
 file {
   ## store location dir
   dir = "sessionStore"
   # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
   maxBranchSessionSize = 16384
   # globe session size , if exceeded throws exceptions
   maxGlobalSessionSize = 512
   # file buffer size , if exceeded allocate new buffer
   fileWriteBufferCacheSize = 16384
   # when recover batch read size
   sessionReloadReadSize = 100
   # async, sync
   flushDiskMode = async
}

 ## database store property
 db {
   ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
   datasource = "druid"
   ## mysql/oracle/postgresql/h2/oceanbase etc.
   dbType = "mysql"
   driverClassName = "com.mysql.jdbc.Driver"
   ## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
   url = "jdbc:mysql://localhost:3306/seata?useUnicode=true&characterEncoding=UTF-8"
   user = "root"
   password = "root"
   minConn = 5
   maxConn = 100
   globalTable = "global_table"
   branchTable = "branch_table"
   lockTable = "lock_table"
   queryLimit = 100
   maxWait = 5000
}

 ## redis store property
 redis {
   ## redis mode: single、sentinel
   mode = "single"
   ## single mode property
   single {
     host = "127.0.0.1"
     port = "6379"
  }
   ## sentinel mode property
   sentinel {
     masterName = ""
     ## such as "10.28.235.65:26379,10.28.235.65:26380,10.28.235.65:26381"
     sentinelHosts = ""
  }
   password = ""
   database = "0"
   minConn = 1
   maxConn = 10
   maxTotal = 100
   queryLimit = 100
}
}

启动

启动步骤为,先启动nacos然后在启动Seata-Server

启动Seata-Server的方式非常简单,直接双击此文件即可:seata-server-1.4.2\bin\seata-server.bat

image20220112193257424.png

启动完成效果

image20220112193410847.png

然后在nacos控制台上就可以看到Seata-Server

image20220112193500935.png