Windows中Seata连接Linux中的nacos的配置

news2025/1/11 23:53:06

目录

前言:

Seata配置教程:

file.conf:

​编辑 

配置代码:

registry.conf:

 ​编辑

nacos-config.sh:

config.txt:


前言:

 许多博主,把两个软件都安装在同一个系统中,但是有些人估计是装在不同的环境下,那么照着那些博主配置,大概率gg,因为你们没有理解配置文件。我来教大家如何配置,让大伙不用看别人的眼色,配出自己的

本博客只讲如何配置,不讲软件的下载。

Seata配置教程:

file.conf:

 

 conf文件夹里面的file.conf

配置代码:

## transaction log store, only used in seata-server
store {
  ## store mode: file、db、redis
  mode = "db"

  ## file store property
  file {
    ## store location dir
    dir = "sessionStore"
    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
    maxBranchSessionSize = 16384
    # globe session size , if exceeded throws exceptions
    maxGlobalSessionSize = 512
    # file buffer size , if exceeded allocate new buffer
    fileWriteBufferCacheSize = 16384
    # when recover batch read size
    sessionReloadReadSize = 100
    # async, sync
    flushDiskMode = async
  }

  ## database store property
  db {
    ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
    datasource = "druid"
    ## mysql/oracle/postgresql/h2/oceanbase etc.
    dbType = "mysql"
    driverClassName = "com.mysql.cj.jdbc.Driver"
    url = "jdbc:mysql://127.0.0.1:3306/seata?serverTimezone=UTC&useUnicode=true&useSSL=false&characterEncoding=utf8&allowPublicKeyRetrieval=true"
    user = "root"
    password = "jly720609"
    minConn = 5
    maxConn = 100
    globalTable = "global_table"
    branchTable = "branch_table"
    lockTable = "lock_table"
    queryLimit = 100
    maxWait = 5000
  }

  ## redis store property
  redis {
    host = "127.0.0.1"
    port = "6379"
    password = ""
    database = "0"
    minConn = 1
    maxConn = 10
    maxTotal = 100
    queryLimit = 100
  }

}

改为db采用数据库保存

 

 

数据库配置  用户名和密码需要修改,改成自己数据库的密码

重点: 数据库分为五版本和八版本,我配置的是八版本的。

    driverClassName = "com.mysql.cj.jdbc.Driver"
    url = "jdbc:mysql://127.0.0.1:3306/seata?serverTimezone=UTC&useUnicode=true&useSSL=false&characterEncoding=utf8&allowPublicKeyRetrieval=true"

registry.conf:

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"
  loadBalance = "RandomLoadBalance"
  loadBalanceVirtualNodes = 10

  nacos {
    application = "seata-server"
    serverAddr = "192.168.56.188:8848"
    group = "SEATA_GROUP"
    namespace = "public"
    cluster = "default"
    username = "nacos"
    password = "nacos"

  }
  eureka {
    serviceUrl = "http://localhost:8761/eureka"
    application = "default"
    weight = "1"
  }
  redis {
    serverAddr = "localhost:6379"
    db = 0
    password = ""
    cluster = "default"
    timeout = 0
  }
  zk {
    cluster = "default"
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
  }
  consul {
    cluster = "default"
    serverAddr = "127.0.0.1:8500"
  }
  etcd3 {
    cluster = "default"
    serverAddr = "http://localhost:2379"
  }
  sofa {
    serverAddr = "127.0.0.1:9603"
    application = "default"
    region = "DEFAULT_ZONE"
    datacenter = "DefaultDataCenter"
    cluster = "default"
    group = "SEATA_GROUP"
    addressWaitTime = "3000"
  }
  file {
    name = "file.conf"
  }
}

config {
  # file、nacos 、apollo、zk、consul、etcd3
  type = "file"

  nacos {
    serverAddr = "127.0.0.1:8848"
    namespace = ""
    group = "SEATA_GROUP"
    username = ""
    password = ""
  }
  consul {
    serverAddr = "127.0.0.1:8500"
  }
  apollo {
    appId = "seata-server"
    apolloMeta = "http://192.168.1.204:8801"
    namespace = "application"
    apolloAccesskeySecret = ""
  }
  zk {
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
  }
  etcd3 {
    serverAddr = "http://localhost:2379"
  }
  file {
    name = "file.conf"
  }
}

 

类型设置为nacos 

 

serverAddr需要配置为连接的nacos的地址。windows的nacos配置为127.0.0.1 linux配置为linux的ip

  serverAddr = "192.168.56.188:8848"

nacos-config.sh:

该文件需要自己创建,在conf文件夹里面 

 

配置代码如下:

#!/usr/bin/env bash
# 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
do
  case $opt in
  h)
    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
done

urlencode() {
  for ((i=0; i < ${#1}; i++))
  do
    char="${1:$i:1}"
    case $char in
    [a-zA-Z0-9.~_-]) printf $char ;;
    *) printf '%%%02X' "'$char" ;;
    esac
  done
}

if [[ -z ${host} ]]; then
    host=localhost
fi
if [[ -z ${port} ]]; then
    port=8848
fi
if [[ -z ${group} ]]; then
    group="SEATA_GROUP"
fi
if [[ -z ${tenant} ]]; then
    tenant=""
fi
if [[ -z ${username} ]]; then
    username=""
fi
if [[ -z ${password} ]]; then
    password=""
fi

nacosAddr=192.168.56.188:$port
contentType="content-type:application/json;charset=UTF-8"

echo "set nacosAddr=$nacosAddr"
echo "set group=$group"

failCount=0
tempLog=$(mktemp -u)
function addConfig() {
  curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$(urlencode $1)&group=$group&content=$(urlencode $2)&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null
  if [[ -z $(cat "${tempLog}") ]]; then
    echo " Please check the cluster status. "
    exit 1
  fi
  if [[ $(cat "${tempLog}") =~ "true" ]]; then
    echo "Set $1=$2 successfully "
  else
    echo "Set $1=$2 failure "
    (( failCount++ ))
  fi
}

count=0
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
#for line in E:\soft\seata-server-1.4.0\seata/config.txt | sed s/[[:space:]]//g); do
  (( count++ ))
  key=${line%%=*}
    value=${line#*=}
  addConfig "${key}" "${value}"
done

echo "========================================================================="
echo " Complete initialization parameters,  total-count:$count ,  failure-count:$failCount "
echo "========================================================================="

if [[ ${failCount} -eq 0 ]]; then
  echo " Init nacos config finished, please start seata-server. "
else
  echo " init nacos config fail. "
fi

 

 找到这里,linux的nacos就写linux的ip,windows的可以用默认的

config.txt:

也需要自己写代码如下,该文件的位置跟bin目录同级 

transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableClientBatchSendRequest=true
transport.threadFactory.bossThreadPrefix=NettyBoss
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
transport.threadFactory.clientSelectorThreadSize=1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
service.vgroupMapping.my_test_tx_group=default
service.default.grouplist=127.0.0.1:8091
service.enableDegrade=false
service.disableGlobalTransaction=false
client.rm.asyncCommitBufferLimit=10000
client.rm.lock.retryInterval=10
client.rm.lock.retryTimes=30
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
client.rm.reportRetryCount=5
client.rm.tableMetaCheckEnable=false
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.rm.tccActionInterceptorOrder=-2147482648
client.tm.commitRetryCount=5
client.tm.rollbackRetryCount=5
client.tm.defaultGlobalTransactionTimeout=60000
client.tm.degradeCheck=false
client.tm.degradeCheckAllowTimes=10
client.tm.degradeCheckPeriod=2000
client.tm.interceptorOrder=-2147482648
store.mode=file
store.lock.mode=file
store.session.mode=file
store.publicKey=xx
store.file.dir=file_store/data
store.file.maxBranchSessionSize=16384
store.file.maxGlobalSessionSize=512
store.file.fileWriteBufferCacheSize=16384
store.file.flushDiskMode=async
store.file.sessionReloadReadSize=100
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.dbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=jly720609
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
store.redis.mode=single
store.redis.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=xx
store.redis.sentinel.sentinelHosts=xx
store.redis.maxConn=10
store.redis.minConn=1
store.redis.maxTotal=100
store.redis.database=0
store.redis.password=xx
store.redis.queryLimit=100
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
server.distributedLockExpireTime=10000
client.undo.dataValidation=true
client.undo.logSerialization=jackson
client.undo.onlyCareUpdateColumns=true
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
client.undo.logTable=undo_log
client.undo.compress.enable=true
client.undo.compress.type=zip
client.undo.compress.threshold=64k
log.exceptionRate=100
transport.serialization=seata
transport.compressor=none
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

 老规矩,修改数据库配置

store.db.driverClassName=com.mysql.cj.dbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true

上面的是八版本的,五版本应该是默认的。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/436329.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

支付系统设计:收银台设计二

文章目录 前言1. 接口校验1.1 Chains1.2 Checker1.2.1 AbstractChecker1.2.2 TokenChecker1.2.3 OrderChecker1.2.4 UserInfoChecker1.2.5 BaseInfoChecker1.2.6 SignChecker 1.3 ApiFilter 2. 下单3. 收银台首页2.1 OrderInfoResolver2.2 UserBaseInfoResolver 4. 执行流程总结…

企业宁愿花 15K 重新招人,也不愿意花 10K 留住老测试员?

金三银四即将进入尾声&#xff0c;大家逐渐收敛了跳槽涨薪的想法&#xff0c;准备收收心等待过年。不置可否&#xff0c;年后必定又是一波跳槽季&#xff0c;通过跳槽才能涨薪已经成为了不少求职者内心默认的定理。 不知道什么时候开始&#xff0c;公司不能满足加薪的要求&…

leetcode 812. 最大三角形面积

题目 给你一个由 X-Y 平面上的点组成的数组 points &#xff0c;其中 points[i] [xi, yi] 。从其中取任意三个不同的点组成三角形&#xff0c;返回能组成的最大三角形的面积。与真实值误差在 10-5 内的答案将会视为正确答案。 示例 1&#xff1a; 输入&#xff1a;points [[…

手把手带你实现通讯录C语言

通讯录大家都很熟悉了&#xff0c;一个联系人包括姓名&#xff0c;年龄&#xff0c;性别&#xff0c;电话&#xff0c;地址等&#xff1b; 那我们想一想我们所学的数据类型&#xff08;int,float,double等都是单一的相同类型 &#xff08;属于内置类型&#xff09;&#xff09;…

#详细介绍!!! 造成死锁的原因以及解决方案!

本篇主要是介绍什么是死锁&#xff0c;已经死锁产生的原因&#xff0c;如果避免死锁。根据上述的几个问题让我们来阅读本篇文章。 目录 1. 什么是死锁 2. 形成死锁的原因&#xff08;四个必要条件&#xff09; 3. 如果有效避免死锁 1. 什么是死锁 死锁主要是锁彼此间进行锁等…

FPGA实现JPEG-LS图像压缩,有损无损可配置,提供工程源码和技术支持

目录 1、前言2、JPEG-LS图像压缩理论3、JPEG-LS图像压缩性能介绍4、JPEG-LS图像压缩时序介绍5、JPEG-LS图像压缩输出压缩流6、工程源码和仿真7、福利&#xff1a;工程代码的获取 1、前言 JPEG-LS&#xff08;简称JLS&#xff09;是一种无损/有损的图像压缩算法&#xff0c;其无…

1 Go语言开发环境搭建详细教程【Go语言教程】

Go语言开发环境搭建【Win、Linux、Mac】 1 SDK下载 官网地址&#xff1a;golang.org,因为一些原因国内可能无法访问。可以使用下面第二个链接。国内地址访问&#xff1a;https://golang.google.cn/dl或者https://www.golangtc.com/download 根据自己操作系统版本&#xff0c;下…

30天学会《Streamlit》(9)

30天学会《Streamlit》是一项编码挑战&#xff0c;旨在帮助您开始构建Streamlit应用程序。特别是&#xff0c;您将能够&#xff1a; 为构建Streamlit应用程序设置编码环境 构建您的第一个Streamlit应用程序 了解用于Streamlit应用程序的所有很棒的输入/输出小部件 第9天 - …

超高精度PID控制器的特殊功能(4)——分程控制功能及其应用

摘要&#xff1a;分程控制作为一种典型的复杂控制方法之一&#xff0c;常用于聚合反应工艺、冷热循环浴、TEC半导体温度控制、动态平衡法的真空和压力控制等领域。为快速和便捷的使用分程控制&#xff0c;避免采用PLC时存在的控制精度差和使用门槛高等问题&#xff0c;本文介绍…

pyqt6+vtk

这里用PyQt6vtk9.2.6 pip install PyQt6 pyqt6-tools vtk这里拉了一个水平布局 然后水平布局中加入QWidget&#xff0c;object name改为vtkWidget 右键Promote Widgets Promoted class name: QVTKRenderWindowInteractor Header file: vtkmodules.qt.QVTKRenderWindowInterac…

文章改写神器在线-AI续写文章生成器

AI续写生成器 AI续写生成器是一种利用人工智能技术的创意工具&#xff0c;能够提高写作效率&#xff0c;为营销推广带来全新的可能性。无论你是写手、广告人员还是市场营销人员&#xff0c;这个工具都能够有效地解决你在写作中遇到的难题。 在内容创作行业中&#xff0c;原创…

Amazon Linux2部署安装Jenkins

先决条件 服务器配置要求 256 MB of RAM 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container) 需要部署安装JDK环境部署安装的Jenkins版本为Version 2.400 部署安装JDK 1. 下载JDK软件包 wget https://corretto.aws/…

Altium Designer借助嘉立创添加PCB封装和3D模型

目录 引言打开立创专业版EDA&#xff0c;建立项目从立创商城找到器件编码添加PCB封装导出和修改3D封装 引言 由于使用Altium Designer的频率并不是特别高&#xff0c;所以每一次使用总是得东跌西撞的才回忆起一些使用步骤。因此&#xff0c;想在这里记录一下Altium Designer借…

【mysql】binlog日志

目录 1.1 基本说明1.2 binlog日志格式1.3 binlog日志查看1.4 binlog日志删除1.5 binlog操作示例 1.1 基本说明 1.全称binary log&#xff0c;二进制日志 2.记录了所有的DDL语句&#xff08;Data Definition Language数据定义语言&#xff09;和DML语句&#xff08;Data Manipul…

Java多线程中sleep()方法和wait()方法的区别

目录 具体而言 &#xff0c;sleep&#xff08;&#xff09;方法与wait&#xff08;&#xff09;方法的区别主要表现在以下几个方面&#xff1a; 引申&#xff1a;sleep&#xff08;&#xff09;方法和yield&#xff08;&#xff09;方法有什么区别&#xff1f; 常见面试题&a…

如何衡量算法的效率?时间复杂度空间复杂度

本篇博客会讲解如何衡量一个算法的效率。衡量算法的效率&#xff0c;主要有2个维度&#xff0c;分别是&#xff1a;时间复杂度和空间复杂度。 时间复杂度用来衡量算法的时间效率。时间复杂度越低&#xff0c;算法的耗时越短&#xff0c;效率则越高。空间复杂度用来衡量算法的空…

Space Cloud updated Crack

Space Cloud updated Crack Space Git Flow-对于实践连续发布周期的开发团队来说&#xff0c;在协调团队成员、建立流程和集成多个工具时&#xff0c;建立交付流可能需要付出巨大努力。为了更容易做到这一点&#xff0c;引入了JetBrains Space Git流&#xff0c;这是一个完整的…

同一热卖商品的高并发写难题 - Lua脚本扣减库存方案

目录 一、Mysql高并发写时的行锁难题 二、Redis的相关命令 1. WATCH命令 2. EVAL与EVALSHA命令 三、SpringBoot执行Lua脚本代码示例 1. 依赖包 2. Lua脚本sku.lua 3. 加载Lua脚本 4. 执行Lua脚本 四、参考资料 一、Mysql高并发写时的行锁难题 通常来说&#xff0c;秒…

百度大模型ERNIE3.0

大模型对比 文心全景图 ERNIE 3.0