下载
https://seata.io/zh-cn/blog/download.html
修改配置 \seata\script\config-center\config.txt
这里使用nacos+db的方式持久化,其他的可以删除.
#有关配置项目的详细信息,请参阅https://seata.io/zh-cn/docs/user/configurations.html
#客户端和服务器的传输配置
transport.type=TCP
transport.server=NIO
transport.heartbeat=true
transport.enableTmClientBatchSendRequest=false
transport.enableRmClientBatchSendRequest=true
transport.enableTcServerBatchSendResponse=false
transport.rpcRmRequestTimeout=30000
transport.rpcTmRequestTimeout=30000
transport.rpcTcRequestTimeout=30000
transport.threadFactory.bossThreadPrefix=NettyBoss
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
transport.threadFactory.clientSelectorThreadSize=1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
transport.shutdown.wait=3
transport.serialization=seata
transport.compressor=none
#事务路由规则配置,仅适用于客户端
service.vgroupMapping.default_tx_group=default
#如果使用注册表,则可以忽略它
service.default.grouplist=172.0.13.142:7091
service.enableDegrade=false
service.disableGlobalTransaction=false
#事务规则配置,仅适用于客户端
client.rm.asyncCommitBufferLimit=10000
client.rm.lock.retryInterval=10
client.rm.lock.retryTimes=30
client.rm.lock.retryPolicyBranchRollbackOnConflict=true
client.rm.reportRetryCount=5
client.rm.tableMetaCheckEnable=true
client.rm.tableMetaCheckerInterval=60000
client.rm.sqlParserType=druid
client.rm.reportSuccessEnable=false
client.rm.sagaBranchRegisterEnable=false
client.rm.sagaJsonParser=fastjson
client.rm.tccActionInterceptorOrder=-2147482648
client.tm.commitRetryCount=5
client.tm.rollbackRetryCount=5
client.tm.defaultGlobalTransactionTimeout=60000
client.tm.degradeCheck=false
client.tm.degradeCheckAllowTimes=10
client.tm.degradeCheckPeriod=2000
client.tm.interceptorOrder=-2147482648
client.undo.dataValidation=true
client.undo.logSerialization=jackson
client.undo.onlyCareUpdateColumns=true
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000
client.undo.logTable=undo_log
client.undo.compress.enable=true
client.undo.compress.type=zip
client.undo.compress.threshold=64k
#对于TCC事务模式
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h
#日志规则配置,适用于客户端和服务器
log.exceptionRate=100
#事务存储配置,仅适用于服务器。文件、数据库和redis配置值是可选的。
store.mode=db
store.lock.mode=db
store.session.mode=db
#用于密码加密
#store.publicKey=
#如果“store.mode、store.lock.mode、store.session.mode”不等于“file”,则可以删除配置块。
#store.file.dir=file_store/data
#store.file.maxBranchSessionSize=16384
#store.file.maxGlobalSessionSize=512
#store.file.fileWriteBufferCacheSize=16384
#store.file.flushDiskMode=async
#store.file.sessionReloadReadSize=100
#如果“存储模式”为“数据库”,则需要这些配置。如果“store.mode,store.lock.mode,store.session.mode”不等于“db”,则可以删除配置块。
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://1.12.255.194:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=root
store.db.password=mysql@2023
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.distributedLockTable=distributed_lock
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
#如果“存储模式”是“redis”,则需要这些配置。如果“store.mode,store.lock.mode,store.session.mode”不等于“redis”,则可以删除配置块。store.redis.mode=single
#store.redis.single.host=172.0.13.142
#store.redis.single.port=6379
#store.redis.sentinel.masterName=
#store.redis.sentinel.sentinelHosts=
#store.redis.maxConn=10
#store.redis.minConn=1
#store.redis.maxTotal=100
#store.redis.database=0
#store.redis.password=casa
#store.redis.queryLimit=100
#事务规则配置,仅适用于服务器
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.distributedLockExpireTime=10000
server.xaerNotaRetryTimeout=60000
server.session.branchAsyncQueueSize=5000
server.session.enableBranchAsyncRemove=false
server.enableParallelRequestHandle=false
#指标配置,仅适用于服务器
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
上传config.txt到nacos
创建DB库
\seata\script\server\db
修改seata配置文件 \seata\conf\application.yml
这里配置的Nacos作用是读取刚刚上传到nacos的配置文件.配置两次重复是因为服务发现与配置中心可分开使用.
# Copyright 1999-2019 Seata.io Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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:
user:
username: seata
password: seata
seata:
config:
# support: nacos, consul, apollo, zk, etcd3
type: nacos
nacos:
server-addr: 127.0.0.1:8850
namespace: 5fe66036-c7ed-4606-8357-f7108d4dcc13
group: SEATA_GROUP
username: nacos
password: nacos
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
data-id: seataServer.properties
registry:
# support: nacos, eureka, redis, zk, consul, etcd3, sofa
type: nacos
#preferred-networks: 172.22.*
nacos:
application: seata-server
server-addr: 172.0.13.142:8850
namespace: 5fe66036-c7ed-4606-8357-f7108d4dcc13
group: SEATA_GROUP
username: nacos
password: nacos
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
store:
# support: file 、 db 、 redis
mode: db
db:
datasource: druid
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatements=true
user: root
password: root
min-conn: 10
max-conn: 100
global-table: global_table
branch-table: branch_table
lock-table: lock_table
distributed-lock-table: distributed_lock
query-limit: 1000
max-wait: 5000
security:
secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
tokenValidityInMilliseconds: 1800000
ignore:
urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
通过脚本启动seata \seata\bin\seata-server.sh
日志 \seata\log\start.out
这里启动脚本有一点报错,并不影响.
查看GUI http://127.0.0.1:7091 账号密码seata/seata
nacos也注册上了.
遇到问题:
1.脚本启动失败,报JVM参数异常, 解决方法: 检查JDK版本
2.seata注册到nacos的ip地址不对,导致RM无法绑定Seata. 解决方法:在seata脚本启动时添加-h标记ip地址.
git: https://gitee.com/move-brick/alibaba