最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何在docker中安裝seata

 更新時(shí)間:2025年11月25日 09:47:56   作者:亦安?  
文章介紹了如何在Docker中安裝Seata,包括下載鏡像、運(yùn)行容器、配置數(shù)據(jù)庫、修改配置文件、啟動(dòng)Seata以及在微服務(wù)項(xiàng)目中使用Seata的步驟,感興趣的朋友跟隨小編一起看看吧

在docker中安裝seata

1. 下載鏡像

#不加 :2.0.0下載的是最新版本的seata
docker pull seataio/seata-server:2.0.0

查看鏡像

docker images

2. 運(yùn)行容器

運(yùn)行seata-server,將配置拷貝到宿主機(jī)中,刪除之前配置并通過宿主機(jī)運(yùn)行容器

#運(yùn)行容器
docker run --name seata -p 8091:8091 -d  seataio/seata-server:2.0.0

#將容器中的配置拷貝到/data/seata
docker cp seata:/seata-server /data
#刪除
docker rm -f seata

3.新建數(shù)據(jù)庫

建庫

CREATE DATABASE seata;
USE seata;

在上一步的seata庫里建表

-- -------------------------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE IF NOT EXISTS `global_table`
(
    `xid`                       VARCHAR(128) NOT NULL,
    `transaction_id`            BIGINT,
    `status`                    TINYINT      NOT NULL,
    `application_id`            VARCHAR(32),
    `transaction_service_group` VARCHAR(32),
    `transaction_name`          VARCHAR(128),
    `timeout`                   INT,
    `begin_time`                BIGINT,
    `application_data`          VARCHAR(2000),
    `gmt_create`                DATETIME,
    `gmt_modified`              DATETIME,
    PRIMARY KEY (`xid`),
    KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
    KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4;
-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(
    `branch_id`         BIGINT       NOT NULL,
    `xid`               VARCHAR(128) NOT NULL,
    `transaction_id`    BIGINT,
    `resource_group_id` VARCHAR(32),
    `resource_id`       VARCHAR(256),
    `branch_type`       VARCHAR(8),
    `status`            TINYINT,
    `client_id`         VARCHAR(64),
    `application_data`  VARCHAR(2000),
    `gmt_create`        DATETIME(6),
    `gmt_modified`      DATETIME(6),
    PRIMARY KEY (`branch_id`),
    KEY `idx_xid` (`xid`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4;
-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(
    `row_key`        VARCHAR(128) NOT NULL,
    `xid`            VARCHAR(128),
    `transaction_id` BIGINT,
    `branch_id`      BIGINT       NOT NULL,
    `resource_id`    VARCHAR(256),
    `table_name`     VARCHAR(32),
    `pk`             VARCHAR(36),
    `status`         TINYINT      NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
    `gmt_create`     DATETIME,
    `gmt_modified`   DATETIME,
    PRIMARY KEY (`row_key`),
    KEY `idx_status` (`status`),
    KEY `idx_branch_id` (`branch_id`),
    KEY `idx_xid` (`xid`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4;
CREATE TABLE IF NOT EXISTS `distributed_lock`
(
    `lock_key`       CHAR(20) NOT NULL,
    `lock_value`     VARCHAR(20) NOT NULL,
    `expire`         BIGINT,
    primary key (`lock_key`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4;
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

4.修改配置文件

找到宿主機(jī)上的/data/seata-server/resources 里的application.yml文件

打開后主要修改這幾個(gè)

下面是我修改后的

#  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: ${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:
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
      namespace:
      group: SEATA_GROUP #后續(xù)自己在nacos里面新建,不想新建SEATA_GROUP,就寫DEFAULT_GROUP
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      server-addr: 127.0.0.1:8848
      group: SEATA_GROUP #后續(xù)自己在nacos里面新建,不想新建SEATA_GROUP,就寫DEFAULT_GROUP
      namespace:
      cluster: default
      username: nacos
      password: nacos    
  store:
    mode: db
    db:
      datasource: druid
      db-type: mysql
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/seata?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
      user: root
      password: 123456
      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
  #  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,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/metadata/v1/**

5.啟動(dòng)

docker run -d --restart=always  --name  seata -p 8091:8091 -p 7091:7091 -v /data/seata-server:/seata-server  seataio/seata-server:2.0.0

PS: 8091是注冊(cè)進(jìn)nacos的默認(rèn)端口, 7091是訪問客戶端的端口

6. 驗(yàn)證

http://localhost:7091/#/login

初始密碼是配置文件中的

7.在微服務(wù)項(xiàng)目中使用 (每個(gè)用到seata的項(xiàng)目都要添加)

首先要配置pom

 <!-- Alibaba Seata 配置 -->
 <dependency>
     <groupId>io.seata</groupId>
     <artifactId>seata-spring-boot-starter</artifactId>
     <version>2.0.0</version>
 </dependency>

在application.yml中添加seata的配置

# ========================seata===================
seata:
  tx-service-group: default_tx_group
  service:
    vgroup-mapping:
      default_tx_group: default #要和seata配置中的registry.nacos.cluster一致
    grouplist:
      default: 127.0.0.1:8091
  registry:
    type: nacos
    nacos:
      server-addr: 127.0.0.1:8848
      namespace: 
      group: SEATA_GROUP
      application: seata-server
      username: nacos
      password: nacos
  data-source-proxy-mode: AT
logging:
  level:
    io:
      seata: info

在用到的庫中添加undo_log日志回滾表 (AT模式專用,其他模式不需要)

-- for AT mode you must to init this sql for you business database. the seata server not need it.
CREATE TABLE IF NOT EXISTS `undo_log`
(
    `branch_id`     BIGINT       NOT NULL COMMENT 'branch transaction id',
    `xid`           VARCHAR(128) NOT NULL COMMENT 'global transaction id',
    `context`       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
    `rollback_info` LONGBLOB     NOT NULL COMMENT 'rollback info',
    `log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
    `log_created`   DATETIME(6)  NOT NULL COMMENT 'create datetime',
    `log_modified`  DATETIME(6)  NOT NULL COMMENT 'modify datetime',
    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
ALTER TABLE `undo_log` ADD INDEX `ix_log_created` (`log_created`);

到此這篇關(guān)于在docker中安裝seata的文章就介紹到這了,更多相關(guān)docker安裝seata內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • docker安裝nacos的詳細(xì)教程

    docker安裝nacos的詳細(xì)教程

    這篇文章主要介紹了docker安裝nacos,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • 詳解如何進(jìn)入、退出docker容器的方法

    詳解如何進(jìn)入、退出docker容器的方法

    這篇文章主要介紹了詳解如何進(jìn)入、退出docker容器的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Docker network自定義網(wǎng)絡(luò)方式

    Docker network自定義網(wǎng)絡(luò)方式

    這篇文章主要介紹了Docker network自定義網(wǎng)絡(luò)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • docker overlay2 文件夾比較大處理步驟

    docker overlay2 文件夾比較大處理步驟

    本文介紹了Docker默認(rèn)存儲(chǔ)驅(qū)動(dòng)overlay2文件夾變得大時(shí)的清理方法,包括清理未使用的Docker對(duì)象、刪除未使用的容器和鏡像、清理日志文件和數(shù)據(jù)卷等步驟,通過這些步驟,可以有效釋放磁盤空間并避免存儲(chǔ)空間不足的問題,感興趣的朋友跟隨小編一起看看吧
    2025-03-03
  • 一文詳解docker容器中的memory限制

    一文詳解docker容器中的memory限制

    在Docker中,內(nèi)存管理是非常重要的一部分,Docker提供了一些功能來管理容器的內(nèi)存使用情況,其中包括內(nèi)存限制、內(nèi)存交換和內(nèi)存統(tǒng)計(jì)等,本文給大家詳細(xì)介紹了docker容器中的memory限制,需要的朋友可以參考下
    2024-04-04
  • 詳解docker容器硬盤動(dòng)態(tài)擴(kuò)容

    詳解docker容器硬盤動(dòng)態(tài)擴(kuò)容

    本篇文章主要介紹了詳解docker容器硬盤動(dòng)態(tài)擴(kuò)容,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • 在docker容器中elasticsearch的導(dǎo)入導(dǎo)出方式

    在docker容器中elasticsearch的導(dǎo)入導(dǎo)出方式

    文章詳細(xì)介紹了如何使用Docker拉取Elasticsearch鏡像,并導(dǎo)出和導(dǎo)入索引數(shù)據(jù),還討論了在Elasticsearch?Head中解決請(qǐng)求頭顯示不正確的問題,包括從容器中復(fù)制文件、編輯文件和將文件回傳到容器
    2025-11-11
  • Docker網(wǎng)段和內(nèi)網(wǎng)網(wǎng)段ip沖突導(dǎo)致無法訪問網(wǎng)絡(luò)的兩種解決方法

    Docker網(wǎng)段和內(nèi)網(wǎng)網(wǎng)段ip沖突導(dǎo)致無法訪問網(wǎng)絡(luò)的兩種解決方法

    本文主要介紹了Docker網(wǎng)段和內(nèi)網(wǎng)網(wǎng)段沖突導(dǎo)致無法訪問網(wǎng)絡(luò)的兩種解決方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • Docker volume使用詳解及實(shí)例

    Docker volume使用詳解及實(shí)例

    這篇文章主要介紹了Docker volume使用詳解及實(shí)例的相關(guān)資料,并附簡(jiǎn)單實(shí)例,幫助大家學(xué)習(xí)參考,需要的朋友可以看下
    2016-11-11
  • docker容器設(shè)置時(shí)區(qū)的幾種方式小結(jié)

    docker容器設(shè)置時(shí)區(qū)的幾種方式小結(jié)

    Docker的基礎(chǔ)鏡像設(shè)置大多是Etc/UTC,也就是標(biāo)準(zhǔn)的UTC 時(shí)間,所以要簡(jiǎn)單的調(diào)整一下,本文主要介紹了docker容器設(shè)置時(shí)區(qū)的幾種方式小結(jié),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-05-05

最新評(píng)論

贺兰县| 驻马店市| 化隆| 江阴市| 玉龙| 屯门区| 太仓市| 灌阳县| 和政县| 永安市| 广德县| 永康市| 巴东县| 托里县| 凭祥市| 伊通| 苏尼特左旗| 右玉县| 漳平市| 镶黄旗| 高唐县| 黎城县| 太仆寺旗| 金平| 阿拉尔市| 华容县| 桃江县| 多伦县| 大冶市| 泾源县| 齐齐哈尔市| 梧州市| 永登县| 太仓市| 南川市| 尚义县| 济源市| 长治市| 宝兴县| 微博| 周口市|