提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
docker部署seata
1.拉取seata镜像
docker pull seataio/seata-server:1.4.0
2.在/usr/dev/seata/config 新建配置文件registry.conf
注册中心和配置中心使用nacos
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "10.0.0.1:8848" #nacos内网地址
namespace = ""
cluster = "default"
username = ""
password = ""
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
file {
name = "file.conf"
}
}
3.在/usr/dev/seata/config 新建配置文件file.conf
store {
## store mode: file、db
mode = "db"
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc.
datasource = "druid"
## mysql/oracle/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://10.0.0.1:3306/seata" #数据库内网地址
user = "root"
password = "123456"
min-conn = 5
max-conn = 30
global.table = "global_table"
branch.table = "branch_table"
lock-table = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
4.在file.conf里指定的mysql中新建seata库,新建3张表
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`)
);
5.启动seata
docker run --name seata-server \
-p 8091:8091 \
-e SEATA_IP=1.10.200.166 \
-e SEATA_PORT=8091 \
-e SEATA_CONFIG_NAME=file:/root/seata-config/registry \
-v /usr/dev/seata/config:/root/seata-config \
-d seataio/seata-server:1.4.0
如果想要不在同一服务器上的服务能注册到seata,SEATA_IP得是外网地址
6.验证seata是否启动成功
查看服务列表,若seata成功注册到nacos,则说明启动成功