阿里分布式事务解决方案seata服务端

阿里分布式事务解决方案seata服务端

seata

Seata 是阿里巴巴开源的分布式事务中间件,一种分布式事务解决方案,具有高性能和易于使用的微服务架构。

1 安装

下载安装包:https://github.com/seata/seata/releases
根据系统运行环境下载不同的压缩文件:
Mac/Linux下载seata-server-xxx.tar.gz;
Windows下载seata-server-xxx.zip。
这里安装的是seata1.4.2版本,解压后目录如下:
在这里插入图片描述

2 配置

主要配置文件是:file.conf、registry.conf
registry.conf主要是进行指定配置中心以及指定加载本地配置或指定注册中心的配置。
file.conf主要是进行数据库连接的配置。若是指定加载注册中心的配置则这个文件不生效。

registry.conf 这里直接指定从nacos中加载配置。并以nacos为注册中心

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"

  nacos {
    application = "seata-server"
    serverAddr = "localhost:8848"
    group = "SEATA_GROUP"
    namespace = "2443362b-a435-4e72-8797-13032c161132"
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}

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

  nacos {
    serverAddr = "localhost:8848"
    namespace = "2443362b-a435-4e72-8797-13032c161132"
    group = "SEATA_GROUP"
    username = "nacos"
    password = "nacos"
    dataId = "seataServer.properties"
  }
}

file.conf 若是在registry.conf 中指定从file中加载配置则,文件修改如下。

## transaction log store, only used in seata-server
store {
  ## store mode: file、db、redis
  mode = "db"
  ## rsa decryption public key
  publicKey = ""
  ## file store property
  file {
    ## store location dir
    dir = "sessionStore"
    # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
    maxBranchSessionSize = 16384
    # globe session size , if exceeded throws exceptions
    maxGlobalSessionSize = 512
    # file buffer size , if exceeded allocate new buffer
    fileWriteBufferCacheSize = 16384
    # when recover batch read size
    sessionReloadReadSize = 100
    # async, sync
    flushDiskMode = async
  }

  ## database store property
  db {
    ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
    datasource = "druid"
    ## mysql/oracle/postgresql/h2/oceanbase etc.
    dbType = "mysql"
    driverClassName = "com.mysql.cj.jdbc.Driver"
    ## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
    url = "jdbc:mysql://localhost:3306/seata?rewriteBatchedStatements=true"
    user = "root"
    password = "root"
    minConn = 5
    maxConn = 100
    globalTable = "global_table"
    branchTable = "branch_table"
    lockTable = "lock_table"
    queryLimit = 100
    maxWait = 5000
  }
    ## sentinel mode property
    sentinel {
      masterName = ""
      ## such as "10.28.235.65:26379,10.28.235.65:26380,10.28.235.65:26381"
      sentinelHosts = ""
    }
    password = ""
    database = "0"
    minConn = 1
    maxConn = 10
    maxTotal = 100
    queryLimit = 100
  }
}

3 从nacos中加载配置准备工作

红框的文件1.4.0之后的版本中默认没有提供,需要自己初始化,config.txt、nacos-config.sh下载地址:nacos-config.shhttps://github.com/seata/seata/tree/1.4.2/script/config-center,若是想要从nacos中加载配置文件,则需要将配置信息上传至nacos中

sh ${SEATAPATH} /script/config-center/nacos/nacos-config.sh -h localhost -p 8848 -g 
SEATA_GROUP -t 5a3c7d6c-f497-4d68-a71a-2e5e3340b3ca -u 用户名 -w 密码
-h:主机,默认值为localhost。
-p:端口,默认值为8848。
-g:配置分组,默认值为'SEATA_GROUP'。
-t:对应Nacos的namespace ID字段,默认值为''。
-u:用户名。
-w:密码。

在这里插入图片描述
上传成功如下。然后nacos上会出现相应的配置信息
在这里插入图片描述
在这里插入图片描述
然后可以启动seata服务端

4 启动seata

启动脚本:
nohup sh ./seata-server.sh -p 8091 -h 127.0.0.1 -m db &

在这里插入图片描述
可以看到seata服务端启动成功
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值