zoukankan      html  css  js  c++  java
  • seata 分布式事务 -- 准备工作

    seata 分布式事务 -- 准备工作

    环境 :

    jdk:1.8

    seata:1.4.0

    seata-1.4.0seataconf  两个配置文件更改 :

    1.  file.conf:

    1.
    
        mode = "db"
    
    2.    
    
        url = "jdbc:mysql://127.0.0.1:3307/seata-server?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai"
    
        user = "root"
    
        password = "root"

    2.registry.conf:

    1.  
    
       type = "eureka"
    
    2.
    
     eureka {
    
        serviceUrl = "http://localhost:7900/eureka/"
    
        application = "seata-server"
    
        weight = "1"
    
      }

    工程 :

    eureka-server  注册中心 

    seata-one    事务发起者

    seata-two    事务参与者

    seata-three  事务参与者

     

     

    三个事务参与者 在 srcmain esources 下分别自定义 两个配置文件 (三个工程文件一样)

    file.conf :

    service {
    #  #transaction service group mapping
    #  vgroup_mapping.fbs_tx_group= "default"
    #  #only support when registry.type=file, please don't set multiple addresses
    #  default.grouplist = "127.0.0.1:8091"
    #  #disable seata
    #  disableGlobalTransaction = false
    
      #######
      #transaction service group mapping
      vgroup_mapping.my_tx_group="seata-server"
      #only support when registry.type=file, please don't set multiple addresses
      #disable seata
      disableGlobalTransaction = false
    }
    
    client {
      rm {
        async.commit.buffer.limit = 10000
        lock {
          retry.internal = 10
          retry.times = 30
          retry.policy.branch-rollback-on-conflict = true
        }
        report.retry.count = 5
        table.meta.check.enable = false
        report.success.enable = true
      }
      tm {
        commit.retry.count = 5
        rollback.retry.count = 5
      }
      undo {
        data.validation = true
        log.serialization = "jackson"
        log.table = "undo_log"
      }
      log {
        exceptionRate = 100
      }
      support {
        # auto proxy the DataSource bean
        spring.datasource.autoproxy = false
      }
    }

    registry.conf :

    registry {
      # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
      type = "eureka"
    
      nacos {
        serverAddr = "localhost"
        namespace = ""
        cluster = "default"
      }
      eureka {
        serviceUrl = "http://localhost:7900/eureka/"
        # 修改点
        application = "seata-server"
        weight = "1"
      }
      redis {
        serverAddr = "localhost:6379"
        db = "0"
      }
      zk {
        cluster = "default"
        serverAddr = "127.0.0.1:2181"
        session.timeout = 6000
        connect.timeout = 2000
      }
      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 = "localhost"
        namespace = ""
      }
      consul {
        serverAddr = "127.0.0.1:8500"
      }
      apollo {
        app.id = "seata-server"
        apollo.meta = "http://192.168.1.204:8801"
      }
      zk {
        serverAddr = "127.0.0.1:2181"
        session.timeout = 6000
        connect.timeout = 2000
      }
      etcd3 {
        serverAddr = "http://localhost:2379"
      }
      file {
        name = "file.conf"
      }
    }

    每个工程对应一个数据库 ,创建好 数据表 和 undo_log 表  和 数据库: seata-server 的三表

    这里的数据表结构(工程one举例:) :

    CREATE TABLE `tbl_one` (
    
      `id` varchar(255) NOT NULL,
    
      `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
    
      PRIMARY KEY (`id`)
    
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

     数据库结构:

  • 相关阅读:
    解决:transform-decorators-legacy 报错
    leetcode刷题笔记 232题 用栈实现队列
    leetcode刷题笔记 231题 2的幂
    leetcode刷题笔记 230题 二叉搜索树中第K小的元素
    leetcode刷题笔记 229题 求众数II
    leetcode刷题笔记 228题 汇总区间
    leetcode刷题笔记 227题 基本计算器II
    leetcode刷题笔记 225题 用队列实现栈
    leetcode刷题笔记 224题 基本计算器
    leetcode刷题笔记 223题 矩形面积
  • 原文地址:https://www.cnblogs.com/lifan12589/p/14781138.html
Copyright © 2011-2022 走看看