Spring Cloud Nacos集成Seata2.0 AT模式
以CentOS 7为例,介绍Spring Cloud Nacos集成Seata2.0 AT模式的流程。分成两个步骤:1.安装配置seata-server、2.项目集成seata-client
一、下载seata-server安装包
根据自己的操作系统选择要下载的安装包格式:下载地址

二、解压安装
将安装包放到指定目录(以/usr/soft/seata为例)

解压,重命名
tar -zxvf seata-server-2.0.0.tar.gz
mv seata seata-server-2.0.0

创建生成环境和开发环境目录:
mkdir dev
mkdir prod

将解压后的seata-server-2.0.0拷贝到dev目录下,进入dev目录下:
cp seata-server-2.0.0 -a dev/
cd dev

三、修改seata配置
修改conf目录下的application.yml:
server:
port: 7091
spring:
application:
name: seata-server
logging:
config: classpath:logback-spring.xml
file:
path: ${
log.home:${
user.home}/logs/seata}
extend:
logstash-appender:
destination: 127.0.0.1:4560
kafka-appender:
bootstrap-servers: 127.0.0.1:9092
topic: logback_to_logstash
console:
user:
username: seata
password: seata
# 这里是主要的配置文件
seata:
config:
# support: nacos, consul, apollo, zk, etcd3
type: nacos
nacos:
server-addr: 127.0.0.1:8848
username: nacos
password: nacos
# 如果在nacos上添加了命名空间,则配置命名空间ID
namespace: fba13bcb-xxxxx-c9a0e # dev
# 配置分组
group: SEATA_GROUP
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
data-id: seataServer.properties
registry:
# support: nacos 、 eureka 、 redis 、 zk 、 consul 、 etcd3 、 sofa
type: nacos
preferred-networks: 30.240.*
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
username: nacos
password: nacos
namespace: fba13bcb-xxxx-c9a0e # dev
group: DEFAULT_GROUP
cluster: default
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
server:
service-port: 8091 #If not configured, the default is '${server.port} + 1000'
max-commit-retry-timeout: -1
max-rollback-retry-timeout: -1
rollback-retry-timeout-unlock-enable: false
enable-check-auth: true
enable-parallel-request-handle: true
enable-parallel-handle-branch: false
retry-dead-threshold: 130000
xaer-nota-retry-timeout: 60000
enableParallelRequestHandle: true
recovery:
committing-retry-period: 1000
async-committing-retry-period: 1000
rollbacking-retry-period: 1000
timeout-retry-period: 1000
undo:
log-save-days: 7
log-delete-period: 86400000
session:
branch-async-queue-size: 5000 #branch async remove queue size
enable-branch-async-remove: false #enable to asynchronous remove branchSession
store:
# support: file 、 db 、 redis 、 raft
mode: db
session:
mode: db
lock:
mode: db
db:
datasource: druid
db-type: mysql
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/mingink-seata?rewriteBatchedStatements=true&&useSSL=false
user: root
password: root
min-conn: 10
max-conn: 100
global-table: global_table
branch-table: branch_table
lock-table: lock_table
distributed-lock-table: distributed_lock

本文介绍了Spring Cloud Nacos如何与Seata2.0集成实现AT模式,包括下载安装seata-server,配置seata与Nacos,创建数据库表,启动seata-server服务,以及Spring Cloud项目中整合Seata的步骤。

3081

被折叠的 条评论
为什么被折叠?



