当前位置: 首页 > article >正文

Docker 安装 Seata2.0.0 (快速配置)

说明:已安装Docker、MySql等,案例使用Mysql数据库模式、Nacos配置信息

1、准备工作

        1.1  拉取镜像

[root@Tseng ~]# docker pull seataio/seata-server:2.0.0
2.0.0: Pulling from seataio/seata-server
001c52e26ad5: Already exists 
d9d4b9b6e964: Pull complete 
2068746827ec: Pull complete 
9daef329d350: Pull complete 
d85151f15b66: Pull complete 
52a8c426d30b: Pull complete 
8754a66e0050: Pull complete 
4aea97b391f0: Pull complete 
8f2debbba8c0: Pull complete 
5e194ee1a562: Pull complete 
916cd6df19b7: Pull complete 
adc1f51855c8: Pull complete 
5a8a99da95e5: Pull complete 
211b9fa044c5: Pull complete 
e1e7722cd2fd: Pull complete 
Digest: sha256:0cf5ea82efab238c48f72f44001c5de56f23e8f64a857b4653135e78c5359e09
Status: Downloaded newer image for seataio/seata-server:2.0.0
[root@Tseng ~]#

        1.2  配置文件 application.yml

server:
  port: 7091

spring:
  application:
    name: seata-server

logging:
  config: classpath:logback-spring.xml
  file:
    path: ${log.home:${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

# 同一台服务器部署的Nacos 内网IP 及seata对应的命名空间信息
seata:
  config:
    # support: nacos, consul, apollo, zk, etcd3
    type: nacos
    nacos:
      server-addr: 192.168.2.81:8848  
      username: nacos
      password: nacos
      namespace: 05c4cbcd-59b6-4371-b2cf-d241d75a4e1c
      data-id: seata-server.properties
  registry:
    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    type: nacos
    nacos:
      application: seata-server
      server-addr: 192.168.2.81:8848
      username: nacos
      password: nacos
      namespace: 05c4cbcd-59b6-4371-b2cf-d241d75a4e1c

  security:
      secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
      tokenValidityInMilliseconds: 1800000
      ignore:
          urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/metadata/v1/**

        1.3 准备数据库 

        SQL :https://github.com/apache/incubator-seata/blob/2.0.0/script/server/db/mysql.sql

         

         1.4  seata 对应Nacos 配置        seata-server.properties

# 数据存储方式,db代表数据库
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://192.168.2.81:3308/seata?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=PRC&useSSL=false&allowPublicKeyRetrieval=true
store.db.user=root
store.db.password=Hv123456
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
# 事务、日志等配置
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.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000

# 客户端与服务端传输方式
transport.serialization=seata
transport.compressor=none
# 关闭metrics功能,提高性能
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

 1.5 Nginx 配置信息

server {
    listen 80;
    server_name seata.my.com;

    location / {
        client_max_body_size 100m;
        proxy_pass http://192.168.2.81:7091;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-NginX-Proxy true;
    }
}

2、获取配置信息

        2.1 创建配置文件目录

[root@Tseng ~]# mkdir -p /data/seata/config
[root@Tseng ~]#

        2.2 启动临时容器

[root@Tseng ~]# cd /data/seata/config
[root@Tseng config]# docker run --name seata-server -d --rm -p 8091:8091 -p 7091:7091 seataio/seata-server:2.0.0
d46962d31951b64922ceb97af465f054f0dde49d317f73beacc6492c3af1bbe6
[root@Tseng config]#

        2.3 将容器内默认配置文件复制出来

[root@Tseng config]# docker cp seata-server:/seata-server/resources /data/seata/config
[root@Tseng config]# ls
resources
[root@Tseng config]#

        2.4 停止容器,删除默认配置文件,建立新的配置文件

[root@Tseng config]# docker stop d469
d469
[root@Tseng config]# cd resources/
[root@Tseng resources]# ls
application.example.yml  application.raft.example.yml  application.yml  banner.txt  docker  io  logback  logback-spring.xml  lua  META-INF  README.md  README-zh.md
[root@Tseng resources]# rm -rf application.yml
# 1.2 步骤中的配置文件信息
[root@Tseng resources]# vim application.yml  
[root@Tseng resources]# cat application.yml
server:
  port: 7091

spring:
  application:
    name: seata-server

logging:
  config: classpath:logback-spring.xml
  file:
    path: ${log.home:${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.2.81:8848
      username: nacos
      password: nacos
      namespace: 05c4cbcd-59b6-4371-b2cf-d241d75a4e1c
      data-id: seata-server.properties
  registry:
    # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    type: nacos
    nacos:
      application: seata-server
      server-addr: 192.168.2.81:8848
      username: nacos
      password: nacos
      namespace: 05c4cbcd-59b6-4371-b2cf-d241d75a4e1c

  security:
      secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
      tokenValidityInMilliseconds: 1800000
      ignore:
          urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/metadata/v1/**

[root@Tseng resources]#

3、启动新的容器

[root@Tseng resources]# docker run --name seata-server -d -p 8191:8091 -p 7091:7091 -e SEATA_IP='192.168.2.81' --restart=always -v /data/seata/config/resources/application.yml:/seata-server/resources/application.yml  seataio/seata-server:2.0.0
7f3141228fb1df42dd643d9e9be0fd3b6e4e2eea806117f04a64f5c381208a01
[root@Tseng resources]# docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
7f3141228fb1        seataio/seata-server:2.0.0   "/bin/bash /seata-se…"   3 seconds ago       Up 2 seconds        0.0.0.0:7091->7091/tcp, 0.0.0.0:8191->8091/tcp             seata-server
dcb867bba3f8        nacos/nacos-server:v2.4.3    "sh bin/docker-start…"   10 days ago         Up 18 hours         0.0.0.0:8848->8848/tcp, 0.0.0.0:9848-9849->9848-9849/tcp   nacos243
6ecff9da64ef        nginx:1.26.2                 "/docker-entrypoint.…"   3 weeks ago         Up 44 hours         0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp                   nginx
5372d6f6c213        mysql:8.0.18                 "docker-entrypoint.s…"   3 weeks ago         Up 18 hours         33060/tcp, 0.0.0.0:3308->3306/tcp                          mysql3308.8.0.18
72e4a9a96a7f        redis:6.0.6                  "docker-entrypoint.s…"   3 weeks ago         Up 44 hours         0.0.0.0:16379->6379/tcp                                    redis16379
[root@Tseng resources]#

 


http://www.kler.cn/a/441721.html

相关文章:

  • 汽车钥匙发展史
  • 2. CSS 中的单位
  • Java Web开发高级——单元测试与集成测试
  • 偏序关系.
  • 深度学习-89-大语言模型LLM之AI应用开发的基本概念
  • Docker 实现MySQL 主从复制
  • Django基础 - 01入门简介
  • .Net Core配置使用Log4Net日志记录
  • 梳理你的思路(从OOP到架构设计)_认识EIT造形与内涵
  • 编译glibc
  • 【YashanDB知识库】如何处理yasql输入交互模式下单行字符总量超过限制4000字节
  • 商业智能汽车充电桩 功能介绍
  • SpringBoot整合MybatisPlus报错Bean不存在:NoSuchBeanDefinitionException
  • C#高级:Winform桌面开发中TreeView的基础例子
  • PH热榜 | 2024-12-17
  • 【多维 DP】力扣2400. 恰好移动 k 步到达某一位置的方法数目
  • 陕西科技大学《2024年807自动控制原理真题》 (完整版)
  • You need to call SQLitePCL.raw.SetProvider()
  • Java中的设计模式全解及电商应用场景示例
  • IP数据云查询IP归属地信息
  • 数据结构:Win32 API详解
  • CXF WebService SpringBoot 添加拦截器,处理响应报文格式
  • React里循环tab列表,并实现点击切换class
  • C语言学习day19:结构体/枚举/共用体/游戏结构体的逆向分析
  • Uniapp安卓端获取手机号码
  • Docker中 localhost 与 0.0.0.0 的区别详解