seata1.3 分散式事務整合 ----- AT模式
1.下載
原始碼下載
https://github.com/seata/seata/tree/1.3.0
Server端下載
https://github.com/seata/seata/tags
2.配置檔案
解壓原始碼找到config.txt,並配置相關資訊,如圖
修改如下圖
新建seata庫,指令碼檔案在原始碼script\server\db 下
配置完之後執行指令碼檔案,將資訊註冊到nacos,前提nacos需要先啟動,執行sh檔案,執行不了的,安裝git即可
註冊到nacos成功之後,可以在nacos配置中心看到相關資訊
配置seata-server file.conf和registry.conf檔案資訊
file.conf 配置如圖
registry.conf 配置如圖
application為服務名稱,預設即可
group組名,預設即可
配置完成之後,執行seata-server
成功截圖如下
3.client端配置如下
在需要用到的微服務專案中新增如下配置資訊
spring:
cloud:
alibaba:
seata:
# 事務分組名稱
tx-service-group: ccyk_tx_group
seata:
registry:
type: nacos
nacos:
server-addr: ${NACOS_HOST:haoyu-cloud-register}:${NACOS_PORT:8848}
application: seata-server
username: nacos
password: nacos
group: SEATA_GROUP
config:
type: nacos
nacos:
server-addr: ${NACOS_HOST:haoyu-cloud-register}:${NACOS_PORT:8848}
username: nacos
password: nacos
group: SEATA_GROUP
tx-service-group 事務分組名稱,與config.txt 中配置保持一致
application seata服務名稱 ,與registry.conf中配置保持一致
group seata分組名稱 ,與registry.conf中配置保持一致
在相應的微服務的資料庫下建立 undo_log 表,指令碼在原始碼專案的script\client\at\db下
使用在相應的業務程式碼中加入 @GlobalTransactional,如圖
重啟服務,完成