Seata 是一款开源的分布式事务解决方案,致力于在微服务架构下提供高性能和简单易用的分布式事务服务。微服务中不可或缺的事务处理,缺少分布式事务管理就会存在数据不统一的情况。
一、下载Seata
地址:http://seata.io/zh-cn/blog/download.html
二、运行Seata
配置文件registry.conf中可以配置注册中心,因为我要整合服务,之前使用的是nacos,所以这边修改一下即可。
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 = "nacos" password = "nacos" } ...... } config { # file、nacos 、apollo、zk、consul、etcd3 type = "nacos" nacos { serverAddr = "127.0.0.1:8848" namespace = "" group = "SEATA_GROUP" username = "nacos" password = "nacos" } ....... }
接着配置file.conf,个人是使用mysql,后期好整合项目,也可以直接file存储。
sql文件地址:https://github.com/seata/seata/blob/1.2.0/script/server/db/mysql.sql
## transaction log store, only used in seata-server store { ## store mode: file、db、redis mode = "db" ## 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://xxx.xxx.xxx.xxx:3306/seata" user = "root" password = "123" minConn = 5 maxConn = 30 globalTable = "global_table" ## global_table、branch_table、lock_table这几个表需要导入,否则会报错 branchTable = "branch_table" lockTable = "lock_table" queryLimit = 100 maxWait = 5000 } ...... }
bin文件夹中就2个文件,window直接运行seata-server.bat,linux下可以命令运行
sh seata-server.sh
然后登陆http://127.0.0.1:8848/nacos/index.html中查看服务列表,就可以看到
三、总结
seata服务搭建异常顺利,已没有奇怪的bug,可能麻烦的是后面的整合到项目里才会有其他问题产生。