一、下载
从Seata下载地址下载
https://github.com/seata/seata/releases
这里下载的是seata-server-1.5.2.tar.gz
解压:
tar -xvf seata-server-1.5.2.tar.gz
修改配置:conf/application.yml
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:8848
# namespace:
group: SEATA_GROUP
username: nacos
password: nacos
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key: ""
#secret-key: ""
data-id: seata-server.yaml
registry:
# support: nacos, eureka, redis, zk, consul, etcd3, sofa
type: nacos
#preferred-networks: *.*.*.*
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
group: SEATA_GROUP
# 默认public
# namespace:
# 加入集群名称
cluster: default
username: nacos
password: nacos
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key: ""
#secret-key: ""
# 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
二、MySQL配置
在MySQL8数据库中创建库表
安装步骤:https://blog.youkuaiyun.com/dreambyday/article/details/126022359
创建库、表、赋权
CREATE USER 'seata'@'%' IDENTIFIED BY 'seata';
create database IF NOT EXISTS seata;
GRANT ALL PRIVILEGES ON seata.* to 'seata'@'%' with GRANT OPTION;
FLUSH PRIVILEGES;
在服务器seata/script/server/db/目录下找到mysql.sql脚本并执行,建立global_table,branch_table,lock_table,distributed_lock表
三、Nacos配置
nacos 里添加配置上面配置的
data-id: seata-server.yaml
group: SEATA_GROUP
修改数据库连接信息
store:
mode: db
lock:
mode: db
session:
mode: db
db:
datasource: druid
dbType: mysql
# MySQL8的驱动
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
user: seata
password: seata
minConn: 5
maxConn: 30
globalTable: global_table
branchTable: branch_table
distributedLockTable: distributed_lock
queryLimit: 100
lockTable: lock_table
maxWait: 5000
server:
recovery:
committingRetryPeriod: 1000
asynCommittingRetryPeriod: 1000
rollbackingRetryPeriod: 1000
timeoutRetryPeriod: 1000
maxCommitRetryTimeout: -1
maxRollbackRetryTimeout: -1
rollbackRetryTimeoutUnlockEnable: false
distributedLockExpireTime: 10000
xaerNotaRetryTimeout: 60000
session:
branchAsyncQueueSize: 5000
enableBranchAsyncRemove: false
undo:
logSaveDays: 7
logDeletePeriod: 86400000
client:
rm:
asyncCommitBufferLimit: 10000
lock:
retryInterval: 10
retryTimes: 30
retryPolicyBranchRollbackOnConflict: true
reportRetryCount: 5
tableMetaCheckEnable: true
tableMetaCheckerInterval: 60000
sqlParserType: druid
reportSuccessEnable: false
sagaBranchRegisterEnable: false
sagaJsonParser: fastjson
tccActionInterceptorOrder: -2147482648
tm:
commitRetryCount: 5
rollbackRetryCount: 5
defaultGlobalTransactionTimeout: 60000
degradeCheck: false
degradeCheckAllowTimes: 10
degradeCheckPeriod: 2000
interceptorOrder: -2147482648
undo:
dataValidation: true
logSerialization: jackson
onlyCareUpdateColumns: true
logTable: undo_log
compress:
enable: true
type: zip
threshold: 64k
tcc:
fence:
logTableName: tcc_fence_log
cleanPeriod: 1h
log:
exceptionRate: 100
metrics:
enabled: false
registryType: compact
exporterList: prometheus
exporterPrometheusPort: 9898
transport:
type: TCP
server: NIO
heartbeat: true
enableTmClientBatchSendRequest: false
enableRmClientBatchSendRequest: true
enableTcServerBatchSendResponse: false
rpcRmRequestTimeout: 30000
rpcTmRequestTimeout: 30000
rpcTcRequestTimeout: 30000
threadFactory:
bossThreadPrefix: NettyBoss
workerThreadPrefix: NettyServerNIOWorker
serverExecutorThreadPrefix: NettyServerBizHandler
shareBossWorker: false
clientSelectorThreadPrefix: NettyClientSelector
clientSelectorThreadSize: 1
clientWorkerThreadPrefix: NettyClientWorkerThread
bossThreadSize: 1
workerThreadSize: default
shutdown:
wait: 3
serialization: seata
compressor: none
四、启动
启动
在bin目录下
sh seata-server.sh -p 8091 -h 127.0.0.1 -m db
查看启动日志,无报错即成功。
tail -200f 日志文件目录
访问服务
IP::7091/#/TransactionInfo
参考
- Seata官网:http://seata.io/zh-cn/docs/user/quickstart.html
- 安装参考1: https://blog.youkuaiyun.com/weixin_43036383/article/details/125765803