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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM