黑龙江省城乡建设厅网站首页,利用关键词进网站后台,企业信息化管理包括哪些内容,企业网站建设用语一#xff1a;Seata基本介绍
Seata是一款开源的分布式事务解决方案#xff0c;致力于在微服务架构下提供高性能和简单易用的分布式事务服务。 详见官网链接#xff1a;https://seata.apache.org/zh-cn/
1.历史项目里的使用经验#xff1a;
之前公司里的oem用户对应的App…一Seata基本介绍
Seata是一款开源的分布式事务解决方案致力于在微服务架构下提供高性能和简单易用的分布式事务服务。 详见官网链接https://seata.apache.org/zh-cn/
1.历史项目里的使用经验
之前公司里的oem用户对应的App计划停服,通告用户手动确认迁移到obm的用户Appoem 和 obm 用户的数据表结构完全一样只是不同App对应的数据分别存储在不同的库需要保证用户在迁移后oem库里清除用户数据而obm库里同步新增用户的数据。迁移后数据需要保证的一致性。这几天工作不太忙利用碎片时间重新搭建了一套也顺便记录下整个搭建过程。
二Seata-server搭建
2.1 版本选择
Seata 也是CS结构的服务类型需要有一个Seata-server端。需要注意的是版本的选择需要和自己项目中其他的框架版本适配。
我的版本选择如下
组件版本spring-boot2.6.11spring-cloud2021.0.4spring-cloud-alibaba2021.0.4.0nacos2.0.4seata1.5.2
官网上推荐的版本适配截图见下
2.2 seata-server 下载
从seata 官网进去后寻找下载页面 中的对应版本。 具体的链接为https://seata.apache.org/zh-cn/unversioned/release-history/seata-server 下载后解压zip包
2.3 初始化DB脚本
文件路径seata\script\server\db\mysql.sql 内容如下
-- -------------------------------- 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_status_gmt_modified (status , gmt_modified),KEY idx_transaction_id (transaction_id)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;-- 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 InnoDBDEFAULT CHARSET utf8mb4;-- 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),status TINYINT NOT NULL DEFAULT 0 COMMENT 0:locked ,1:rollbacking,gmt_create DATETIME,gmt_modified DATETIME,PRIMARY KEY (row_key),KEY idx_status (status),KEY idx_branch_id (branch_id),KEY idx_xid_and_branch_id (xid , branch_id)
) ENGINE InnoDBDEFAULT CHARSET utf8mb4;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 InnoDBDEFAULT 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);创建一个新库seata 在新库里执行mysql.sql
2.4 配置文件编辑
文件路径seata\conf\application.yml application.yml 的配置信息可以参在官方给出的application.example.yml文件的配置。
# seata-server 对应的端口
server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstash# seata控制台的账号密码
console:user:username: seatapassword: seataseata:config:# support: nacos, consul, apollo, zk, etcd3#以nacos 作为配置中心具体nacos配置根据自己的nacos调整type: nacos nacos:server-addr: 127.0.0.1:8848namespace: d6eccad6-681c-4133-b9ff-1abcd951297a group: DOLPHIN_GROUPusername: nacospassword: nacosregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofa#以nacos 作为注册中心具体nacos配置根据自己的nacos调整type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group: DOLPHIN_GROUPnamespace: d6eccad6-681c-4133-b9ff-1abcd951297acluster: defaultusername: nacospassword: nacos##if use MSE Nacos with auth, mutex with username/password attribute#access-key: #secret-key: store:# support: file 、 db 、 redis#以db作为存储中心具体存储配置根据自己的选择配mode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.cj.jdbc.Driver# 步骤2.3里初始化DB脚本时创建的库url: jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatementstrueuser: rootpassword: myPwdmin-conn: 5max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 100max-wait: 5000
# server:
# service-port: 8091 #If not configured, the default is ${server.port} 1000security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login2.5 seata-server启动
seata\bin 目录下 注意启动log如下。监听的端口是8091. 是在启动的端口7091 1000 .配置文件里可见这个规则。
# server:
# service-port: 8091 #If not configured, the default is ${server.port} 10002.6 seata-server 控制台登录 登录地址localhost:7092 账号密码见application.yml 中控制台配置