zoukankan      html  css  js  c++  java
  • Seata Server环境搭建

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/14398087.html

    存储模式说明

    Seata Server端的存储模式有三种

    • file
    • db
    • redis

    默认为file

    搭建DB存储模式

    下载安装包

    wget https://github.com/seata/seata/releases/download/v1.4.1/seata-server-1.4.1.tar.gz
    wget https://github.com/seata/seata/archive/v1.4.1.tar.gz

    解压

    tar zxvf seata-server-1.4.1.tar.gz -C ~/app/
    tar zxvf v1.4.1.tar.gz -C ~/app/

    建表

    全局事务会话信息由3块内容构成

    • 全局事务 —— global_table
    • 分支事务 —— branch_table
    • 全局锁 —— lock_table

    创建数据库seata,执行sql脚本(~/app/seata-1.4.1/script/server/db/mysql.sql)

    -- -------------------------------- 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_gmt_modified_status` (`gmt_modified`, `status`),
        KEY `idx_transaction_id` (`transaction_id`)
    ) ENGINE = InnoDB
      DEFAULT CHARSET = utf8;
    
    -- 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 = InnoDB
      DEFAULT CHARSET = utf8;
    
    -- the table to store lock data
    CREATE TABLE IF NOT EXISTS `lock_table`
    (
        `row_key`        VARCHAR(128) NOT NULL,
        `xid`            VARCHAR(96),
        `transaction_id` BIGINT,
        `branch_id`      BIGINT       NOT NULL,
        `resource_id`    VARCHAR(256),
        `table_name`     VARCHAR(32),
        `pk`             VARCHAR(36),
        `gmt_create`     DATETIME,
        `gmt_modified`   DATETIME,
        PRIMARY KEY (`row_key`),
        KEY `idx_branch_id` (`branch_id`)
    ) ENGINE = InnoDB
      DEFAULT CHARSET = utf8;
    View Code

    修改store.mode

    vi ~/app/seata/conf/file.conf

    修改数据库配置

    配置Nacos注册中心

    vi ~/app/seata/conf/registry.conf

    配置Nacos配置中心

    vi ~/app/seata/conf/registry.conf

    注意:

    如果配置了seata server使用nacos作为配置中心,则配置信息会从nacos读取,file.conf可以不用配置。

    客户端配置registry.conf使用nacos时也要注意group要和seata server中的group一致,默认group是"DEFAULT_GROUP"

    启动Nacos

    sh ~/app/nacos/bin/startup.sh -m standalone

    修改配置参数

    vi ~/app/seata-1.4.1/script/config-center/config.txt

    同步配置参数到Nacos 

    cd ~/app/seata-1.4.1/script/config-center/nacos
    sh nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP

    查看同步配置

    启动Seata Server

    sh ~/app/seata/bin/seata-server.sh

    Reference

    https://github.com/seata/seata/releases

    强者自救 圣者渡人
  • 相关阅读:
    自己觉得好的文章(2)
    为什么要用C运行时库的_beginthreadex代替操作系统的CreateThread来创建线程?
    GraphEdit
    吴裕雄天生自然Spring BootSpring Boot与Thymeleaf实现页面信息国际化
    吴裕雄天生自然Spring BootThymeleaf基础语法
    吴裕雄天生自然Spring BootSpring Boot处理JSON数据
    吴裕雄天生自然Spring Boot基于Thymeleaf与BootStrap的Web开发实例
    吴裕雄天生自然Spring Boot基本配置和注解
    吴裕雄天生自然Spring Boot自定义Starters
    吴裕雄天生自然Spring Boot的基本配置
  • 原文地址:https://www.cnblogs.com/agilestyle/p/14398087.html
Copyright © 2011-2022 走看看