Seata1.2.0的配置以及踩坑记录
⾸先Seata1.2.0版本不在⾃带sql,且在f⽂件中没有了vgroup_mapping.fsp_tx_group =“default” 这项配置数据库SQL
seata数据库
drop table if exists`global_table`;
create table`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`)
);
-- the table to store BranchSession data
drop table if exists`branch_table`;
create table`branch_table`(
`branch_id`bigint not null,
`xid`varchar(128)not null,
`transaction_id`bigint,
`resource_group_id`varchar(32),
`resource_id`varchar(256),
`lock_key`varchar(128),
`branch_type`varchar(8),
`status`tinyint,
`client_id`varchar(64),
`application_data`varchar(2000),
`gmt_create`datetime,
`gmt_modified`datetime,
primary key(`branch_id`),
key`idx_xid`(`xid`)
);
-- the table to store lock data
drop table if exists`lock_table`;
create table`lock_table`(
`row_key`varchar(128)not null,
`xid`varchar(96),
`transaction_id` long ,
`branch_id` long,
`resource_id`varchar(256),
`table_name`varchar(32),
`pk`varchar(36),
`gmt_create`datetime,
`gmt_modified`datetime,
primary key(`row_key`)
);
在其它使⽤seata的数据库中建undo_log表
drop table`undo_log`;
`id`bigint(20)NOT NULL AUTO_INCREMENT,
`branch_id`bigint(20)NOT NULL,
`xid`varchar(100)NOT NULL,
`context`varchar(128)NOT NULL,
`rollback_info`longblob NOT NULL,
`log_status`int(11)NOT NULL,
`log_created`datetime NOT NULL,
`log_modified`datetime NOT NULL,
`ext`varchar(100)DEFAULT NULL,
PRIMARY KEY(`id`),
UNIQUE KEY`ux_undo_log`(`xid`,`branch_id`)
)ENGINE=InnoDB AUTO_INCREMENT=1DEFAULT CHARSET=utf8;
修改f
将mode改为db
修改数据库为⾃⼰的地址和⽤户名密码
## transaction log store, only used in seata-server
store {
## store mode: file、db
mode = "db"
## file store property
file {
## store location dir
dir = "sessionStore"
timeout of 5000ms exceeded
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
maxBranchSessionSize = 16384
# globe session size , if exceeded throws exceptions
maxGlobalSessionSize = 512
# file buffer size , if exceeded allocate new buffer
fileWriteBufferCacheSize = 16384
# when recover batch read size
sessionReloadReadSize = 100
# async, sync
flushDiskMode = async
}
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.    datasource = "druid"
## mysql/oracle/postgresql/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "sql.jdbc.Driver"
url = "jdbc:mysql://127.0.0.1:3306/seata"
user = "root"
password = "root"
minConn = 5
maxConn = 30
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
修改ample
更改的内容与f⼀致
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
# the client batch send request enable
enableClientBatchSendRequest = false
#thread factory for netty
threadFactory {
bossThreadPrefix = "NettyBoss"
workerThreadPrefix = "NettyServerNIOWorker"
serverExecutorThreadPrefix = "NettyServerBizHandler"
shareBossWorker = false
clientSelectorThreadPrefix = "NettyClientSelector"
clientSelectorThreadSize = 1
clientWorkerThreadPrefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
bossThreadSize = 1
#auto default pin or 8
workerThreadSize = "default"
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
## transaction log store, only used in server side
store {
## store mode: file、db
mode = "db"
## file store property
file {
## store location dir
dir = "sessionStore"
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
maxBranchSessionSize = 16384
# globe session size , if exceeded throws exceptions
maxGlobalSessionSize = 512
# file buffer size , if exceeded allocate new buffer
fileWriteBufferCacheSize = 16384
# when recover batch read size
sessionReloadReadSize = 100
# async, sync
flushDiskMode = async
}
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.    datasource = "druid"
## mysql/oracle/postgresql/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "sql.jdbc.Driver"
url = "jdbc:mysql://127.0.0.1:3306/seata"
user = "root"
password = "root"
minConn = 5
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
}
}
## server configuration, only used in server side
server {
recovery {
#schedule committing retry period in milliseconds
committingRetryPeriod = 1000
#schedule asyn committing retry period in milliseconds
asynCommittingRetryPeriod = 1000
#schedule rollbacking retry period in milliseconds
rollbackingRetryPeriod = 1000
#schedule timeout retry period in milliseconds
timeoutRetryPeriod = 1000
}
undo {
logSaveDays = 7
#schedule delete expired undo_log in milliseconds
logDeletePeriod = 86400000
}
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent  maxCommitRetryTimeout = "-1"
maxRollbackRetryTimeout = "-1"
rollbackRetryTimeoutUnlockEnable = false
}
## metrics configuration, only used in server side
metrics {
enabled = false
registryType = "compact"
# multi exporters use comma divided
exporterList = "prometheus"
exporterPrometheusPort = 9898
}
修改f
将type修改为nacos
修改serverAddr为localhost:8848;默认为localhsot
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "localhost:8848"
namespace = ""
cluster = "default"
username = ""
password = ""
}
eureka {
serviceUrl = "localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = 0
cluster = "default"
timeout = 0
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
username = ""
password = ""
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "f"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3  type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
group = "SEATA_GROUP"
username = ""
password = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
appId = "seata-server"
apolloMeta = "192.168.1.204:8801"    namespace = "application"
}
zk {
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
username = ""
password = ""
}
etcd3 {
serverAddr = "localhost:2379"
}
file {
name = "f"

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。