- 版本问题 seata 1.5和1.5之前的目录结构不同,使用docker修改的配置文件也不同
1.4的左右
1.5之后 - docker 挂载文件也不同
1.5之前是使用自己写的挂载registry
docker run -d -p 8091:8091 -p 7091:7091 --network newlead --name seata-serve -e SEATA_IP=192.168.249.132 -v /home/hadoop/seata-sever1.4/seata-server.conf:/seata-server/resources/registry.conf seataio/seata-server:1.4.0
1.5后就是
先运行一个容器,把目录复制出来进行挂载
docker run -d -p 8091:8091 -p 7091:7091 --name seata-serve seataio/seata-server:latest
#拷出后可以,可以选择修改application.yml再cp进容器,或者rm临时容器,如下重新创建,并做好映射路径设置
docker cp seata-serve:/seata-server/resources /User/seata/config
- 指定 application.yml
docker run --name seata-server \-p 8091:8091 \-p 7091:7091 \-e SEATA_IP=宿主机ip \-v /User/seata/config:/seata-server/resources \seataio/seata-server
-
连接不上nacos 或者springcloud连接不上seata,这三个之前
有版本依赖关系如果跨版本就会报错 -
数据库连接失败导致seata无法启动
当你的数据库是8之后,也许你的项目可以使用老驱动连接mysql,但是seata一定会报错,如果报错null指针,就要看看是否需要更换新驱动,并且有seata有些版本需要加时区
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://localhost:3306/seata?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
- 在使用seata时候需要在对应服务的库中添加undo_log回调日志表和全局锁表,不然也可能服务事务无法被seata管理
/*Navicat Premium Data TransferSource Server : localSource Server Type : MySQLSource Server Version : 50622Source Host : localhost:3306Source Schema : seata_demoTarget Server Type : MySQLTarget Server Version : 50622File Encoding : 65001Date: 20/06/2021 12:39:03
*/SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for undo_log
-- ----------------------------
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (`branch_id` bigint(20) NOT NULL COMMENT 'branch transaction id',`xid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'global transaction id',`context` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci 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 INDEX `ux_undo_log`(`xid`, `branch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'AT transaction mode undo table' ROW_FORMAT = Compact;-- ----------------------------
-- Records of undo_log
-- ------------------------------ ----------------------------
-- Table structure for lock_table
-- ----------------------------
DROP TABLE IF EXISTS `lock_table`;
CREATE TABLE `lock_table` (`row_key` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,`xid` varchar(96) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`transaction_id` bigint(20) NULL DEFAULT NULL,`branch_id` bigint(20) NOT NULL,`resource_id` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`table_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`pk` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`gmt_create` datetime NULL DEFAULT NULL,`gmt_modified` datetime NULL DEFAULT NULL,PRIMARY KEY (`row_key`) USING BTREE,INDEX `idx_branch_id`(`branch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;SET FOREIGN_KEY_CHECKS = 1;