Seata-Server安装
一、下载
下载地址:https://github.com/seata/seata/releases
二、安装
1、解压缩
2、修改conf目录下的file.conf配置文件
- 先备份原始file.conf文件
3、修改
自定义事务组名称+事务日志存储模式为db+数据库连接信息
如果是使用的更高版本的mysql则需要稍加修改:
driver-class-name = “com.mysql.cj.jdbc.Driver”
url = "jdbc:mysql://127.0.0.1:3306/seata?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true"
4、在mysql中新建seata库
![在这里插入图片描述](https://img-blog.csdnimg.cn/88eb1169d8f74fee8cbdd5420de82acc.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MDc4Nzgx,size_16,color_FFFFFF,t_70)
5、在seata库建表
- 新建查询,输入以下sql语句,并执行
```sql
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)
);
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)
);
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)
);
6、修改seata-server-0.9.0\seata\conf目录下的registry.conf配置文件
- 先备份registry.conf文件
- 修改seata-server-0.9.0\seata\conf目录下的registry.conf配置文件
三、测试
1、启动Nacos端口号8848
- 找到Nacos目录下的bin文件,双击startup.cmd
2、启动seata-server
- 导航到seata目录下的bin文件,在导航栏输入cmd并回车
- 输入seata-server.bat启动seata(防止闪退)
3、查看服务
- 在浏览器输入http://localhost:8848/nacos/进入Nacos服务平台
- 点击服务列表,就可以看到seata注册进Nacos中