1:官网下载
https://seata.io/en-us/blog/download.html 本文章已1.6.1为例,版本不同,配置文件conf不同,请自行判断
2:解压
3:更改配置文件
3.1 配置事物日志存储模式
seata默认储存方式是file,通常我们希望储存在数据库中方便我们查看,已mysql5.7版本为例
conf/application.yml 文件存储配置修改如下
store:
# support: file 、 db 、 redis
# mode: file
mode: db
file:
dir: sessionStore
max-branch-session-size: 16384
max-global-session-size: 512
file-write-buffer-cache-size: 16384
session-reload-read-size: 100
flush-disk-mode: async
db:
datasource: druid
db-type: mysql
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatements=true&useSSL=true&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
user:
password:
min-conn: 10
max-conn: 100
global-table: global_table
branch-table: branch_table
lock-table: lock_table
distributed-lock-table: distributed_lock
query-limit: 1000
max-wait: 5000
其中数据库用户名、密码使用自己的
3.2 创建seata数据存放处
上面配置了mysql数据库,那么同时也要在mysql数据库上建立对应的seata数据库,并导入seata准备的数据表。
seata1.6.1的版本数据表信息主要存储在如下目录
导入成功可以看到如下表信息
4:配置注册信息
seata 支持多种注册中心。nacos 、 eureka 、 redis 、 zk 、 consul 、 etcd3 、 sofa,为了方便使用alibaba全家桶,后期扩展方便,此处已nacos注册中心为例
conf/application.yml 文件存储配置修改如下
seata:
config:
# support: nacos, consul, apollo, zk, etcd3
# type: file
type: nacos
nacos:
server-addr: xxxx
group: DEFAULT_GROUP
username: xxx
password: xxx
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key: ""
#secret-key: ""
#data-id: seataServer.properties(可nacos中配置https://seata.io/zh-cn/docs/user/configuration/nacos.html)
registry:
# support: nacos, eureka, redis, zk, consul, etcd3, sofa
# type: file
type: nacos
nacos:
application: seata-server
server-addr: xxx
group: seata_GROUP
namespace:
cluster: default
username: xxx
password: xxx
以上配置中nacos地址、用户名、密码等信息根据自己实际情况配置
5:启动seata服务