Table of contents
introduction
Recently, Seata TCC integration is being done. During the integration process, Seata Server is upgraded from the original 1.4.2 to the latest 1.5.2. This article records the upgrade process of Seata 1.5.
For the installation process of the original Seata 1.4.2, please refer to my previous blog:
Distributed Transactions - Seata - Getting Started with AT => 2. Start Seata Server (TC)
download link
Download address: https://github.com/seata/seata/releases/tag/v1.5.2
configuration
After decompression, you can find that the original conf/registry.conf configuration file is gone, and you can directly modify application.yml for configuration.
The application.yml configuration content is also similar to the original registry.conf, mainly including the following two configurations:
- The configuration center used by Seata (support file, nacos, consul, apollo, zk, etcd3)
- The service registry used by Seata (support file, nacos, eureka, redis, zk, consul, etcd3, sofa)
Also taking it 配置中心、注册中心使用Nacos,store.mode=db(mysql)
as an example, the application.yml sample configuration is given as follows:
server:
port: 7091
spring:
application:
name: seata-server
# 日志配置
logging:
config: classpath:logback-spring.xml
file:
path: ${
user.home}/logs/seata
# 不外接日志,故如下配置可暂不考虑
extend:
logstash-appender:
destination: 127.0.0.1:4560
kafka-appender:
bootstrap-servers: 127.0.0.1:9092
topic: logback_to_logstash
# 新增加的console控制台,
# 可通过访问http://localhost:7091进行登录,账号如下seata/seata
console:
user:
username: seata
password: seata
seata:
# Seata接入Nacos配置中心
config:
# support: file, nacos, consul, apollo, zk, etcd3
type: nacos
nacos:
server-addr: 127.0.0.1:8848
namespace: luo-dev
group: SEATA_GROUP
username: nacos
password: nacos
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key: ""
#secret-key: ""
data-id: seataServer.properties
# Seata接入Nacos服务注册中心
registry:
# support: file, nacos, eureka, redis, zk, consul, etcd3, sofa
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
group: SEATA_GROUP
namespace: luo-dev
cluster: default
username: nacos
password: nacos
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key: ""
#secret-key: ""
# 此处可不必配置,由于接入了nacos配置,以下store相关配置可直接通过seataServer.properties进行配置
# store:
# support: file 、 db 、 redis
# mode: db
# server:
# service-port: 8091 #If not configured, the default is '${server.port} + 1000'
security:
secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
tokenValidityInMilliseconds: 1800000
ignore:
urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
For the Nacos configuration used in the above configuration seataServer.properties
, see the original content:
1.5.2/script/config-center/config.txt
For specific adjustments, please refer to my previous blog:
Distributed Transactions - Seata - Getting Started with AT => 2. Start Seata Server(TC) => (5) Import initial configuration to nacos
Initial Mysql database
-
When upgrading from Seata1.4 to 1.5, the database script has changed. Take mysql as an example:
- 1.4 msyql script: 1.4.2/script/server/db/mysql.sql
- 1.5 mysql脚本: 1.5.2/script/server/db/mysql.sql Compared with version 1.4, the mysql script of version 1.5 is mainly adjusted as follows:
- The distributed_lock table is newly added,
- The original lock_table table adds a new status column,
- And the utf8 encoding of 1.4 is adjusted to the utf8mb4 encoding of 1.5.
Remember to initialize the database with the new version's database scripts before upgrading.
Support TCC Fence
Seata version 1.5 solves the problems of idempotency, empty rollback, and suspension in TCC mode
. To support this feature, it is necessary to additionally import the table tcc-fence-log in the business database of each service :
CREATE TABLE IF NOT EXISTS `tcc_fence_log`
(
`xid` VARCHAR(128) NOT NULL COMMENT 'global id',
`branch_id` BIGINT NOT NULL COMMENT 'branch id',
`action_name` VARCHAR(64) NOT NULL COMMENT 'action name',
`status` TINYINT NOT NULL COMMENT 'status(tried:1;committed:2;rollbacked:3;suspended:4)',
`gmt_create` DATETIME(3) NOT NULL COMMENT 'create time',
`gmt_modified` DATETIME(3) NOT NULL COMMENT 'update time',
PRIMARY KEY (`xid`, `branch_id`),
KEY `idx_gmt_modified` (`gmt_modified`),
KEY `idx_status` (`status`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
Note: Seata 1.5 solves the problems of TCC idempotence, suspension, and empty rollback. See:
The new version of Ali Seata finally solves the problems of idempotency, suspension, and empty rollback in TCC mode
After the above adjustments are made, it can be started directly via /bin/seata-server.bat|sh.