Seata安装
Docker安装
- 复制配置文件
1
2
3
4
5
6path=/usr/local/software/docker/seata
mkdir -p $path
docker run -d --name seata-test seataio/seata-server
docker cp seata-test:/seata-server/resources/registry.conf $path
docker stop seata-test && docker rm seata-test - 修改配置文件 registry.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22registry {
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "192.168.1.128:8848"
group = "SEATA_GROUP"
username = "nacos"
password = "nacos"
}
}
config {
type = "nacos"
nacos {
serverAddr = "192.168.1.128:8848"
group = "SEATA_GROUP"
username = "nacos"
password = "nacos"
}
} - 导入配置至Nacos
1
2
3
4
5
6
7
8
9
10
11
12
13
14Shell脚本地址
https://github.com/seata/seata/blob/master/script/config-center/nacos/nacos-config.sh
配置文件地址 需要放置在Shell脚本上一级目录
配置描述参考 http://seata.io/zh-cn/docs/user/configurations.html
https://github.com/seata/seata/blob/master/script/config-center/config.txt
创建Seata命名空间 customNamespaceId为空时会自动生成
curl 'http://192.168.1.128:8848/nacos/v1/console/namespaces' \
-d 'username=nacos&password=nacos&customNamespaceId=namespaceId&namespaceName=SEATA_GROUP'
导入配置
./nacos-config.sh \
-h 192.168.1.128 -p 8848 \
-t namespaceId \
-u nacos -w nacos - 启动
1
2
3
4
5
6
7
8docker run -d \
--name seata-test \
-p 8091:8091 \
-e SEATA_IP=192.168.1.128 \
-v $path/registry.conf:/seata-server/resources/registry.conf \
seataio/seata-server
docker logs -f seata-test
测试
1 | 每个微服务模块中创建undo_log表 |
代码参考 https://github.com/tothis/spring-cloud-record/tree/main/seata