seata入门
部署
官网下releases,不要用官方镜像部署,手动部署(centos)
Releases · seata/seata (github.com)
梦幻联动nacos
前提
官网下载releases源码,找到script文件夹
config.txt配置
scritpt -> config-cente
点进去
config.txt照官网修改
1 2 3 4 5
| store.mode=db store.db.driverClassName=com.mysql.cj.jdbc.Driver store.db.url=jdbc:mysql://sdadgz.cn:3307/seata?useUnicode=true&rewriteBatchedStatements=true store.db.user=root store.db.password=123456
|
service.vgroupMapping.my_test_tx_group=default
其中 my_test_tx_group
对应 resource.application.yaml
中 seata.tx-service-group
default
对应 seata服务端registry.conf 中 registry -> nacos -> cluster
config.txt上载
scritpt -> config-center -> nacos
点进去
1 2 3 4 5 6 7
| # win sh .\nacos-config.sh -h sdadgz.cn -p 8849 -g SEATA_GROUP -t test # 参数说明 -h host -p port -g group -t namespase
|
梦幻联动mysql
服务端
创个数据库
script -> server -> db -> mysql.sql
客户端
每个使用的表都需要放一个,例:user表
script -> client -> at -> db -> mysql.sql
依赖
1 2 3 4
| <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-seata</artifactId> </dependency>
|
启动项
@EnableTransactionManagement
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| seata: tx-service-group: my_test_tx_group registry: type: nacos nacos: server-addr: sdadgz.cn:8849 application: seata-server username: nacos password: sdadgz.cn group: SEATA_GROUP namespace: test config: type: nacos nacos: server-addr: sdadgz.cn:8849 group: SEATA_GROUP namespace: test username: nacos password: sdadgz.cn
|