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 #每台服务器最多重试次数,但是首次调用不包括在内

你可能感兴趣的:(分布式事务,数据库开发,数据库架构)