seata1.3.0 服務端的搭建
1.從官網下載seata-server-1.3.0
https://github.com/seata/seata/releases/tag/v1.3.0
也可以百度雲下載seata-server-1.3.0
鏈接:https://pan.baidu.com/s/1Xmilth4Xs81CJqclmMKj7A
提取碼:1ysf
2.下載以后conf目錄有兩個配置文件,一個是注冊配置文件,另一個是file配置文件
注冊配置文件用nacos的話,注意seata-server服務端與連接到該服務端的客戶端是在一個group下面,否則客戶端會報錯無法從nacos注冊服務器找到服務端。

file里面可以配置數據庫
## transaction log store, only used in server side
store {
## store mode: file、db
mode = "db"
## 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"
url = "jdbc:mysql://localhost:3306/seata"
user = "root"
password = "root"
minConn = 5
maxConn = 30
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
## server configuration, only used in server side
server {
recovery {
#schedule committing retry period in milliseconds
committingRetryPeriod = 1000
#schedule asyn committing retry period in milliseconds
asynCommittingRetryPeriod = 1000
#schedule rollbacking retry period in milliseconds
rollbackingRetryPeriod = 1000
#schedule timeout retry period in milliseconds
timeoutRetryPeriod = 1000
}
undo {
logSaveDays = 7
#schedule delete expired undo_log in milliseconds
logDeletePeriod = 86400000
}
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
maxCommitRetryTimeout = "-1"
maxRollbackRetryTimeout = "-1"
rollbackRetryTimeoutUnlockEnable = false
}
## metrics configuration, only used in server side
metrics {
enabled = false
registryType = "compact"
# multi exporters use comma divided
exporterList = "prometheus"
exporterPrometheusPort = 9898
}
同時搭建seata-server服務所依賴的數據庫,global_tablesql,branch_table,lock_table語句見https://gitee.com/xiaoyinjun/seata-demo/blob/master/sql/seata.sql
配置好文件之后,啟動腳本nohup ./seata-server.sh -p 8091 -h ******(綁定的ip地址)就可以執行了。
客戶端代碼示例見https://gitee.com/xiaoyinjun/seata-demo.git。如果按照以上搭建seata-server服務器,搭建客戶端代碼示例中所需要的數據庫,建庫語句在sql目錄里面。就可以一鍵運行了。
客戶端示例的file的配置文件有個事務組可以自定義
service {
vgroupMapping.fsp_tx_group = "default" #修改自定義事務組名稱
default.grouplist = "127.0.0.1:8091"
enableDegrade = false
disable = false
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
disableGlobalTransaction = false
}
但是接下來的springboot的配置文件也需要和他一致
spring:
cloud:
alibaba:
seata:
tx-service-group: fsp_tx_group
同時客戶端file里面的數據庫配置,register.conf注冊服務器配置同上面的seata-server配置一樣。demo都已經是配置好了的。
seata官方文檔見地址https://seata.io/zh-cn/docs/overview/what-is-seata.html
