seata-server安装(nacos)

seata-server安装(nacos)

1.下载seata-server

https://github.com/seata/seata/releases

2.创建seata-server数据库及表

https://github.com/seata/seata/tree/1.4.0/script/server/db

3.修改seata-server的registry.conf文件

#修改为如下配置
registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"

  nacos {
    application = "seata-server"
    serverAddr = "ip:port"
    group = "SEATA_SERVICE_GROUP" #这里为服务的group
    namespace = "24c004c0-a5a8-405e-89c1-50a147492ab2"
    cluster = "order_tx_group"
    username = ""
    password = ""
  }
}

config {
  # file、nacos 、apollo、zk、consul、etcd3
  type = "nacos"

  nacos {
    serverAddr = "ip:order"
    namespace = "24c004c0-a5a8-405e-89c1-50a147492ab2"
    group = "SEATA_GROUP" #这里为配置的group
    username = ""
    password = ""
    #dataId = "seataServer.properties"
  }
}

4.导入通用seata到nacos的通用配置

#下载config.txt文件和nacos-config.sh文件
https://github.com/seata/seata/tree/1.4.0/script/config-center

#修改存储模式为db,删除其余存储部分配置
store.mode=db
#等号左侧rder_tx_group:事务逻辑分组名称
#等号右侧rder_tx_group:对应seat-server的registry.conf的cluster属性
service.vgroupMapping.order_tx_group=order_tx_group

#导入配置到nacos
./nacos-config.sh -h localhost -p 4418 -g SEATA_GROUP -t 24c004c0-a5a8-405e-89c1-50a147492ab2

5.下载client脚本

https://github.com/seata/seata/tree/1.4.0/script/client/at/db

6.调整maven依赖(解决版本兼容问题)

<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-alibaba-dependencies</artifactId>
  <version>2.2.3.RELEASE</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>

<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-openfeign</artifactId>
  <version>2.2.10.RELEASE</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-openfeign-core</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-openfeign-core</artifactId>
  <version>2.2.10.RELEASE</version>
</dependency>
<!--<dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>-->

<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>

7.获取客户端yaml文件配置

https://github.com/seata/seata/tree/1.4.0/script/client/spring

#保留如下部分(其余删掉)
seata:
  enabled: true
  application-id: seata-server
  tx-service-group: order_tx_group
  enable-auto-data-source-proxy: true
  data-source-proxy-mode: AT
  use-jdk-proxy: false
  excludes-for-auto-proxying: firstClassNameForExclude,secondClassNameForExclude
  config:
    type: nacos
    nacos:
      namespace: 24c004c0-a5a8-405e-89c1-50a147492ab2
      serverAddr: ip:port
      group: SEATA_GROUP
      username: ""
      password: ""
  registry:
    type: nacos
    load-balance: RandomLoadBalance
    load-balance-virtual-nodes: 10
    nacos:
      application: seata-server
      server-addr: ip:port
      group : "SEATA_SERVICE_GROUP"
      namespace: 24c004c0-a5a8-405e-89c1-50a147492ab2
      username: ""
      password: ""

8.增加ribbon相关配置

#openFeign默认不开启重试,使用的是ribbon的重试机制
ribbon:
  ReadTimeout: 2000
  ConnectTimeout: 2000
  OkToRetryOnAllOperations: false #只重试get请求
  MaxAutoRetriesNextServer: 1 #最多重试多少台服务器,但是首次调用不包括在内
  MaxAutoRetries: 1 #每台服务器最多重试次数,但是首次调用不包括在内
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值