apache seata(incubating) 是一款开源的分布式事务解决方案,致力于在微服务架构下提供高性能和简单易用的分布式事务服务。
1、下载 windows 版 seata server 中间件
打开 https://https://github.com/apache/incubator-seata/releases 下载最新稳定版本或找个合适的稳定版本,至于如何打开 http://github.com 请自行百度。
当前最新稳定版本为 seata server 2.0.0,点击 seata-server-2.0.0.zip 进行下载。
2、解压 seata-server-2.0.0.zip
根目录结构(如下图):
3、自定义配置
3.1、修改 conf\application.yml 配置文件
由于配置文件的配置是一块的,只能用修改前和修改后的截图做对比,以及提供修改后对的配置字符串。
修改前(如下图):
修改后(如下图):
完整配置如下:
seata:
config:
# support: nacos, consul, apollo, zk, etcd3
type: nacos
nacos:
server-addr: 127.0.0.1:8848
namespace:
group: DEFAULT_GROUP
username: nacos
password: nacos
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
data-id: seataServer.properties
registry:
# support: nacos, eureka, redis, zk, consul, etcd3, sofa
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
group: DEFAULT_GROUP
namespace:
cluster: default
username: nacos
password: nacos
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
store:
# support: file 、 db 、 redis 、 raft
mode: db
session:
mode: db
lock:
mode: db
db:
datasource: druid
db-type: mysql
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/seata?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
user: seata
password: seata
min-conn: 10
max-conn: 100
global-table: global_table
branch-table: branch_table
lock-table: lock_table
distributed-lock-table: distributed_lock
query-limit: 1000
max-wait: 5000
redis:
mode: single
database: 0
min-conn: 10
max-conn: 100
password:
max-total: 100
query-limit: 1000
single:
host: 127.0.0.1
port: 6379
sentinel:
master-name:
sentinel-hosts:
sentinel-password:
metrics:
enabled: false
registry-type: compact
exporter-list: prometheus
exporter-prometheus-port: 9898
transport:
rpc-tc-request-timeout: 15000
enable-tc-server-batch-send-response: false
shutdown:
wait: 3
thread-factory:
boss-thread-prefix: NettyBoss
worker-thread-prefix: NettyServerNIOWorker
boss-thread-size: 1
3.2、新建一个 mysql 数据库,执行 script\server\db\mysql.sql 文件。
3.3、创建有标题的 bat
自带的 bin\seata-server.bat 没有标题,如果一台服务器运行多个用 cmd 打开的服务,就不好区分哪个是 seata server 的 bat 了,所以才需要 自建 seata.bat,脚本如下:
title seata
bin\seata-server.bat
pause
3.4、运行
想要 seata server启动成功,首先要启动 redis 和 nacos server
效果如下图就是成功的: