声明:
本文用于本人技术学习和备忘。水平有限,如有错漏欢迎指正!
原创不易,如有转载请标注出处:https://blog.csdn.net/luyou0401/article/details/126621635
Seata版本号:1.5.2
Nacos版本号:2.0.3
Mysql版本号:8.0.27
官方文档:https://seata.io/zh-cn/docs/ops/deploy-by-docker.html
https://hub.docker.com/r/seataio/seata-server
# 默认版本 latest
docker pull seataio/seata-server:latest
# 如需指定版本,如下
docker pull seataio/seata-server:1.5.2
操作如下:
luyou@MBP-yaco ~ % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
seataio/seata-server 1.5.2 f6a5368b6720 6 weeks ago 186MB
结果:
根据需要创建本地目录
用途 | docker目录 | 本地目录 |
---|---|---|
配置文件 | /seata-server/resources | /Users/luyou/docker/seata/conf |
根据配置需要,将配置文件放置在本地目录中:
安装docker时会默认创建一个内部的桥接网络,每创建一个容器分配一个虚拟网卡,容器之间可以根据ip互相访问。
下述配置文件均使用此IP,否则将无法连接Docker中其他Nacos和Mysql服务。使用Mac终端查询:
配置服务注册中心和配置中心使用nacos,如下:
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: 192.168.31.70:8848
namespace: 0184a7fe-5043-4582-abc2-5b552a216315
group: SEATA_GROUP
username: nacos
password: nacos
##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
nacos:
application: seata-server
server-addr: 192.168.31.70:8848
group: SEATA_GROUP
namespace: 0184a7fe-5043-4582-abc2-5b552a216315
cluster: default
username: nacos
password: nacos
# store:
# support: file 、 db 、 redis
# mode: file
# 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
进入nacos配置管理,在yml配置的namespace选项卡下,新增配置:
根据yml配置信息如下:
配置内容如下:
#For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
#Transport configuration, for client and server
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
#Transaction routing rules configuration, only for the client
service.vgroupMapping.default_tx_group=default
#If you use a registry, you can ignore it
service.default.grouplist=127.0.0.1:8091
service.enableDegrade=false
service.disableGlobalTransaction=false
#Transaction rule configuration, only for the client
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
#For TCC transaction mode
tcc.fence.logTableName=tcc_fence_log
tcc.fence.cleanPeriod=1h
#Log rule configuration, for client and server
log.exceptionRate=100
#Transaction storage configuration, only for the server. The file, DB, and redis configuration values are optional.
store.mode=db
store.lock.mode=db
store.session.mode=db
#Used for password encryption
#store.publicKey=
#If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
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
#These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://192.168.31.70:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=seatauser
store.db.password=seata125@
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
#These configurations are required if the `store mode` is `redis`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `redis`, you can remove the configuration block.
store.redis.mode=single
store.redis.single.host=127.0.0.1
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=
store.redis.queryLimit=100
#Transaction rule configuration, only for the server
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 configuration, only for the server
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898
与默认配置差异为:
store.mode=db
store.lock.mode=db
store.session.mode=db
# mysql8:com.mysql.cj.jdbc.Driver;mysql8以前版本:com.mysql.jdbc.Driver
store.db.driverClassName=com.mysql.cj.jdbc.Driver
# 替换自己的mysql配置
store.db.url=jdbc:mysql://192.168.31.70:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=seatauser
store.db.password=seata125@
# 使用默认配置启动
docker run --name seata-server -p 8091:8091 seataio/seata-server:1.5.2
# 指定配置启动
docker run --name seata-server \
-p 8091:8091 \
-p 7091:7091 \
-v /Users/luyou/docker/seata/conf/application.yml:/seata-server/resources/application.yml \
-d seataio/seata-server:1.5.2
结果:
命令行:
docker start seata-server
图形界面:
命令行:
docker stop seata-server
图形界面:
命令行:
docker rm seata-server
图形界面:
命令行:
docker logs -f seata-server
图形界面:
图形日志:
# 进入容器
docker exec -it seata-server sh
# 退出容器
exit
声明:
本文用于本人技术学习和备忘。水平有限,如有错漏欢迎指正!
原创不易,如有转载请标注出处:https://blog.csdn.net/luyou0401/article/details/126621635