• seata环境的安装


    1.给每个需要进行分布式事务控制的服务的数据库增加一个undo_log表

    -- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
    CREATE TABLE `undo_log` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `branch_id` bigint(20) NOT NULL,
      `xid` varchar(100) NOT NULL,
      `context` varchar(128) NOT NULL,
      `rollback_info` longblob NOT NULL,
      `log_status` int(11) NOT NULL,
      `log_created` datetime NOT NULL,
      `log_modified` datetime NOT NULL,
      `ext` varchar(100) DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    2.linux虚拟机普通的部署

    # seata-server部署文档
    
    1.上传,将`seata-server-1.3.0.zip`上传到`/usr/local/software`目录下
    
    2.解压文件到指定目录
    
    ```shell
    unzip /usr/local/software/seata-server-1.3.0.zip -d /usr/local
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    3.修改日志配置文件,否则启动控制台乱码(如果是window的情况需要修改如下配置)

    vi /usr/local/seata/conf/logback.xml
    
    • 1

    原配置如下:

    <property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wEx"/>
    
    • 1

    修改成如下格式:

    <property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p --- %[%15.15t] %-40.40logger{39} : %m%n%wEx"/>
    
    • 1

    此问题是因为开发者为seata1.3.0添加字体颜色,而在window中的shell脚本内不显示发生的乱码错误

    4.修改registry.config文件

    vi /usr/local/seata/conf/registry.conf
    
    • 1

    修改内容如下:[注意需要把下面nacos的IP地址修改成实际地址]

    registry {
      # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
      type = "nacos"
    
      nacos {
        application = "seata-server"
        serverAddr = "nacos的IP地址:8848"
        group = "SEATA_GROUP"
        namespace = ""
        cluster = "default"
        username = ""
        password = ""
      }
    }
    
    config {
      # file、nacos 、apollo、zk、consul、etcd3
      type = "nacos"
      nacos {
        serverAddr = "nacos的IP地址:8848"
        namespace = ""
        group = "SEATA_GROUP"
        username = ""
        password = ""
      }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    5.启动seata-server

    nohup /usr/local/seata/bin/seata-server.sh -h 目前所在服务器ip地址 -p 7000 >log.out 2>1 &
    
    • 1
    1. jps看到server seata启动成功
    2. 在nacos看到seata之后标识成功注册到naocs
    
    最后就是对每个使用分布式事务的服务的配置
    
    	com.alibaba.cloud
    	spring-cloud-starter-alibaba-seata
    	2.2.2.RELEASE
    	
    		
                io.seata
    			seata-spring-boot-starter
    		
    	
    
    
    	io.seata
    	seata-spring-boot-starter
    	1.3.0
    
    
    yml
    
    seata:
      tx-service-group: seckill-service-group
      registry:
        type: nacos
        nacos:
          server-addr: ${spring.cloud.nacos.config.server-addr}
          group: SEATA_GROUP
          application: seata-server
      service:
        vgroup-mapping:
          seckill-service-group: default
    
    
    
    两个group名字要一样seckill-service-group,最好根据服务命名
    
    最后就是在分布式事务的入口加上@GlobalTransactional就可以完成整个配置了
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
  • 相关阅读:
    java spring cloud 工程企业管理软件-综合型项目管理软件-工程系统源码
    windows10+WSL的ubuntu子系统cuda+cudnn安装与配置
    AI降临,前端启用面壁计划
    [附源码]计算机毕业设计springboot汽车租赁管理系统
    Flowable工作流之任务回退
    【Redis】事务、lua脚本、发布订阅、异步连接
    青少年python系列 25.turtle库绘制一个田字方格的方框
    BurpSuite官方实验室之逻辑漏洞
    JavaScript简单类型和复杂类型
    根据机械臂视频模拟出运动路线
  • 原文地址:https://blog.csdn.net/qq_56533553/article/details/132841326