使用 docker-compose 部署 Seata Server

注意事項(xiàng)

  • 避免直接拉取latest版本鏡像,latest版本并不一定是released版本,為避免不必要的問題,請到docker鏡像倉庫確定要拉取的鏡像版本。

快速開始

  • <a href="#file-file">【無注冊中心,file存儲】</a>
  • <a href="#file-db">【無注冊中心,db存儲】</a>
  • <a href="#nacos-db">【nacos注冊中心,db存儲】</a>
  • <a href="#ha-nacos-db">【高可用部署】</a>

<a id="file-file">【無注冊中心,file存儲】</a>

該模式下,不需要注冊中心,也不需要任何第三方存儲中心。

docker-compose.yaml

version: "3.1"
services:
  seata-server:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8091:8091"
    environment:
      - SEATA_PORT=8091
      - STORE_MODE=file

<a id="file-db">【無注冊中心,DB存儲】</a>

db模式需要在數(shù)據(jù)庫創(chuàng)建對應(yīng)的表結(jié)構(gòu),建表腳本。
如無法訪問,請點(diǎn)擊 <a href="#mysql">【mysql表結(jié)構(gòu)】</a>、<a href="#oracle">【oracle表結(jié)構(gòu)】</a>、<a href="#postgresql">【postgresql表結(jié)構(gòu)】</a>。

(1)準(zhǔn)備file.conf配置文件

其他存儲模式可參考<a href="#file.example.conf">file.example.conf</a>

# 1.5.0版本后,默認(rèn)事務(wù)分組改成了default_tx_group
# 參考:service.vgroupMapping.default_tx_group=default
service.vgroupMapping.my_test_tx_group=default
# 存儲模式
store.mode=db

store.db.datasource=druid
store.db.dbType=mysql
# 需要根據(jù)mysql的版本調(diào)整driverClassName
# mysql8及以上版本對應(yīng)的driver:com.mysql.cj.jdbc.Driver
# mysql8以下版本的driver:com.mysql.jdbc.Driver
store.db.driverClassName=com.mysql.cj.jdbc.Driver
# 注意調(diào)整host和port
store.db.url=jdbc:mysql://127.0.0.1:3306/seata-server?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
# 數(shù)據(jù)庫用戶名
store.db.user=root
# 用戶名密碼
store.db.password=123456

(2)準(zhǔn)備registry.conf文件

其他注冊中心、配置中心方式可參考<a href="#registry.example.conf">registry.example.conf</a>

直連模式(無注冊中心)

registry {
  type = "file"
}

config {
  type = "file"
  
  file {
    name="file:/root/seata-config/file.conf"
  }
}

(3)準(zhǔn)備docker-compose.yaml文件

version: "3.1"
services:
  seata-server:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8091:8091"
    environment:
      - SEATA_PORT=8091
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
    # 需要把file.conf和registry.conf都放到./seata-server/config文件夾中
      - "./seata-server/config:/root/seata-config"

<a id="nacos-db">【nacos注冊中心,db存儲】</a>

db模式需要在數(shù)據(jù)庫創(chuàng)建對應(yīng)的表結(jié)構(gòu),建表腳本。
如無法訪問,請點(diǎn)擊 <a href="#mysql">【mysql表結(jié)構(gòu)】</a>、<a href="#oracle">【oracle表結(jié)構(gòu)】</a>、<a href="#postgresql">【postgresql表結(jié)構(gòu)】</a>。

(1)準(zhǔn)備file.conf配置文件

其他存儲模式可參考<a href="#file.example.conf">file.example.conf</a>

# 1.5.0版本后,默認(rèn)事務(wù)分組改成了default_tx_group
# 參考:service.vgroupMapping.default_tx_group=default
service.vgroupMapping.my_test_tx_group=default
# 存儲模式
store.mode=db

store.db.datasource=druid
store.db.dbType=mysql
# 需要根據(jù)mysql的版本調(diào)整driverClassName
# mysql8及以上版本對應(yīng)的driver:com.mysql.cj.jdbc.Driver
# mysql8以下版本的driver:com.mysql.jdbc.Driver
store.db.driverClassName=com.mysql.cj.jdbc.Driver
# 注意調(diào)整host和port
store.db.url=jdbc:mysql://127.0.0.1:3306/seata-server?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
# 數(shù)據(jù)庫用戶名
store.db.user=root
# 用戶名密碼
store.db.password=123456

(2)準(zhǔn)備registry.conf文件

nacos注冊中心。

其他注冊中心、配置中心方式可參考<a href="#registry.example.conf">registry.example.conf</a>

registry {
  type = "nacos"
  
  nacos {
  # seata服務(wù)注冊在nacos上的別名,客戶端通過該別名調(diào)用服務(wù)
    application = "seata-server"
  # nacos服務(wù)的ip和端口
    serverAddr = "127.0.0.1:8848"
  # nacos上指定的namespace
    namespace = ""
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}

#【如果nacos服務(wù)是docker運(yùn)行的話,config.type需要指定為file模式,否則會報錯】
config {
  type = "file"
  
  file {
    name="file:/root/seata-config/file.conf"
  }
}

(3)準(zhǔn)備docker-compose.yaml文件

version: "3.1"
services:
  seata-server:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8091:8091"
    environment:
      # 指定seata服務(wù)啟動端口
      - SEATA_PORT=8091
      # 注冊到nacos上的ip??蛻舳藢⑼ㄟ^該ip訪問seata服務(wù)。
      # 注意公網(wǎng)ip和內(nèi)網(wǎng)ip的差異。
      - SEATA_IP=127.0.0.1
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
    # 需要把file.conf和registry.conf都放到./seata-server/config文件夾中
      - "./seata-server/config:/root/seata-config"

<a id="ha-nacos-db">【高可用部署】</a>

seata高可用依賴于注冊中心、數(shù)據(jù)庫,可不依賴配置中心。

db模式需要在數(shù)據(jù)庫創(chuàng)建對應(yīng)的表結(jié)構(gòu),建表腳本。
如無法訪問,請點(diǎn)擊 <a href="#mysql">【mysql表結(jié)構(gòu)】</a>、<a href="#oracle">【oracle表結(jié)構(gòu)】</a>、<a href="#postgresql">【postgresql表結(jié)構(gòu)】</a>。

(1)準(zhǔn)備file.conf配置文件

其他存儲模式可參考<a href="#file.example.conf">file.example.conf</a>

# 1.5.0版本后,默認(rèn)事務(wù)分組改成了default_tx_group
# 參考:service.vgroupMapping.default_tx_group=default
service.vgroupMapping.my_test_tx_group=default
# 存儲模式
store.mode=db

store.db.datasource=druid
store.db.dbType=mysql
# 需要根據(jù)mysql的版本調(diào)整driverClassName
# mysql8及以上版本對應(yīng)的driver:com.mysql.cj.jdbc.Driver
# mysql8以下版本的driver:com.mysql.jdbc.Driver
store.db.driverClassName=com.mysql.cj.jdbc.Driver
# 注意調(diào)整host和port
store.db.url=jdbc:mysql://127.0.0.1:3306/seata-server?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
# 數(shù)據(jù)庫用戶名
store.db.user=root
# 用戶名密碼
store.db.password=123456

(2)準(zhǔn)備registry.conf文件

nacos注冊中心。

其他注冊中心、配置中心方式可參考<a href="#registry.example.conf">registry.example.conf</a>

registry {
  type = "nacos"
  
  nacos {
  # seata服務(wù)注冊在nacos上的別名,客戶端通過該別名調(diào)用服務(wù)
    application = "seata-server"
  # nacos服務(wù)的ip和端口
    serverAddr = "127.0.0.1:8848"
  # nacos上指定的namespace
    namespace = ""
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}

#【如果nacos服務(wù)是docker運(yùn)行的話,config.type需要指定為file模式,否則會報錯】
config {
  type = "file"
  
  file {
    name="file:/root/seata-config/file.conf"
  }
}

(3)準(zhǔn)備docker-compose.yaml文件

只要保持配置一致,seata服務(wù)可在一臺機(jī)器上部署多實(shí)例,也可同時部署在多臺不同的主機(jī)下面實(shí)現(xiàn)服務(wù)高可用。

version: "3.1"
services:
  # seata服務(wù)1
  seata-server-1:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8091:8091"
    environment:
      # 指定seata服務(wù)啟動端口
      - SEATA_PORT=8091
      # 注冊到nacos上的ip。客戶端將通過該ip訪問seata服務(wù)。
      # 注意公網(wǎng)ip和內(nèi)網(wǎng)ip的差異。
      - SEATA_IP=127.0.0.1
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
    # 需要把file.conf和registry.conf都放到./seata-server/config文件夾中
      - "./seata-server/config:/root/seata-config"
  # seata服務(wù)2
  seata-server-2:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8092:8092"
    environment:
      # 指定seata服務(wù)啟動端口
      - SEATA_PORT=8092
      # 注冊到nacos上的ip。客戶端將通過該ip訪問seata服務(wù)。
      # 注意公網(wǎng)ip和內(nèi)網(wǎng)ip的差異。
      - SEATA_IP=127.0.0.1
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
    # 需要把file.conf和registry.conf都放到./seata-server/config文件夾中
      - "./seata-server/config:/root/seata-config"
  # seata服務(wù)3
  seata-server-3:
    image: seataio/seata-server:1.4.2
    hostname: seata-server
    ports:
      - "8093:8093"
    environment:
      # 指定seata服務(wù)啟動端口
      - SEATA_PORT=8093
      # 注冊到nacos上的ip??蛻舳藢⑼ㄟ^該ip訪問seata服務(wù)。
      # 注意公網(wǎng)ip和內(nèi)網(wǎng)ip的差異。
      - SEATA_IP=127.0.0.1
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
    # 需要把file.conf和registry.conf都放到./seata-server/config文件夾中
      - "./seata-server/config:/root/seata-config"

環(huán)境變量

seata-server 支持以下環(huán)境變量:

  • SEATA_IP

可選, 指定seata-server啟動的IP, 該IP用于向注冊中心注冊時使用, 如eureka等

  • SEATA_PORT

可選, 指定seata-server啟動的端口, 默認(rèn)為 8091

  • STORE_MODE

可選, 指定seata-server的事務(wù)日志存儲方式, 支持db ,file,redis(Seata-Server 1.3及以上版本支持), 默認(rèn)是 file

  • SERVER_NODE

可選, 用于指定seata-server節(jié)點(diǎn)ID, 如 1,2,3..., 默認(rèn)為 根據(jù)ip生成

  • SEATA_ENV

可選, 指定 seata-server 運(yùn)行環(huán)境, 如 dev, test 等, 服務(wù)啟動時會使用 registry-dev.conf 這樣的配置

  • SEATA_CONFIG_NAME

可選, 指定配置文件位置, 如 file:/root/registry, 將會加載 /root/registry.conf 作為配置文件,如果需要同時指定 file.conf文件,需要將registry.confconfig.file.name的值改為類似file:/root/file.conf

表結(jié)構(gòu)

<a id="mysql">(1)mysql</a>

-- -------------------------------- 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;

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 = InnoDB
  DEFAULT 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);

<a id="oracle">(2)oracle</a>

-- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE global_table
(
    xid                       VARCHAR2(128) NOT NULL,
    transaction_id            NUMBER(19),
    status                    NUMBER(3)     NOT NULL,
    application_id            VARCHAR2(32),
    transaction_service_group VARCHAR2(32),
    transaction_name          VARCHAR2(128),
    timeout                   NUMBER(10),
    begin_time                NUMBER(19),
    application_data          VARCHAR2(2000),
    gmt_create                TIMESTAMP(0),
    gmt_modified              TIMESTAMP(0),
    PRIMARY KEY (xid)
);

CREATE INDEX idx_gmt_modified_status ON global_table (gmt_modified, status);
CREATE INDEX idx_transaction_id ON global_table (transaction_id);

-- the table to store BranchSession data
CREATE TABLE branch_table
(
    branch_id         NUMBER(19)    NOT NULL,
    xid               VARCHAR2(128) NOT NULL,
    transaction_id    NUMBER(19),
    resource_group_id VARCHAR2(32),
    resource_id       VARCHAR2(256),
    branch_type       VARCHAR2(8),
    status            NUMBER(3),
    client_id         VARCHAR2(64),
    application_data  VARCHAR2(2000),
    gmt_create        TIMESTAMP(6),
    gmt_modified      TIMESTAMP(6),
    PRIMARY KEY (branch_id)
);

CREATE INDEX idx_xid ON branch_table (xid);

-- the table to store lock data
CREATE TABLE lock_table
(
    row_key        VARCHAR2(128) NOT NULL,
    xid            VARCHAR2(128),
    transaction_id NUMBER(19),
    branch_id      NUMBER(19)    NOT NULL,
    resource_id    VARCHAR2(256),
    table_name     VARCHAR2(32),
    pk             VARCHAR2(36),
    gmt_create     TIMESTAMP(0),
    gmt_modified   TIMESTAMP(0),
    PRIMARY KEY (row_key)
);

CREATE INDEX idx_branch_id ON lock_table (branch_id);

CREATE TABLE distributed_lock (
    lock_key     VARCHAR2(20)  NOT NULL,
    lock_value        VARCHAR2(20)  NOT NULL,
    expire       DECIMAL(18)   NOT NULL,
    PRIMARY KEY (lock_key)
);

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);

<a id="postgresql">(3) postgresql</a>

-- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE IF NOT EXISTS public.global_table
(
    xid                       VARCHAR(128) NOT NULL,
    transaction_id            BIGINT,
    status                    SMALLINT     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                TIMESTAMP(0),
    gmt_modified              TIMESTAMP(0),
    CONSTRAINT pk_global_table PRIMARY KEY (xid)
);

CREATE INDEX idx_gmt_modified_status ON public.global_table (gmt_modified, status);
CREATE INDEX idx_transaction_id ON public.global_table (transaction_id);

-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS public.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            SMALLINT,
    client_id         VARCHAR(64),
    application_data  VARCHAR(2000),
    gmt_create        TIMESTAMP(6),
    gmt_modified      TIMESTAMP(6),
    CONSTRAINT pk_branch_table PRIMARY KEY (branch_id)
);

CREATE INDEX idx_xid ON public.branch_table (xid);

-- the table to store lock data
CREATE TABLE IF NOT EXISTS public.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     TIMESTAMP(0),
    gmt_modified   TIMESTAMP(0),
    CONSTRAINT pk_lock_table PRIMARY KEY (row_key)
);

CREATE INDEX idx_branch_id ON public.lock_table (branch_id);

CREATE TABLE distributed_lock (
    lock_key     VARCHAR(20)  NOT NULL,
    lock_value        VARCHAR(20)  NOT NULL,
    expire       BIGINT       NOT NULL,
    CONSTRAINT pk_distributed_lock_table PRIMARY KEY (lock_key)
);

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);

配置示例

<a id="registry.example.conf">(1) registry.example.conf</a>

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "file"

  nacos {
    application = "seata-server"
    serverAddr = "127.0.0.1:8848"
    group = "SEATA_GROUP"
    namespace = ""
    cluster = "default"
    username = ""
    password = ""
  }
  eureka {
    serviceUrl = "http://localhost:8761/eureka"
    application = "default"
    weight = "1"
  }
  redis {
    serverAddr = "localhost:6379"
    db = 0
    password = ""
    cluster = "default"
    timeout = 0
  }
  zk {
    cluster = "default"
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
  }
  consul {
    cluster = "default"
    serverAddr = "127.0.0.1:8500"
    aclToken = ""
  }
  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 = "127.0.0.1:8848"
    namespace = ""
    group = "SEATA_GROUP"
    username = ""
    password = ""
    dataId = "seataServer.properties"
  }
  consul {
    serverAddr = "127.0.0.1:8500"
    aclToken = ""
  }
  apollo {
    appId = "seata-server"
    ## apolloConfigService will cover apolloMeta
    apolloMeta = "http://192.168.1.204:8801"
    apolloConfigService = "http://192.168.1.204:8080"
    namespace = "application"
    apolloAccesskeySecret = ""
    cluster = "seata"
  }
  zk {
    serverAddr = "127.0.0.1:2181"
    sessionTimeout = 6000
    connectTimeout = 2000
    username = ""
    password = ""
    nodePath = "/seata/seata.properties"
  }
  etcd3 {
    serverAddr = "http://localhost:2379"
  }
  file {
    name = "file.conf"
  }
}

<a id="file.example.conf">(2) file.example.conf</a>

store {
  ## 存儲模式: file、db、redis,三選一
  mode = "file"
  ## rsa加密公鑰,可選
  publicKey = ""
  ## file store property
  file {
    ## 存儲路徑
    dir = ""
    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
    maxBranchSessionSize = 16384
    # globe session size , if exceeded throws exceptions
    maxGlobalSessionSize = 512
    # file buffer size , if exceeded allocate new buffer
    fileWriteBufferCacheSize = 16384
    # when recover batch read size
    sessionReloadReadSize = 100
    # 刷盤方式:async, sync
    flushDiskMode = async
  }

  ## database store property
  db {
    ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
    datasource = "druid"
    ## mysql/oracle/postgresql/h2/oceanbase etc.
    dbType = "mysql"
    ## 注意不同mysql版本對應(yīng)的driver
    driverClassName = "com.mysql.jdbc.Driver"
    ## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
    url = "jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatements=true"
    user = "mysql"
    password = "mysql"
    minConn = 5
    maxConn = 100
    globalTable = "global_table"
    branchTable = "branch_table"
    lockTable = "lock_table"
    queryLimit = 100
    maxWait = 5000
  }

  ## redis store property
  redis {
    ## redis mode: single、sentinel
    mode = "single"
    ## single mode property
    single {
      host = "127.0.0.1"
      port = "6379"
    }
    ## sentinel mode property
    sentinel {
      masterName = ""
      ## such as "10.28.235.65:26379,10.28.235.65:26380,10.28.235.65:26381"
      sentinelHosts = ""
    }
    password = ""
    database = "0"
    minConn = 1
    maxConn = 10
    maxTotal = 100
    queryLimit = 100
  }
}

# 下面配置為可選,根據(jù)業(yè)務(wù)場景選擇使用

transport {
  # tcp, unix-domain-socket
  type = "TCP"
  #NIO, NATIVE
  server = "NIO"
  #enable heartbeat
  heartbeat = true
  # the client batch send request enable
  enableClientBatchSendRequest = false
  #thread factory for netty
  threadFactory {
    bossThreadPrefix = "NettyBoss"
    workerThreadPrefix = "NettyServerNIOWorker"
    serverExecutorThreadPrefix = "NettyServerBizHandler"
    shareBossWorker = false
    clientSelectorThreadPrefix = "NettyClientSelector"
    clientSelectorThreadSize = 1
    clientWorkerThreadPrefix = "NettyClientWorkerThread"
    # netty boss thread size
    bossThreadSize = 1
    #auto default pin or 8
    workerThreadSize = "default"
  }
  shutdown {
    # when destroy server, wait seconds
    wait = 3
  }
  serialization = "seata"
  compressor = "none"
}

## server configuration, only used in server side
server {
  recovery {
    #schedule committing retry period in milliseconds
    committingRetryPeriod = 1000
    #schedule asyn committing retry period in milliseconds
    asynCommittingRetryPeriod = 1000
    #schedule rollbacking retry period in milliseconds
    rollbackingRetryPeriod = 1000
    #schedule timeout retry period in milliseconds
    timeoutRetryPeriod = 1000
  }
  undo {
    logSaveDays = 7
    #schedule delete expired undo_log in milliseconds
    logDeletePeriod = 86400000
  }
  #check auth
  enableCheckAuth = true
  #unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
  maxCommitRetryTimeout = "-1"
  maxRollbackRetryTimeout = "-1"
  rollbackRetryTimeoutUnlockEnable = false
  retryDeadThreshold = 130000
}

## metrics configuration, only used in server side
metrics {
  enabled = false
  registryType = "compact"
  # multi exporters use comma divided
  exporterList = "prometheus"
  exporterPrometheusPort = 9898
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容