Nacos 配置中心
Survive by day and develop by night.
talk for import biz , show your perfect code,full busy,skip hardness,make a better result,wait for change,challenge Survive.
happy for hardess to solve denpendies.
目录
概述
当您将nacos-client整合到您的 Seata工程之前,请确保后台已经启动 Nacos 服务。如果您尚且不熟悉 Nacos 的基本使用的话,可先行参考 Nacos 快速入门。建议使用 Nacos 1.2.0 及以上的版本。
需求:
Seata 融合 Nacos 配置中心的操作步骤非常简单,大致步骤可分为“增加 Maven 依赖”以及“配置nacos配置中心“和提交配置至Nacos-Server。
设计思路
io.seata seata-spring-boot-starter 最新版 com.alibaba.nacos nacos-client 1.2.0及以上版本实现思路分析
1.Client端配置中心
seata:
config:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
group : “SEATA_GROUP”
namespace: “”
2.Server端配置中心
在 registry.conf 中加入对应配置中心,其余配置参考
config {
type = “nacos”
nacos {
serverAddr = “127.0.0.1:8848”
group = “SEATA_GROUP”
namespace = “”
}
}
3.上传配置至Nacos配置中心
通过dataId配置:
从v1.4.2版本开始,已支持从一个Nacos dataId中获取所有配置信息,你只需要额外添加一个dataId配置项。
首先你需要在nacos新建配置,此处dataId为seataServer.properties,配置内容参考https://github.com/seata/seata/tree/develop/script/config-center 的config.txt并按需修改保存
在client参考如下配置进行修改,
4.client参考
seata:
config:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
group : “SEATA_GROUP”
namespace: “”
dataId: “seataServer.properties”
username: “nacos”
password: “nacos”
5.通过脚本上传配置到Nacos
参考https://github.com/seata/seata/tree/develop/script/config-center 的config.txt并修改,之后运行仓库中提供的nacos脚本,将信息提交到nacos控制台,如果有需要更改,可直接通过控制台更改.
eg: sh ${SEATAPATH}/script/config-center/nacos/nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 5a3c7d6c-f497-4d68-a71a-2e5e3340b3ca -u username -w password
拓展实现
参考资料和推荐阅读
- 无
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~