概述
单机部署 Seata TC Server,常用于学习或测试使用,不建议在生产环境中部署单机。因为 TC 需要进行全局事务和分支事务的记录,所以需要对应的存储。
目前,TC 有两种存储模式:
- file 模式:适合单机模式,全局事务会话信息在内存中读写,并持久化本地文件 root.data,性能较高;
- db 模式:适合集群模式,全局事务会话信息通过 db 共享,相对性能差点。
采用 file 模式部署单机 Seata TC Server 如下图:

下载Seata
- 进入网址:https://github.com/seata/seata/tags
- 选择版本,并点击进入

- 下载服务包

安装Seata服务
- 上传seata-server服务包(通过rz或者其他方式)
- 解压seata-server服务包
tar -xvf seata-server-1.4.1.tar.gz
- 配置file.conf文件(db方式,需要新增三张表)
/*
Navicat MySQL Data Transfer
Source Server : dev
Source Server Version : 50728
Source Host : rm-s8vmywrq.mysql.rds.aliyuncs.com:3306
Source Database : seata
Target Server Type : MYSQL
Target Server Version : 50728
File Encoding : 65001
Date: 2021-02-25 17:57:50
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for branch_table
-- ----------------------------
DROP TABLE IF EXISTS `branch_table`;
CREATE TABLE `branch_table` (
`branch_id` bigint(20) NOT NULL,
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`resource_group_id` varchar(32) DEFAULT NULL,
`resource_id` varchar(256) DEFAULT NULL,
`lock_key` varchar(128) DEFAULT NULL,
`branch_type` varchar(8) DEFAULT NULL,
`status` tinyint(4) DEFAULT NULL,
`client_id` varchar(64) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`branch_id`),
KEY `idx_xid` (`xid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for global_table
-- ----------------------------
DROP TABLE IF EXISTS `global_table`;
CREATE TABLE `global_table` (
`xid` varchar(128) NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(32) DEFAULT NULL,
`transaction_service_group` varchar(32) DEFAULT NULL,
`transaction_name` varchar(128) DEFAULT NULL,
`timeout` int(11) DEFAULT NULL,
`begin_time` bigint(20) DEFAULT NULL,
`application_data` varchar(2000) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`,`status`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for lock_table
-- ----------------------------
DROP TABLE IF EXISTS `lock_table`;
CREATE TABLE `lock_table` (
`row_key` varchar(128) NOT NULL,
`xid` varchar(96) DEFAULT NULL,
`transaction_id` mediumtext,
`branch_id` mediumtext,
`resource_id` varchar(256) DEFAULT NULL,
`table_name` varchar(32) DEFAULT NULL,
`pk` varchar(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
PRIMARY KEY (`row_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- 配置registry.conf文件(eureka方式)

启动Seata服务
- 单网卡启动
nohup ./seata-server.sh > log.out 2>1 &
- 多网卡启动并指定ip(nohup ./seata-server.sh -h ip -p port 2>1 &)
nohup ./seata-server.sh -h 10.10.92.132 -p 8091 2>1 &
本文介绍单机部署Seata TC Server,适用于学习或测试,不建议用于生产环境。阐述了TC的两种存储模式:file模式适合单机,性能高;db模式适合集群,性能稍差。还详细说明了下载、安装和启动Seata服务的步骤。
1193





