seata部署与集成
一、下载seata server
https://github.com/apache/incubator-seata/releases 下载你需要的版本
二、到seata-server\script\server\db 目录下,获取对应数据库的sql这里我用mysql
新建seata库,执行sql
三、到seata-server\conf 目录下,修改application.yml,集成nacos
server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${log.home:${user.home}/logs/seata}extend:logstash-appender:# off by defaultenabled: falsedestination: 127.0.0.1:4560kafka-appender:# off by defaultenabled: falsebootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashproducer:acks: 0linger-ms: 1000max-block-ms: 0metric-appender:# off by defaultenabled: falseseata:config:# support: nacos, consul, apollo, zk, etcd3type: nacosnacos:server-addr: 192.168.*****:8848namespace: seatagroup: SEATA_GROUPcontext-path:username: nacospassword: *****data-id: seata-server.ymlregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacospreferred-networks: 30.240.*nacos:application: seata-serverserver-addr: 192.168.*****:8848group: SEATA_GROUPnamespace: seatacluster: seatacontext-path:##1.The following configuration is for the open source version of Nacosusername: nacospassword: *****
四、到nacos相应的namespace下建立对应配置文件seata-server.yml
store:mode: dbdb:datasource: druiddbType: mysqldriverClassName: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://192.168.*******:3306/seata?allowPublicKeyRetrieval=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghaiuser: *******password: *******minConn: 10maxConn: 100globalTable: global_tablebranchTable: branch_tablelockTable: lock_tabledistributedLockTable: distributed_lockqueryLimit: 1000maxWait: 5000metrics:enabled: falseregistry-type: compactexporter-list: prometheusexporter-prometheus-port: 9898
transport:rpc-tc-request-timeout: 15000enable-tc-server-batch-send-response: falseshutdown:wait: 3thread-factory:boss-thread-prefix: NettyBossworker-thread-prefix: NettyServerNIOWorkerboss-thread-size: 1
security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/metadata/v1/**service:vgroupMapping:default_tx_group: seata
五、Springboot服务yml文件引入配置
config:import:- nacos:seata-client:config.yml?group=${spring.profiles.active}
在nacos建立对应文件seata-client:config.yml
seata:enabled: trueapplication-id: ${spring.application.name}# 需与nacos配置的vgroupMapping一致tx-service-group: default_tx_groupregistry:type: nacosnacos:server-addr: 192.168.******:8848application: seata-serverusername: nacospassword: ******group: SEATA_GROUPnamespace: seataconfig:type: nacosnacos:server-addr: 192.168.******:8848username: nacospassword: ******group: SEATA_GROUPdata-id: seata-server.ymlnamespace: seata