Seata 搭配MySQL8 启动运行教程(Seata 默认不支持 MySQL8)

    科技2022-07-10  96

    文章目录

    1. 官网下载2. 解压到指定目录并修改 conf 目录下的 file.conf 配置文件3. MySQL8 数据库新建库 seata,并建立三张表和替换 MySQL8 驱动4. 修改 conf 目录下的registry.conf 配置文件5. 先启动 Nacos 端口号 88486. 再启动 bin 目录下的 seata-server.bat

    1. 官网下载

    发布说明:https://github.com/seata/seata/releases

    2. 解压到指定目录并修改 conf 目录下的 file.conf 配置文件

    修改 Service 模块(自定义事务组名称): vgroup_mapping.my_test_tx_group = "fsp_tx_group" 修改 store 模块(让信息保存在数据库、默认是保存在文件中): mode = "db" driver-class-name = "com.mysql.cj.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata?serverTimezone=UTC" user = "root" password = "你自己的密码"

    3. MySQL8 数据库新建库 seata,并建立三张表和替换 MySQL8 驱动

    建表语句如下: SQL 语句如下:

    -- 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`) );

    因为默认不支持 8,所以在 lib 文件夹下替换 mysql 的驱动 jar 包。lib 文件夹下,已经由一个 jdbc 文件夹,把里面驱动版本为 8 的 jar 包拷贝到外面 lib 文件夹下即可。

    4. 修改 conf 目录下的registry.conf 配置文件

    5. 先启动 Nacos 端口号 8848

    6. 再启动 bin 目录下的 seata-server.bat

    Processed: 0.009, SQL: 8