下载地址:https://github.com/seata/seata/releases
安装
cd /usr/local && mkdir seata && cd seata
tar -zxvf seata-server-1.4.0.tar.gz && mv seata seata-1.4.0
解压目录介绍
- 可执行文件目录
bat格式文件为windows系统启动文件
sh格式文件为linux系统启动文件
- 服务端配置文件
registry {
type = "nacos"
loadBalance = "RandomLoadBalance"
loadBalanceVirtualNodes = 10
nacos {
application = "seata-server"
serverAddr = "*.*.*.*:8840"
group = "SEATA_GROUP"
namespace = ""
cluster = "default"
username = "nacos账号"
password = "nacos密码"
}
}
config {
type = "nacos"
nacos {
serverAddr = "*.*.*.*:8840"
namespace = ""
group = "SEATA_GROUP"
username = "nacos账号"
password = "nacos密码"
}
}
store {
mode = "db"
db {
datasource = "druid"
dbType = "mysql"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://127.0.0.1:3306/seata"
user = "mysql账号"
password = "mysql密码"
minConn = 5
maxConn = 100
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
<!-- <property name="LOG_HOME" value="${user.home}/logs/seata"/> -->
<property name="LOG_HOME" value="/usr/local/seata/seata-1.4.0/logs/seata"/>
初始化数据库表结构
CREATE DATABASE seata default character set utf8 collate utf8_general_ci;
GRANT ALL PRIVILEGES on seata.* to 'lixing'@'%';
FLUSH PRIVILEGES;
- 创建服务端 global_table、branch_table、lock_table 表(mysql版本)
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;
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;
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;
- 创建客户端 undo_log 表(mysql版本)(一个微服务即为一个客户端,需要为每个微服务数据库实例创建)
CREATE TABLE IF NOT EXISTS `undo_log`
(
`branch_id` BIGINT(20) NOT NULL COMMENT 'branch transaction id',
`xid` VARCHAR(100) NOT NULL COMMENT 'global transaction id',
`context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
`rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
`log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
`log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
`log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';
启动
设置开机自启、开启端口:点我
nohup sh /usr/local/seata/seata-1.4.0/bin/seata-server.sh -h 192.168.233.131 -p 8091 >/dev/null 2>&1 &
自定义Seata配置文件
|