🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
**1. 下载Seata后解压** https://github.com/seata/seata/releases/tag/v1.0.0 ![](https://img.kancloud.cn/78/6b/786b0e4deb9801411903ac1c3a242675_1373x294.png) **2. 修改文件`%SEATA_HOME%\conf\file.conf`** ```conf #将原来的default改为自己想要的名字 vgroup_mapping.my_test_tx_group = "fsp_tx_group" #将file改成db mode = "db" # 填写自己MySQL数据的用户名和密码 db-type = "mysql" driver-class-name = "com.mysql.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata" user = "root" password = "root" ``` **3. 在MySQL中创建`seata`数据库并在该库下运行脚本`mysql.sql`** https://github.com/seata/seata/tree/1.0.0/script/server/db ![](https://img.kancloud.cn/5a/c0/5ac0c2e677f325880bb9fd8854db753b_1519x262.png) ```sql -- -------------------------------- 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_gmt_modified_status` (`gmt_modified`, `status`), KEY `idx_transaction_id` (`transaction_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- 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, `gmt_modified` DATETIME, PRIMARY KEY (`branch_id`), KEY `idx_xid` (`xid`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; -- the table to store lock data CREATE TABLE IF NOT EXISTS `lock_table` ( `row_key` VARCHAR(128) NOT NULL, `xid` VARCHAR(96), `transaction_id` BIGINT, `branch_id` BIGINT NOT NULL, `resource_id` VARCHAR(256), `table_name` VARCHAR(32), `pk` VARCHAR(36), `gmt_create` DATETIME, `gmt_modified` DATETIME, PRIMARY KEY (`row_key`), KEY `idx_branch_id` (`branch_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; ``` **4. 修改文件`%SEATA_HOME%\conf\register.conf`** ```conf registry { # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa type = "nacos" #选择nacos作为注册中心 nacos { serverAddr = "localhost:8848" #nacos服务地址 namespace = "" cluster = "default" } ``` **5. 验证是否搭建成功** 确保nacos已经启动,然后执行`%SEATA_HOME%\bin\seata-server.bat`启动Seata服务。出现如下信息则Seata搭建成功。 ![](https://img.kancloud.cn/02/44/024499b9ac9364eb25c8c0487a83b97d_1898x289.png)