Seata实现分布式事务
Seate版本 0.9 window版
链接:https://pan.baidu.com/s/10LciCPIykjmLfKGPXlomZw
提取码:aspu
nacos版本 1.2.1 window版
链接:https://pan.baidu.com/s/1tJDgBQ2_S19VweJ9DDp0KQ
提取码:8848
访问路径 localhost:8848
gitee:https://gitee.com/HelloWorldLHY/seata-demo.git
github:
nacos配置中心新建配置文件
1.service-order-dev.yaml
server:
port: 8082
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql:///moni?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
username: root
password: 123456
1.初始化Seata在nacos的配置
修改seata\conf\nacos-config.txt 内容
service.vgroup_mapping.service-product=default
service.vgroup_mapping.service-storage=default
service.vgroup_mapping.service-account=default
service-product,service-account与service-storage均为微服务名称
初始化seata 的nacos配置
注意: 这里要保证nacos是已经正常运行的
cd conf
nacos-config.sh 127.0.0.1
执行成功后可以打开Nacos的控制台,在配置列表中,可以看到初始化了很多Group为SEATA_GROUP 的配置。
如果在nacos 中存在service.vgroup_mapping.service-storage 等配置
说明配置生效
2.启动Seata服务
cd bin
seata-server.bat -p 9000 -m file
3.初始化数据表
新建数据库moni
运行moni.sql
注意:undo_log表 为分布式事务seata所用表 基于此表实现回滚
4.在resources下添加Seata的配置文件 registry.conf
registry {
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
}
config {
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = "public"
cluster = "default"
}
}