首页 > 其他分享 >Docker部署Seata

Docker部署Seata

时间:2024-04-08 13:22:29浏览次数:24  
标签:Seata 部署 redis server client transport Docker store seata

参考文档:https://blog.csdn.net/qq_38066812/article/details/136238350

版本1.6.1
注意点:配置文件中关于nacos的addr,namespace,username,password,group,data-id等要与nacos中一致;IP地址相关的配置要考虑在容器内是否可以访问到

安装

docker pull seataio/seata-server:1.6.0
# 启动容器
docker run -d --name seata-server -p 8091:8091 -p 7091:7091  seataio/seata-server:1.6.0
# 拷贝文件到宿主机目录/mydata/services/seata/resources(这个目录需要先手动创建)
cd /mydata/services
mkdir seata
cd /mydata/services/seata
mkdir resources
docker cp seata-server:/seata-server/resources  /mydata/services/seata/
# 停止并删除容器
docker stop seata-server
docker rm seata-server

修改配置文件application.yml

修改/mydata/services/seata/resources目录下的文件application.yml

#  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: www.shimeng.cc:8848
      namespace: da52f965-b3db-4120-9677-dd4339edea79
      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
    nacos:
      application: seata-server
      server-addr: www.shimeng.cc:8848
      namespace: da52f965-b3db-4120-9677-dd4339edea79
      group: SEATA_GROUP
      username: nacos
      password: nacos
      cluster: default
      #context-path:
      ##if use MSE Nacos with auth, mutex with username/password attribute
      #access-key: ""
      #secret-key: ""
  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中创建配置文件seataServer.properties

#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
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=redis
store.lock.mode=redis
store.session.mode=redis
#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.jdbc.Driver
store.db.url=jdbc:mysql://www.shimeng.cc:3306/seata?useUnicode=true&rewriteBatchedStatements=true
store.db.user=username
store.db.password=password
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=www.shimeng.cc
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=root
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

重启

# 重新启动容器
docker run -i -t -d --restart always --name seata-server \
-p 7091:7091 -p 8091:8091  \
-e SEATA_IP=www.shimeng.cc \
-e SEATA_PORT=8091 \
-e TZ=Asia/Shanghai  \
-v /mydata/services/seata/resources:/seata-server/resources \
-v /etc/localtime:/etc/localtime \
seataio/seata-server:1.6.0

# -e SEATA_IP=[公网IP] 这个ip必须是公网ip,否则会访问失败

项目中配置

seata:
  application-id: ${spring.application.name}
  #数据源代理模式使用AT模式(可以不用配置,seata默认使用AT模式)
  data-source-proxy-mode: AT
  tx-service-group: mygroup # 事务分组名称,要和服务端对应
  #事务群组(可以每个应用独立取名,也可以使用相同的名字),
  #要与服务端nacos配置seataServer.properties中service.vgroupMapping.mygroup=default中存在,
  #此处的mygroup名字可以自定义,与 tx-service-group: mygroup中的mygroup保持一致
  service:
    vgroup-mapping:
      mygroup: default
  enabled: false

标签:Seata,部署,redis,server,client,transport,Docker,store,seata
From: https://www.cnblogs.com/fortuneju/p/18120919

相关文章

  • 开源大模型本地私有化部署
    1、安装ollamaollma下载https://ollama.com/download/windowslinux安装curl-fsSLhttps://ollama.com/install.sh|sh运行ollamarungemma:2bollamarungemma:7b使用端口114342、下载open-webui代码https://github.com/open-webui/open-webui.git生成目录open-webuidoc......
  • ubuntu2204 部署 stable-diffusion-webui
    显卡:(一个实例仅能用一张卡)顶配:rtx6000ada48g,a10040g,a100 80g,a100 96g,a80080g,h100,h200高端:rtx409024g,rtx4090D24g,rtxa600048g,rtxa500024g,rtx5000ada32g魔改:rtx2080ti22g,rtx308020g性价比:rtx4060ti16g,rtx206012g,rtx306012g,rtx309024g,rtxtitan24g其......
  • 如何建立python应用的docker镜像
    Docker是一种轻量级的容器技术,能够帮助开发人员轻松地将应用程序打包和部署到不同的环境中。Python是一种流行的编程语言,Docker可以帮助我们将Python应用程序打包成镜像,方便部署到不同的容器环境中。本文将介绍如何使用Docker构建Python应用程序的镜像。安装Docker在开始构建Pyt......
  • 从模型到部署,教你如何用Python构建机器学习API服务
    本文分享自华为云社区《Python构建机器学习API服务从模型到部署的完整指南》,作者:柠檬味拥抱。在当今数据驱动的世界中,机器学习模型在解决各种问题中扮演着重要角色。然而,将这些模型应用到实际问题中并与其他系统集成,往往需要构建API服务。本文将介绍如何使用Python构建机器学习......
  • Springboot计算机毕业设计橙心优购微信小程序的设计与实现【附源码】开题+论文+mysql+
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着移动互联网的快速发展和普及,微信小程序作为一种新兴的移动应用形态,受到了广大用户的青睐。微信小程序不仅具备即用即走、无需安装的特点,而且能够......
  • Springboot计算机毕业设计宠物领养与物品捐赠小程序【附源码】开题+论文+mysql+程序+
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着人们生活质量的提升,越来越多的人选择宠物作为生活中的伴侣。然而,宠物数量的增长也带来了一系列问题,如流浪宠物数量的增加、宠物养护知识的缺乏等......
  • Mysql8.0高可用部署
    Mysql8.0高可用部署前言目前是三台服务器,每台服务器部署mysql、mgr、proxysql、keepalived,mysql8.0是通过mgr的方式来实现mysql服务的高可用,实现故障自动检测及自动切换,发生故障时能自动切换到新的主节点,但是当程序调用的mysql对应的服务宕机后,无法自动切换到正常服务上面......
  • SpringBoot热部署
    SpringBoot热部署方便开发环境热部署就是不需要停掉服务使修改的代码生效;原来的服务器是独立的,通过配置加载当前运行的项目,现在是内置的,受SpringBoot管控,是SpringBoot的一部分,不能感知到程序的变化了,所以使用一个工具,在spring容器中操作,监控tomcat容器的变化启动热部署的工具......
  • 项目部署的error
    将springboot3项目部署到阿里云服务器运行,发送邮件时报错CouldnotconnecttoSMTPhost:smtp.qq.com,port:25,response:-1原因阿里云服务器出于安全策略的考虑,主动屏蔽了服务器25端口,导致邮件服务无法正常使用。解决办法重新编写自定义JavaMailSenderImpl,并注册为Be......
  • docker 安装gitlab
    1、查找镜像dockersearchgitlab/gitlab-ce2、下载镜像dockerpullgitlab/gitlab-ce3、创建文件夹mkdir-p/home/lihaiyang/docker/gitlab/etc/home/lihaiyang/docker/gitlab/log/home/lihaiyang/docker/gitlab/opt4、创建文件并写入配置在/home/lihaiyang/docker......