Seata+Nacos联合使用

1.Seata配置

seata:
config:
# support: nacos, consul, apollo, zk, etcd3
type: nacos
nacos:
server-addr: 127.0.0.1:8848
namespace: train
group: SEATA_GROUP
username: nacos
password: nacos
context-path:
data-id: seataServer.properties
registry:
# support: nacos, eureka, redis, zk, consul, etcd3, sofa
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
group: SEATA_GROUP
namespace: train
cluster: default
username: nacos
password: nacos

Seata+Nacos联合使用_第1张图片

yml文件,注意格式书写

Nacos启动后,启动Seata即可,之后Nacos就能检测到Seata服务。

2.Nacos配置

Seata+Nacos联合使用_第2张图片

图片中type大小写打错了应该是dbType

store.mode=db

store.db.dbType=mysql

store.db.datasource=druid

store.db.driverClassName=com.mysql.cj.jdbc.Driver

store.db.url=

store.db.user=

store.db.password=

3.数据库准备表

\seata\script\server\db 路径里有sql,到数据库里执行

然后启动seata即可

4.IDEA配置

Seata+Nacos联合使用_第3张图片

打错号的配置转移到了Nacos,集群的机器挂了方便转移服务到其他集群的机器。

Nacos增加配置

# seata注册中心,要和seata server的application.yml配置保持一致
seata.registry.type=nacos
seata.registry.nacos.application=seata-server
seata.registry.nacos.server-addr=127.0.0.1:8848
seata.registry.nacos.group=SEATA_GROUP
seata.registry.nacos.namespace=train
seata.registry.nacos.username=nacos
seata.registry.nacos.password=nacos

# seata配置中心,要和seata server的application.yml配置保持一致
seata.config.type=nacos
seata.config.nacos.server-addr=127.0.0.1:8848
seata.config.nacos.group=SEATA_GROUP
seata.config.nacos.namespace=train
seata.config.nacos.dataId=seataServer.properties
seata.config.nacos.username=nacos
seata.config.nacos.password=nacos

# 事务组名称,必须在nacos中有配置过:service.vgroupMapping.train-group=default
seata.tx-service-group=train-group
# 事务组和seata集群做关联
#seata.service.vgroup-mapping.train-group=default
# seata集群对应的机器
#seata.service.grouplist.default=127.0.0.1:8091

service.vgroupMapping.train-group=default

service.default.grouplist=127.0.0.1:8091

你可能感兴趣的:(SpringCloud,java,spring,cloud)