下载地址:seata
前提:seata各个版本的变化都挺大的 如1.0版本之前 conf目录下就带有sql文件
如1.0版本之后 conf目录下就不带有sql文件
并且文件的位置也发生了变化
但本质上没变
我这里用的 1.1版本
接下来动手吧:
进入conf文件
可以看到这是我修改好的以后的
把file.conf registry.conf file.conf.example 这三个复制一份当备胎
先修改file文件
把
他这个亦是大概就是让你选择 你要用 mode=“” file或者 db数据库
这里我们肯定用数据库呀 把file换成db
换成数据库他就会循行数据的代码
db{
}
找到db{}
这里是数据库的配置
改成自己的 账号密码 这里注意了 如果你用的 mysql8.0以上 就在驱动哪里加上 .dj
同理修改其他文件:
file.conf.example 下面也有db 这里也要修改
下一个文件:
这里也是一样 选择nacos
这样就配置好了
还有上面提到的 没有sql 表了
下面我复制sql表格 再cmd 运行就行了
CREATE DATABASE seata_account;
USE seata_account;
CREATE TABLE t_account(
id BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
user_id BIGINT(11) DEFAULT NULL COMMENT 用户id,
total DECIMAL(10,0) DEFAULT NULL COMMENT 总额度,
used DECIMAL(10,0) DEFAULT NULL COMMENT 已用额度,
residue DECIMAL(10,0) DEFAULT 0 COMMENT 剩余可用额度
)ENGINE=InnoDB AUTO_INCREMENT=7 CHARSET=utf8;
INSERT INTO t_account(id, user_id, total, used, residue) VALUES(1,1,1000,0,1000);
CREATE DATABASE seata_storage;
USE seata_storage;
CREATE TABLE t_storage(
id BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
product_id BIGINT(11) DEFAULT NULL COMMENT 产品id,
total INT(11) DEFAULT NULL COMMENT 总库存,
used INT(11) DEFAULT NULL COMMENT 已用库存,
residue INT(11) DEFAULT NULL COMMENT 剩余库存
)ENGINE=InnoDB AUTO_INCREMENT=7 CHARSET=utf8;
INSERT INTO t_storage(id, product_id, total, used, residue) VALUES(1,1,100,0,100);
CREATE DATABASE seata_order;
USE seata_order;
CREATE TABLE t_order(
id BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
user_id BIGINT(11) DEFAULT NULL COMMENT 用户id,
product_id BIGINT(11) DEFAULT NULL COMMENT 产品id,
count INT(11) DEFAULT NULL COMMENT 数量,
money DECIMAL(11,0) DEFAULT NULL COMMENT 金额,
status INT(1) DEFAULT NULL COMMENT 订单状态:0创建中,1已完结
)ENGINE=InnoDB AUTO_INCREMENT=7 CHARSET=utf8;
主表 seata
这个 自己要先建一个 数据库 然后在数据库运行就行了
-- the table to store GlobalSession data
drop table if exists `global_table`;
create table `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_gmt_modified_status` (`gmt_modified`, `status`),
key `idx_transaction_id` (`transaction_id`)
);
-- the table to store BranchSession data
drop table if exists `branch_table`;
create table `branch_table` (
`branch_id` bigint not null,
`xid` varchar(128) not null,
`transaction_id` bigint ,
`resource_group_id` varchar(32),
`resource_id` varchar(256) ,
`lock_key` varchar(128) ,
`branch_type` varchar(8) ,
`status` tinyint,
`client_id` varchar(64),
`application_data` varchar(2000),
`gmt_create` datetime,
`gmt_modified` datetime,
primary key (`branch_id`),
key `idx_xid` (`xid`)
);
-- the table to store lock data
drop table if exists `lock_table`;
create table `lock_table` (
`row_key` varchar(128) not null,
`xid` varchar(96),
`transaction_id` long ,
`branch_id` long,
`resource_id` varchar(256) ,
`table_name` varchar(32) ,
`pk` varchar(36) ,
`gmt_create` datetime ,
`gmt_modified` datetime,
primary key(`row_key`)
);
好了 这样就行了 运行就可以
先打开nacos 再打开 seata
点击运行
出错了吗? 闪退?
这里是办法:闪退解决总结