背景
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 先备份一份。
如图:
打开 file.conf 修改:
## transaction log store, only used in seata-serverstore {## store mode: file、db、redis#mode = "file"#修改为DB模式mode = "db"## file store propertyfile {## store location dirdir = "sessionStore"# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptionsmaxBranchSessionSize = 16384# globe session size , if exceeded throws exceptionsmaxGlobalSessionSize = 512# file buffer size , if exceeded allocate new bufferfileWriteBufferCacheSize = 16384# when recover batch read sizesessionReloadReadSize = 100# async, syncflushDiskMode = async}## database store propertydb {## 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://127.0.0.1:3308/seata_config?serverTimezone=UTC"#自己数据库的用户名user = "root"#自己数据库的密码password = "123456"minConn = 5maxConn = 100#这里需要的脚本文件在官方文档里有globalTable = "global_table"branchTable = "branch_table"lockTable = "lock_table"queryLimit = 100maxWait = 5000}## redis store propertyredis {host = "127.0.0.1"port = "6379"password = ""database = "0"minConn = 1maxConn = 10maxTotal = 100queryLimit = 100}}
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 服务。
Nacos 依旧采用单机版方式启动完毕后,再启动 Sataa 服务。
至此出现监听端口,Seata 服务端启动成功。
