docker部署Seata
1.拉取镜像docker pull seataio/seata-server2.新增配置文件2.1 registry.conf在我们服务器目录上创建文件:registry.confregistry.conf内容如下:registry {# file 、nacos 、eureka、redis、zk、consul、etcd3、sofatype = "nacos"nacos {application =
·
1.拉取镜像
docker pull seataio/seata-server
2.新增配置文件
2.1 registry.conf
在我们服务器目录上创建文件:registry.conf
registry.conf内容如下:
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "192.168.1.2:8848" #nacos内网地址
namespace = ""
cluster = "default"
username = ""
password = ""
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
file {
name = "file.conf"
}
}
2.2 file.conf
继续创建文件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://192.168.1.2:3306/seata" #数据库内网地址
user = "root"
password = "root"
min-conn = 5
max-conn = 30
global.table = "global_table"
branch.table = "branch_table"
lock-table = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
在我们的数据库中创建数据库seata,同时在seata中创建我们file.conf里指向的表,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`)
);
3.启动seata
docker run --name seata-server \
-p 8091:8091 \
-e SEATA_IP=192.168.1.2 \
-e SEATA_PORT=8091 \
-e SEATA_CONFIG_NAME=file:/root/seata-config/registry \
-v /home/ninesun/soft/seata/config:/root/seata-config \
-d seataio/seata-server
我来解释一下上面都是什么代表什么:
- SEATA_IP
可选, 指定seata-server启动的IP, 该IP用于向注册中心注册时使用, 如eureka等 - SEATA_PORT
可选, 指定seata-server启动的端口, 默认为 8091 - STORE_MODE
可选, 指定seata-server的事务日志存储方式, 支持db 和 file, 默认是 file - SERVER_NODE
可选, 用于指定seata-server节点ID, 如 1,2,3…, 默认为 1 - SEATA_ENV
可选, 指定 seata-server 运行环境, 如 dev, test 等, 服务启动时会使用 registry-dev.conf 这样的配置 - SEATA_CONFIG_NAME
可选, 指定配置文件位置, 如 file:/root/registry, 将会加载 /root/registry.conf 作为配置文件,如果需要同时指定 file.conf文件,需要将registry.conf的config.file.name的值改为类似file:/root/file.conf:
我们需要修改启动指令的内容如下:
4.验证是否启动成功
打开nacos,如果出现以下内容说明你配置成功:
更多推荐
已为社区贡献12条内容
所有评论(0)