当前位置:网站首页>Seata deployment and microservice integration
Seata deployment and microservice integration
2022-07-26 14:23:00 【Liu Chu, Ge Nian】
List of articles
Deploy Seata Of tc-server
1. download
First we need to download seata-server package , The address in http/seata.io/zh-cn/blog/download.html

Also prepared Baidu online disk download link for you :
link :https://pan.baidu.com/s/1gm3MWasl0AzAVBNb6vUC6Q?pwd=hcd6
Extraction code :hcd6
– From Baidu network disk super member V6 The share of

2. decompression
Unzip this in a non Chinese Directory zip package , Its directory structure is as follows :

3. Modify the configuration
modify conf In the catalog registry.conf file :

The contents are as follows :
registry {
# tc Registry class of the service , Choose here nacos, It can also be eureka、zookeeper etc.
type = "nacos"
nacos {
# seata tc Service registered to nacos Service name of , You can customize
application = "seata-tc-server"
serverAddr = "127.0.0.1:8848"
group = "DEFAULT_GROUP"
namespace = ""
cluster = "SH"
username = "nacos"
password = "nacos"
}
}
config {
# Read tc The configuration file of the server , From here nacos Configuration center read , So if tc It's clustering , Configuration can be shared
type = "nacos"
# To configure nacos Address and other information
nacos {
serverAddr = "127.0.0.1:8848"
namespace = ""
group = "SEATA_GROUP"
username = "nacos"
password = "nacos"
dataId = "seataServer.properties"
}
}
Cover :

4. stay nacos Add the configuration
Particular attention , In order to make tc Clusters of services can share configurations , We chose nacos As a unified configuration center . Therefore, the server configuration file seataServer.properties Documents need to be in nacos Middle match .
The format is as follows :

The configuration is as follows :
# Data storage mode ,db On behalf of the database
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=root
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
# Business 、 Log and other configurations
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
# Transmission mode between client and server
transport.serialization=seata
transport.compressor=none
# close metrics function , Improve performance
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
The database address 、 user name 、 Passwords need to be changed to your own database information .
5. Create database tables
Particular attention :tc Services when managing distributed transactions , You need to record transaction related data into the database , You need to create these tables in advance .
Create a new one called seata The database of , Run the following method to create a table
These tables mainly record global transactions 、 Branch business 、 Global lock information :
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Branch transaction table
-- ----------------------------
DROP TABLE IF EXISTS `branch_table`;
CREATE TABLE `branch_table` (
`branch_id` bigint(20) NOT NULL,
`xid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`transaction_id` bigint(20) NULL DEFAULT NULL,
`resource_group_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`resource_id` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`branch_type` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`status` tinyint(4) NULL DEFAULT NULL,
`client_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`application_data` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gmt_create` datetime(6) NULL DEFAULT NULL,
`gmt_modified` datetime(6) NULL DEFAULT NULL,
PRIMARY KEY (`branch_id`) USING BTREE,
INDEX `idx_xid`(`xid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Global transaction table
-- ----------------------------
DROP TABLE IF EXISTS `global_table`;
CREATE TABLE `global_table` (
`xid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`transaction_id` bigint(20) NULL DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`transaction_service_group` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`transaction_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`timeout` int(11) NULL DEFAULT NULL,
`begin_time` bigint(20) NULL DEFAULT NULL,
`application_data` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gmt_create` datetime NULL DEFAULT NULL,
`gmt_modified` datetime NULL DEFAULT NULL,
PRIMARY KEY (`xid`) USING BTREE,
INDEX `idx_gmt_modified_status`(`gmt_modified`, `status`) USING BTREE,
INDEX `idx_transaction_id`(`transaction_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
SET FOREIGN_KEY_CHECKS = 1;
6. start-up TC service
Get into bin Catalog , Run the seata-server.bat that will do :

After successful startup ,seata-server Should have registered to nacos Registration Center .
Open the browser , visit nacos Address :http://localhost:8848, Then go to the service list page , You can see seata-tc-server Information about :

Microservice Integration seata
1. Introduce dependencies
First , We need to introduce... Into microservices seata rely on :
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<exclusions>
<!-- Lower version ,1.3.0, Thus eliminate -->
<exclusion>
<artifactId>seata-spring-boot-starter</artifactId>
<groupId>io.seata</groupId>
</exclusion>
</exclusions>
</dependency>
<!--seata starter use 1.4.2 edition -->
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>${seata.version}</version>
</dependency>
2. Modify the configuration file
Need modification application.yml file , Add some configuration :
seata:
registry: # TC Configuration of service registry , According to this information, microservices go to the registry to obtain tc Service address
# Reference resources tc Serve your own registry.conf Configuration in
type: nacos
nacos: # tc
server-addr: 127.0.0.1:8848
namespace: ""
group: DEFAULT_GROUP
application: seata-tc-server # tc The service is nacos Service name in
cluster: SH
tx-service-group: seata-demo # Transaction group , According to this, get tc Service cluster name
service:
vgroup-mapping: # Transaction group and TC service cluster The mapping relation of
seata-demo: SH

边栏推荐
- 『SignalR』.NET使用 SignalR 进行实时通信初体验
- 融合多自然语言处理任务的中医辅助诊疗方案研究——以糖尿病为例
- 基于双层主题模型的技术演化分析框架及其应用
- Plato farm is expected to further expand its ecosystem through elephant swap
- 低功耗多通道WFAS1431无线数据采集采发仪使用流程说明
- MySQL-03 数据库操作
- 2022-07-26 Daily: the first anniversary of the establishment of alphafold DB database, research on the lighting point of official promotion
- ~6. ccf 2021-09-1 数组推导
- URL的使用下载资源
- 初识Opencv4.X----图像透视变换
猜你喜欢

融合多自然语言处理任务的中医辅助诊疗方案研究——以糖尿病为例

One stop monitoring of the software and hardware infrastructure of the whole university, and Suzhou University replaces PostgreSQL with time series database

基于标签嵌入注意力机制的多任务文本分类模型

全校软硬件基础设施一站式监控 ,苏州大学以时序数据库替换 PostgreSQL

Uni app from creation to operation to wechat developer tool

Use cpolar to build a commercial website (apply for website security certificate)
![[paper reading] raw+:a two view graph propagation method with word coupling for readability assessment](/img/14/1a02d564c59724d04fce340b6b227d.png)
[paper reading] raw+:a two view graph propagation method with word coupling for readability assessment

Technology evolution analysis framework based on two-level topic model and its application

sp导出贴图到maya

How can red star Macalline design cloud upgrade the traditional home furnishing industry in ten minutes to produce film and television level interior design effects
随机推荐
作业7.25 排序与查找
Flink SQL (III) connects to the external system system and JDBC
UDP multithreaded online chat
【数学建模】常用基本模型总结
uni-app从创建到运行到微信开发者工具
Integer internal cache
如何做 APP 升级测试 ?
Circular queue (implemented in C language)
Understand the meaning of length in MySQL data types
C语言_结构体指针来访问结构体数组
Unity学习笔记–无限地图
Multithreading - thread pool
图神经网络Core数据集介绍
[paper reading] raw+:a two view graph propagation method with word coupling for readability assessment
基于SPO语义三元组的疾病知识发现
sp导出贴图到maya
Add a display horizontal line between idea methods
Difference between base addressing and index addressing
如何评价测试质量?
Redis data operation