当前位置: 首页 > news >正文

springcloud第4季 分布式事务seata作用服务搭建

一  seata作用

1.1 作用

二  seata服务端搭建

2.1 seata搭建

2.2.1 seata 服务端下载安装

下载地址: Seata-Server下载 | Apache Seata

截图如下:

2.2.2 使用mysql初始化seata所需表

1.下载脚本地址:incubator-seata/script/server/db/mysql.sql at 2.x · apache/incubator-seata · GitHub

2.脚本内容

--
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements.  See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You 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.
---- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE IF NOT EXISTS `global_table`
(`xid`                       VARCHAR(128) NOT NULL,`transaction_id`            BIGINT,`status`                    TINYINT      NOT NULL,`application_id`            VARCHAR(32),`transaction_service_group` VARCHAR(32),`transaction_name`          VARCHAR(128),`timeout`                   INT,`begin_time`                BIGINT,`application_data`          VARCHAR(2000),`gmt_create`                DATETIME,`gmt_modified`              DATETIME,PRIMARY KEY (`xid`),KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(`branch_id`         BIGINT       NOT NULL,`xid`               VARCHAR(128) NOT NULL,`transaction_id`    BIGINT,`resource_group_id` VARCHAR(32),`resource_id`       VARCHAR(256),`branch_type`       VARCHAR(8),`status`            TINYINT,`client_id`         VARCHAR(64),`application_data`  VARCHAR(2000),`gmt_create`        DATETIME(6),`gmt_modified`      DATETIME(6),PRIMARY KEY (`branch_id`),KEY `idx_xid` (`xid`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(`row_key`        VARCHAR(128) NOT NULL,`xid`            VARCHAR(128),`transaction_id` BIGINT,`branch_id`      BIGINT       NOT NULL,`resource_id`    VARCHAR(256),`table_name`     VARCHAR(32),`pk`             VARCHAR(36),`status`         TINYINT      NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',`gmt_create`     DATETIME,`gmt_modified`   DATETIME,PRIMARY KEY (`row_key`),KEY `idx_status` (`status`),KEY `idx_branch_id` (`branch_id`),KEY `idx_xid` (`xid`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;CREATE TABLE IF NOT EXISTS `distributed_lock`
(`lock_key`       CHAR(20) NOT NULL,`lock_value`     VARCHAR(20) NOT NULL,`expire`         BIGINT,primary key (`lock_key`)
) ENGINE = InnoDBDEFAULT CHARSET = utf8mb4;INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

 3.附加mysql数据库

2.2.3 nacos的信息配置

2.2.4 seata 服务端进行配置

2.2.5 启动服务

1.查看nacos

2.查看seata

http://localhost:7901

操作步骤

相关文章:

  • vite配置之获取.env.[mode]下的数据
  • linux 安装sftp及使用sftp上传和下载
  • NVIDIA发布Nemotron-4 340B 用于生成高质量的合成数据
  • GitHub项目里的api
  • Excel小技巧| 批量多列多行转为一列
  • 系统架构设计师【论文-2017年 试题2】: 论软件架构风格(包括写作要点和经典范文)
  • 外观缺陷检测原理
  • vue3+vite+ts 使用webrtc-streamer播放海康rtsp监控视频
  • C++面经
  • C# list 成员对象是int型存在堆区还是栈区
  • 机器学习——集成学习和梯度提升决策树
  • C#中[StructLayout(LayoutKind.Sequential, Pack = 1)]解释
  • C++ 58 之 计算器案例
  • 模板方法模式(大话设计模式)C/C++版本
  • Python:基础爬虫
  • 【剑指offer】让抽象问题具体化
  • 【刷算法】从上往下打印二叉树
  • Angular 4.x 动态创建组件
  • CentOS6 编译安装 redis-3.2.3
  • happypack两次报错的问题
  • Java 网络编程(2):UDP 的使用
  • October CMS - 快速入门 9 Images And Galleries
  • Python十分钟制作属于你自己的个性logo
  • Spring框架之我见(三)——IOC、AOP
  • VirtualBox 安装过程中出现 Running VMs found 错误的解决过程
  • 持续集成与持续部署宝典Part 2:创建持续集成流水线
  • 从零到一:用Phaser.js写意地开发小游戏(Chapter 3 - 加载游戏资源)
  • 当SetTimeout遇到了字符串
  • 翻译 | 老司机带你秒懂内存管理 - 第一部(共三部)
  • 诡异!React stopPropagation失灵
  • 简单数学运算程序(不定期更新)
  • 近期前端发展计划
  • 面试题:给你个id,去拿到name,多叉树遍历
  • 面试遇到的一些题
  • 模型微调
  • 如何将自己的网站分享到QQ空间,微信,微博等等
  • 深度学习入门:10门免费线上课程推荐
  • 吴恩达Deep Learning课程练习题参考答案——R语言版
  • ​直流电和交流电有什么区别为什么这个时候又要变成直流电呢?交流转换到直流(整流器)直流变交流(逆变器)​
  • #LLM入门|Prompt#3.3_存储_Memory
  • (1)(1.19) TeraRanger One/EVO测距仪
  • (12)Hive调优——count distinct去重优化
  • (DFS + 剪枝)【洛谷P1731】 [NOI1999] 生日蛋糕
  • (八)Spring源码解析:Spring MVC
  • (几何:六边形面积)编写程序,提示用户输入六边形的边长,然后显示它的面积。
  • (七)Knockout 创建自定义绑定
  • (三)Kafka 监控之 Streams 监控(Streams Monitoring)和其他
  • (四)库存超卖案例实战——优化redis分布式锁
  • (原創) 如何將struct塞進vector? (C/C++) (STL)
  • (原創) 如何使用ISO C++讀寫BMP圖檔? (C/C++) (Image Processing)
  • (转)利用ant在Mac 下自动化打包签名Android程序
  • (转载)OpenStack Hacker养成指南
  • .bat批处理(六):替换字符串中匹配的子串
  • .NET Core/Framework 创建委托以大幅度提高反射调用的性能
  • .NET 使用配置文件