docker部署seata1.6.0

docker部署seata1.6.0

Seata 是 阿里巴巴 开源的 分布式事务中间件,解决 微服务 场景下面临的分布式事务问题。需要先搭建seata服务端然后与springcloud的集成以实现分布式事务控制的过程 ,项目中只需要在远程调用APi服务的方法上使用注解 @GlobalTransactional,就能实现跨模块事务回滚。

一、安装seata1.6.0

docker pull seataio/seata-server:1.6.0
# 启动容器
docker run -d --name seata-server -p 8091:8091 -p 7091:7091  seataio/seata-server:1.6.0
# 拷贝文件到宿主机目录/opt/seata/seata-server(这个目录需要先手动创建)
cd /opt
mkdir seata
cd /opt/seata
mkdir seata-server
docker cp seata-server:/seata-server/resources  /opt/seata/seata-server/
# 停止并删除容器
docker stop seata-server
docker rm seata-server
# 修改/opt/seata/seata-server/resources目录下的文件application.yml
# 重新启动容器
docker run -i -t -d --restart always --name seata-server \
-p 7091:7091 -p 8091:8091  \
-e SEATA_IP=192.168.124.11 \
-e SEATA_PORT=8091 \
-e TZ=Asia/Shanghai  \
-v /opt/seata/seata-server/resources:/seata-server/resources \
-v /etc/localtime:/etc/localtime \
seataio/seata-server:1.6.0# -e SEATA_IP=[公网IP] 这个ip必须是公网ip,否则会访问失败

在这里插入图片描述

二、修改配置文件application.yml

  • 修改控制台登录账号密码
console:user:username: seata11password: 123456
  • 修改type=nacos
  • 修改nacos连接的账号密码
  • 修改数据库连接
#  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.server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashconsole:user:username: seata11password: 123456
seata:config:# support: nacos, consul, apollo, zk, etcd3type: nacosnacos:server-addr: 192.168.124.11:8848namespace: eca990b0-5481-4f9e-b4d0-f2a517bb26778group: SEATA_GROUPusername: rootpassword: 123456#context-path:##if use MSE Nacos with auth, mutex with username/password attribute#access-key: ""#secret-key: ""data-id: seataServer.propertiesregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacospreferred-networks: 30.240.*nacos:application: seata-serverserver-addr: 192.168.124.11:8848group: SEATA_GROUPnamespace: eca990b0-5481-4f9e-b4d0-f2a517bb26778cluster: defaultusername: rootpassword: 123456#context-path:##if use MSE Nacos with auth, mutex with username/password attribute#access-key: ""#secret-key: ""store:# support: file 、 db 、 redismode: dbsession:mode: dblock:mode: dbfile:dir: sessionStoremax-branch-session-size: 16384max-global-session-size: 512file-write-buffer-cache-size: 16384session-reload-read-size: 100flush-disk-mode: asyncdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://192.168.124.11:3306/seata_db?rewriteBatchedStatements=trueuser: rootpassword: 123456min-conn: 5max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 100max-wait: 5000server:service-port: 8091 #If not configured, the default is '${server.port} + 1000security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

三、nacos中创建配置文件seataServer.properties

在这里插入图片描述

  • seataServer.properties
  • 修改service.vgroupMapping.mygroup=default

#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
#Transport configuration, for client and server
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableTmClientBatchSendRequest=false
transport.enableRmClientBatchSendRequest=true
transport.enableTcServerBatchSendResponse=false
transport.rpcRmRequestTimeout=30000
transport.rpcTmRequestTimeout=30000
transport.rpcTcRequestTimeout=30000
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
transport.serialization=seata
transport.compressor=none#Transaction routing rules configuration, only for the client
# 此处的mygroup名字可以自定义,只修改这个值即可,
# 需要在nacos中配置dataId为service.vgroupMapping.mygroup,配置格式:为txt,内容为default
service.vgroupMapping.mygroup=default
#If you use a registry, you can ignore it
service.default.grouplist=192.168.124.11:8091
service.enableDegrade=false
service.disableGlobalTransaction=false#Transaction rule configuration, only for the client
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=true
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.rm.sagaJsonParser=fastjson
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
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
#For TCC transaction mode
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h#Log rule configuration, for client and server
log.exceptionRate=100#Transaction storage configuration, only for the server. The file, db, and redis configuration values are optional.
# 默认为file,一定要改为db,我们自己的服务启动会连接不到seata
store.mode=db
store.lock.mode=db
store.session.mode=db
#Used for password encryption#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
# 修改mysql的配置# 数据存储方式,db代表数据库
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://192.168.124.11:3306/seata_db?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
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.distributedLockTable=distributed_lock
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
# 事务、日志等配置#Transaction rule configuration, only for the server
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
server.xaerNotaRetryTimeout=60000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=false#Metrics configuration, only for the server
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

四、nacos中配置service.vgroupMapping.mygroup

在这里插入图片描述

五、项目中配置seata

  • bootstrap.yml中配置

seata:application-id: ${spring.application.name}#数据源代理模式使用AT模式(可以不用配置,seata默认使用AT模式)data-source-proxy-mode: ATtx-service-group: mygroup # 事务分组名称,要和服务端对应#事务群组(可以每个应用独立取名,也可以使用相同的名字),#要与服务端nacos配置seataServer.properties中service.vgroupMapping.mygroup=default中存在,#此处的mygroup名字可以自定义,与 tx-service-group: mygroup中的mygroup保持一致service:vgroup-mapping:mygroup: defaultenabled: falseregistry:type: nacosnacos:username: rootpassword: 123456namespace: @nacos.config.namespace@server-addr: @nacos.server-addr@group: SEATA_GROUP#seata服务名application: seata-serverconfig:type: nacosnacos:username: rootpassword: 123456namespace: @nacos.config.namespace@server-addr: @nacos.server-addr@group: SEATA_GROUP

六、导入seata数据库

  • seata-server-1.6.0下载地址:https://github.com/apache/incubator-seata/tags
    在这里插入图片描述

  • 数据库脚本目录: \seata-server-1.6.0\seata\script\server\db
    在这里插入图片描述
    在这里插入图片描述

  • 配置完后重启seata容器 docker restart seata-server

  • 项目中就可以使用分布式事务了

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

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

相关文章

集群master和worker区别

1、Master Master 是 K8S 的集群控制节点,每个 K8S 集群里需要有一个 Master 节点来负责整个集群的管理和控制,基本上 K8S 所有的控制命令都是发给它,它来负责具体的执行过程。Master 节点通常会占据一个独立的服务器,因为它太重要…

使用logicflow流程图实例

一.背景 需要使用流程引擎开发项目,没有使用flowable、activiti这类的国外流程引擎,想使用国内的引擎二次开发,缺少单例模式的流程画图程序,都是vue、react、angluer的不适合,从网上找了antx6、logicflow、bpmn.js。感…

架构设计:数据库扩展

引言 随着业务的发展和用户规模的增长,数据库往往会面临着存储容量不足、性能瓶颈等问题。为了解决这些问题,数据库扩展成为了一种常见的解决方案。在数据库扩展的实践中,有许多不同的策略和技术可供选择,其中包括水平拆分、垂直…

【MySQL 探索之旅】初始MySQL数据库

📚博客主页:爱敲代码的小杨. ✨专栏:《Java SE语法》 | 《数据结构与算法》 | 《C生万物》 ❤️感谢大家点赞👍🏻收藏⭐评论✍🏻,您的三连就是我持续更新的动力❤️ 🙏小杨水平有…

【LeetCode每日一题】 单调栈的案例84 柱状图中最大的矩形

84 柱状图中最大的矩形 给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。 求在该柱状图中,能够勾勒出来的矩形的最大面积。 示例 1: 输入:heights [2,1,5,6,2,3] 输出:10 解释…

Conmi的正确答案——将JAVA中maven的.m2文件夹放到D盘

系统:WIN11 1、将.m2文件夹移动到D盘 移动后: 2、创建目录链接 mklink /j "C:\Users\Administrator\.m2" "D:\.m2"至此,maven默认的jar包会加载到D盘的.m2文件夹

小程序分包的详细流程

小程序分包的详细流程如下: 建立分包文件夹:在项目根目录下创建分包文件夹,用来存放除底部菜单栏页面之外的其他页面。例如,你可以创建一个名为subPackages的文件夹,并在其中创建pages文件夹用于存放页面文件&#xff…

Ubuntu环境安装MySQL数据库

1.安装过程 打开终端(Terminal)窗口,使用以下命令更新系统软件包: sudo apt update ubuntu环境安装mysql-server和mysql开发包,包括mysql头文件和动态库文件,命令如下: sudo apt-get instal…

vue复用组件出现data-v-xxx乱码无法通过css修改指定样式

vue复用组件出现data-v-xxx乱码无法通过css修改指定样式解决方案如下 选择需要修改的样式 给最高级父级元素定义新的classname 与原有样式保持相同级联 修改指定样式 .demo_parent .demo_son .demo_grandson[data-v-73a2ee76]{ padding: 0; border-radius: 3px; background: #…

【科研基础】信息瓶颈 Information Bottleneck

Information Bottleneck的主要想法是将多层神经网络视为逐层传递的马尔科夫链,信息在链中被逐层压缩,去掉和输出无关的,留下与输出相关的。也就是说让每一层与模型输入的互信息逐渐减小,与模型输出的互信息逐渐增大【1】 [1]信息瓶…

分享数字孪生潭江流域建设与实践论文

数字孪生潭江流域建设 广东省水利厅 以支撑江门市沿线水工程精准联调联控,提升水旱灾害防御能力为首要任务,融合多信息源预报、GIS等技术,建立气象-水文-水动力集一体的复杂流域入库径流预报及其洪涝延伸预报模型平台,构建具有“…

zookeeper动态扩缩容(无需重启)

目录 一、启动一个zk 二、扩容一个zk 三、缩容一个zk 四、重新配置集群的节点 前言: zookeeper动态扩/缩容的reconfig命令旨在不需要重启zookeeper中任何一个节点的情况下,对整个zookeeper集群进行动态扩/缩容。 zookeeper客户端支持的命令&#xff…

Qt应用软件【文件篇】INI文件读写

文章目录 INI文件简介INI文件的主要特点INI文件的应用场景Qt INI文件相关API汇总Qt读取INI文件代码示例Qt写入INI文件代码示例Qt修改INI文件代码示例INI文件编码格式问题INI文件简介 INI文件,全称Initialization File,是一种简单的文本文件,用于存储配置信息和参数。它由多…

【明道云】导入Excel数据时的默认顺序

【背景】 明道云导入Excel过程中由于数据问题往往会有一些需要补录的地方。这种情况下就需要已上传到线上的数据和本地Excel的记录顺序完全一致才方便对比。因此需要清除如何让两者的记录顺序一致。 【分析】 经过多次排序对比,考虑到分页的影响,发现…

二层交换机和三层交换机区别

01、二层交换机 二层交换机,也被称为数据链路层交换机,是在OSI模型的数据链路层(第二层)进行数据交换的设备。它基于MAC(Media Access Control)地址来转发数据包,实现局域网内部的数据传输 1、…

jetson nano——报错(已解决):ModuleNotFoundError: No module named ‘dlib‘

目录 1.问题描述2. ps:下面二个方法选一个即可。2.1.方法一:2.2.方法二:我直接提供文件,大家进入cd dlib-19.17输入python3 setup.py install即可 系统:jetson-nano-jp451-sd-card-image ubuntu 18.04 借鉴了这位博主的…

HTMLElement.click()的回调触发踩坑

先看看以下代码 const el document.getElementById("btn") el.addEventListener("click", () > {Promise.resolve().then(() > console.log("microtask 1"));console.log("1"); }); el.addEventListener("click", (…

Spring Boot 手写starter!!!

原因:为什么要手写starter??? 原因:简化功能。 实例:以分页为例:写一个starter。 1.首先定义一个PageX注解。 Target({ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Documented p…

mac/windows git ssh 配置多平台账号(入门篇)

目录 引子多账号多平台配置git一、.ssh文件夹路径1.1 mac 系统1.2 windows 系统 二、生成new ssh2.1 mac系统2.2 windows 系统 三、配置 config四、验证五、用ssh方式拉取远程仓库代码 引子 push代码到github仓库时,提示报错。 Push failed Remote: Support for pa…

Channel

在Java中,Channel是一个用于IO操作(特别是NIO,即非阻塞IO)的接口,它提供了一种连接到IO服务(如文件系统或套接字)的开放连接。Channel是Java NIO中的核心组件之一,使得能够以更接近操…