docker-compose db nacos 模式
准备数据库表
数据库表: https://github.com/apache/incubator-seata/tree/develop/script/server/db
准备compose.yaml文件
version: "3.1"
services:
seata-server:
image: seataio/seata-server:1.5.2
ports:
- "7091:7091"
- "8091:8091"
environment:
- STORE_MODE=db
# 以SEATA_IP作为host注册seata server
- SEATA_IP=192.168.208.128
- SEATA_PORT=8091
volumes:
- "/usr/share/zoneinfo/Asia/Shanghai:/etc/localtime" #设置系统时区
- "/usr/share/zoneinfo/Asia/Shanghai:/etc/timezone" #设置时区
# 假设我们通过docker cp命令把资源文件拷贝到相对路径`./seata-server/resources`中
# docker cp 容器id:/seata-server/resources ./resource 这步不能少
# 如有问题,请阅读上面的[注意事项]以及[使用自定义配置文件]
- "./resources:/seata-server/resources"
networks:
# 外部db数据库网络,需要先启动mysql容器,可以单独布置,或者放在这里一起布置
- hm-net
networks:
hm-net:
external: true # 来自外部
准备application.yaml文件
application 例子 注意,将/seata-server/resources拷贝出来后需要将里面的application替换
server:
port: 7091
spring:
application:
name: seata-server
console:
user:
username: liuyaowen
password: 123123
logging:
config: classpath:logback-spring.xml
file:
path: ${log.home:${user.home}/logs/seata}
extend:
logstash-appender:
destination: 127.0.0.1:4560
kafka-appender:
bootstrap-servers: 127.0.0.1:9092
topic: logback_to_logstash
seata:
config:
# support: nacos 、 consul 、 apollo 、 zk 、 etcd3
type: nacos
nacos:
server-addr: 192.168.208.128:8848
namespace: 9194952e-02a9-4737-89c2-1f3dee3317f0
group: SEATA_GROUP
username:
password:
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
preferred-networks: 30.240.*
nacos:
application: seata-server
server-addr: 192.168.208.128:8848
group: SEATA_GROUP
namespace: 9194952e-02a9-4737-89c2-1f3dee3317f0
cluster: default
username:
password:
context-path:
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
security:
secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
tokenValidityInMilliseconds: 1800000
ignore:
urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
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
之后还需要在nacos中配置好seata的配置 nacos 配置例子
CodeBlock Loading...
拉起服务
docker-compose -f docker-compose.yaml up
文件建构
CodeBlock Loading...
简单使用
引入id
CodeBlock Loading...
配置
CodeBlock Loading...
AT 模式
CodeBlock Loading...