文章目录

  • 1. 创建文件config.txt
  • 2. 创建nacos-config.sh
  • 3. 配置导入nacos配置中心
  • 4. 配置验证
1. 创建文件config.txt

在seata的安装文件夹下创建文件config.txt

[root@node2 ~]# cd /app/seata/seata-server-1.4.2/
[root@node2 seata-server-1.4.2]# vim config.txt

说明:
第一行:这里order-service值得是订单模块的服务
从第二行开始:下面是数据库信息根据自己的实际情况配置
注意点:不能添加中文注释

添加以下内容:

service.vgroupMapping.order-service=default
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/ry-seata?useUnicode=true
store.db.user=root
store.db.password=123456
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000

上面的文件是精简后的部分,完整文件可在github中找到

https://github.com/seata/seata/blob/develop/script/config-center/config.txt

2. 创建nacos-config.sh

在conf/文件夹下下载文件
https://github.com/seata/seata/blob/develop/script/config-center/nacos/nacos-config.sh
用于将上面的seata配置信息导入到nacos 执行下面的命令

[root@node2 seata-server-1.4.2]# cd conf
[root@node2 conf]# vim nacos-config.sh
内容比较多,建议直接下载吧
#!/bin/sh
# Copyright 1999-2019 Seata.io Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at、
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.while getopts ":h:p:g:t:u:w:" opt
docase $opt inh)host=$OPTARG;;p)port=$OPTARG;;g)group=$OPTARG;;t)tenant=$OPTARG;;u)username=$OPTARG;;w)password=$OPTARG;;?)echo " USAGE OPTION: $0 [-h host] [-p port] [-g group] [-t tenant] [-u username] [-w password] "exit 1;;esac
doneif [ -z ${host} ]; thenhost=localhost
fi
if [ -z ${port} ]; thenport=8848
fi
if [ -z ${group} ]; thengroup="SEATA_GROUP"
fi
if [ -z ${tenant} ]; thentenant=""
fi
if [ -z ${username} ]; thenusername=""
fi
if [ -z ${password} ]; thenpassword=""
finacosAddr=$host:$port
contentType="content-type:application/json;charset=UTF-8"echo "set nacosAddr=$nacosAddr"
echo "set group=$group"urlencode() {length="${#1}"i=0while [ $length -gt $i ]; dochar="${1:$i:1}"case $char in[a-zA-Z0-9.~_-]) printf $char ;;*) printf '%%%02X' "'$char" ;;esaci=`expr $i + 1`done
}failCount=0
tempLog=$(mktemp -u)
function addConfig() {dataId=`urlencode $1`content=`urlencode $2`curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$dataId&group=$group&content=$content&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/nullif [ -z $(cat "${tempLog}") ]; thenecho " Please check the cluster status. "exit 1fiif [ "$(cat "${tempLog}")" == "true" ]; thenecho "Set $1=$2 successfully "elseecho "Set $1=$2 failure "failCount=`expr $failCount + 1`fi
}count=0
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); docount=`expr $count + 1`key=${line%%=*}value=${line#*=}addConfig "${key}" "${value}"
doneecho "========================================================================="
echo " Complete initialization parameters,  total-count:$count ,  failure-count:$failCount "
echo "========================================================================="if [ ${failCount} -eq 0 ]; thenecho " Init nacos config finished, please start seata-server. "
elseecho " init nacos config fail. "
fi
3. 配置导入nacos配置中心

将seata配置信息导入到nacos config配置中心

 sh nacos-config.sh -h 127.0.0.1
  • -h后面是nacos配置中心的地址
    操作记录:
[root@node2 conf]#  sh nacos-config.sh -h 127.0.0.1
set nacosAddr=127.0.0.1:8848
set group=SEATA_GROUP
Set service.vgroupMapping.order-service=default successfully
Set store.mode=db successfully
Set store.db.datasource=druid successfully
Set store.db.dbType=mysql successfully
Set store.db.driverClassName=com.mysql.cj.jdbc.Driver successfully
Set store.db.url=jdbc:mysql://127.0.0.1:3306/ry-seata?useUnicode=true successfully
Set store.db.user=root successfully
Set store.db.password=123456 successfully
Set store.db.minConn=5 successfully
Set store.db.maxConn=30 successfully
Set store.db.globalTable=global_table successfully
Set store.db.branchTable=branch_table successfully
Set store.db.queryLimit=100 successfully
Set store.db.lockTable=lock_table successfully
Set store.db.maxWait=5000 successfully
=========================================================================Complete initialization parameters,  total-count:15 ,  failure-count:0
=========================================================================Init nacos config finished, please start seata-server.
[root@node2 conf]#

4. 配置验证

执行完成后登录到nacos 查看配置中心的数据是否导入完毕,如图所示

RuoYi-Cloud 进阶篇_03( Seata 高可用集群与 NacosConfig配置中心整合)相关推荐

  1. Nacos发布 v0.2 版本,无缝支持 Spring Cloud 微服务生态及高可用集群模式

    2019独角兽企业重金招聘Python工程师标准>>> 近日,阿里巴巴新开源项目Nacos 发布了 v0.2 版本,该版本开始支持完整的Spring生态技术栈,这包括 Spring ...

  2. 【❤️万字长文总结❤️】一篇学会Redis高可用✔集群✔搭建详细教程

    大家好,我是Lex 喜欢欺负超人那个Lex 擅长领域:python开发.网络安全渗透.Windows域控Exchange架构 今日重点:今天总结一下Redis集群高可用的搭建流程 [惊喜推荐+优质资源 ...

  3. Skywalking+Nacos实现高可用集群和动态配置

    注意:Skywalking启动时路径不可为中文(windows) 环境介绍# 下面是架构图: 软件版本信息: nacos:1.3.0 skywalking:8.5.0 elastcisearch:7. ...

  4. RuoYi-Cloud 进阶篇_04( Seata 高可用集群 AT模式 需求实战)

    需求背景: 模拟下单场景:首先去在自己的本地创建一条下单记录,同时,还要去调用库存服务,执行减库存操作. 这里演示一个客户下订单的流程服务来为小伙伴们进一步了解一下分布式事务到底如何使用? 首先,我会 ...

  5. 高可用集群heartbeat安装配置(一)

    一.HA高可 FailOver:故障转移 包含HA Resource IP, service,STONITH FailBack故障转移原点 Faiover domain:故障转移域 资源粘性资源更倾向 ...

  6. 基于CENTOS7 Linux高可用集群LVS+Keepalived配置

    1.LVS安装配置 配置LVS负载均衡集群: 1.填写下列IP分配表 服务器角色 IP地址 DR 192.168.158.129 RS1 192.168.158.137 RS2 192.168.158 ...

  7. 基于zookeeper(集群)+LevelDB的ActiveMq高可用集群安装、配置、测试

    Linux 环境 zookeeper集群安装.配置.测试https://blog.csdn.net/weixin_40816738/article/details/100576259 MQ集群部署规划 ...

  8. Redis创建高可用集群教程【Windows环境】

    模仿的过程中,加入自己的思考和理解,也会有进步和收获. 在这个互联网时代,在高并发和高流量可能随时爆发的情况下,单机版的系统或者单机版的应用已经无法生存,越来越多的应用开始支持集群,支持分布式部署了. ...

  9. Redis高可用集群-哨兵模式(Redis-Sentinel)搭建配置教程【Windows环境】

    ================================================= 人工智能教程.零基础!通俗易懂!风趣幽默!大家可以看看是否对自己有帮助! 点击查看高清无码教程 == ...

最新文章

  1. OVS datapath之action分析(十九)
  2. python实现单例模式
  3. HDU1114 Piggy-Bank 【全然背包】
  4. python引入jit_从numba导入jit
  5. PHP 模拟真实ip,PHP实现-获取用户的真实IP
  6. python利用集合的无重复性_python集合?
  7. flink二阶提交(没有搞完)
  8. mysql010函数使用.单行函数.多行函数
  9. emmet语法 1127
  10. 数据库自增主键用完了怎么办
  11. 计算机结构化思维学计算机,基于结构化知识的学习/思考机器和学习/思考方法以及计算机系统和信息生成方法...
  12. 用DrawerLayout(Support Library 4提供)开发侧边栏,有没有什么方法关闭手势控制?...
  13. [APIO2009]抢掠计划 ($Tarjan$,最长路)
  14. 微型计算机1G指的是1024字节,孙闻:1GB的流量等于多少mb
  15. ceph peering流程分析
  16. latex引用图标出现问号
  17. vue2 - 基于Export2Excel.js导出Excel案例(js-xlsx插件二次封装使用)
  18. Monkey测试黑白名单
  19. 利用pandas进行数据分析
  20. ThreadLocalMap里弱引用

热门文章

  1. php取mod,php支持mod及php-cgi的方式
  2. php 变量调试,PHP变量调试函数
  3. (pytorch-深度学习)语言模型-学习笔记
  4. Linux命令sngre,linux gre隧道创建
  5. 用树莓派+lora shield搭建一个LoRaWAN网关
  6. 只需10分钟!就能用Flask,Docker和Jenkins部署机器学习模型
  7. 机器学习与数据科学决策树指南
  8. 场景联创 施耐德电气“绿色智能制造创赢计划”第二季收官
  9. Gartner:全行业投入人工智能,计算机视觉占比最高
  10. CPU 明明 8 个核,网卡为啥拼命折腾一号核?