A detailed introduction to seata docker high availability deployment

A detailed introduction to seata docker high availability deployment

Version

1.4.2
Official Documentation
dockerhub

start up

Specify the configuration file location /root/seata-config/registry.conf via the environment variable SEATA_CONFIG_NAME

docker run --name seata-server \
        -p 8091:8091 \
        -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \ 
        -v /User/seata/config:/root/seata-config \
        seataio/seata-server

Configuration Files

Achieving high availability requires relying on the registration center, configuration center, and database
registry.conf

registry {
  type = "nacos"

  nacos
    application = "seata-server"
    serverAddr = "192.168.199.2"
    namespace = "test"
    group = "SEATA_GROUP"
    cluster = "default"
    username = ""
    password = ""
  }
}

config {
  type = "nacos"  
  nacos
    serverAddr = "192.168.199.2"
    namespace = "test"
    group = "SEATA_GROUP"
    username = ""
    password = ""
  }
}

NACOS Configuration

Note: When using nacos configuration, you need to configure text values ​​for each configuration item under the corresponding group (SEATA_GROUP) instead of creating a properties file containing all configurations. You can use the script in the official source code to import all available configuration references

1. Using a database

store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://192.168.199.2:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=123456

Create a database

Database creation script

-- -------------------------------- 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(128),
    `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;

Exception handling

1. The client reports an error: Data too long for column 'application_id'

io.seata.core.exception.TmTransactionException: TransactionException[begin global request failed. xid=null, msg=Data truncation: Data too long for column 'application_id' at row 1]
at io.seata.tm.DefaultTransactionManager.begin(DefaultTransactionManager.java:55) ~[seata-all-1.3.0.jar:1.3.0]
at io.seata.tm.api.DefaultGlobalTransaction.begin(DefaultGlobalTransaction.java:104) ~[seata-all-1.3.0.jar:1.3.0]
at io.seata.tm.api.TransactionalTemplate.beginTransaction(TransactionalTemplate.java:175) ~[seata-all-1.3.0.jar:1.3.0]

The default length of the global_table.application_id field in the seata database is varchar(32). If the client application ID is too long, this error will be reported. You can manually modify the field type to increase the length.

This is the end of this article about seata docker high availability deployment. For more relevant seata docker deployment content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of the deployment process of SEATA transaction service Docker
  • Docker deploys mysql remote connection to solve 2003 problems
  • Implementation of docker-compose deployment project based on MySQL8

<<:  How to change fixed positioning of child elements to absolute positioning by CSS3 transform

>>:  Basic knowledge: What does http mean before a website address?

Recommend

Analysis and practice of React server-side rendering principle

Most people have heard of the concept of server-s...

Detailed explanation of MySQL cursor concepts and usage

This article uses examples to explain the concept...

A brief summary of all encapsulation methods in Vue

Table of contents 1. Encapsulation API 2. Registe...

MySQL obtains the current date and time function example detailed explanation

Get the current date + time (date + time) functio...

Native JS to implement drag position preview

This article shares with you a small Demo that ad...

Summary of Nginx load balancing methods

To understand load balancing, you must first unde...

About Vue's 4 auxiliary functions of Vuex

Table of contents 1. Auxiliary functions 2. Examp...

How to manually deploy war packages through tomcat9 on windows and linux

The results are different in Windows and Linux en...

Vue realizes dynamic progress bar effect

This article example shares the specific code of ...

5 tips for writing CSS to make your style more standardized

1. Arrange CSS in alphabetical order Not in alphab...

Detailed explanation of reduce fold unfold usage in JS

Table of contents fold (reduce) Using for...of Us...

How to display div on object without being blocked by object animation

Today I made a menu button. When you move the mous...

Detailed explanation of Truncate usage in MySQL

Preface: When we want to clear a table, we often ...

Angular framework detailed explanation of view abstract definition

Preface As a front-end framework designed "f...

Solution to MySQL unable to read table error (MySQL 1018 error)

1. Error reproduction I can access the MySQL data...