本文共 1833 字,大约阅读时间需要 6 分钟。
分布式前:
分布式之后:
单体应用被拆分成微服务应用,原来的三个模块被拆分成三个独立的应用,分别使用三个独立的数据源,业务操作需要调用三个服务来完成。此时每个服务内部的数据一致性由本地事务来保证,但是全局的数据一致性问题没法保证。
Seata是一款开源的分布式事务解决方案,致力于在微服务架构下提供高性能和简单易用的分布式事务服务。
官网:http:seata.io/zh-cn/
一个典型的分布式事务过程:
分布式事务处理过程:ID + 三组件模型
处理过程:
https://seata.io/zh-cn/blog/download.html
解压seata-server.zip,修改conf下的file.conf配置文件.
主要修改:自定义事务组名称+事务日志存储模式为db+数据库连接信息
service { #transaction service group mapping ###vgroup_mapping.my_test_tx_group = "default" vgroup_mapping.my_test_tx_group = "fsp_tx_group" #自定义事务组名称 #only support when registry.type=file, please don't set multiple addresses default.grouplist = "127.0.0.1:8091" #disable seata disableGlobalTransaction = false}## transaction log store, only used in seata-serverstore { ## store mode: file、db mode = "db" #指定存储模式为db ## file store property file { ## store location dir dir = "sessionStore" } ## database store property db { ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc. datasource = "dbcp" ## mysql/oracle/h2/oceanbase etc. db-type = "mysql" driver-class-name = "com.mysql.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata" user = "root" password = "123456" }}
建库:
https://github.com/seata/seata/tree/develop/script/server/db
修改/seata/conf目录下的registry.conf配置文件:
启动nacos,启动seata,
seata-server.sh支持的启动参数列表:
转载地址:http://gppqb.baihongyu.com/