Seata安装下载和启动

.下载

下载地址:Releases · seata/seata · GitHub:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution. - Releases · seata/seatahttps://github.com/seata/seata/releases

 

2.3.2.安装

  • 上传并解压安装包:

[root@localhost ~]# cd /usr/upload
[root@localhost upload]# tar -zxvf seata-server-1.4.2.tar.gz -C /usr/local    

2.3.3.修改配置文件

  • 修改seata/seata-server-1.4.2/conf/目录下的registry.conf文件:

registry {
  #tc服务的注册中心类型,这里选择nacos,也可以是eureka、zookeeper等
  type = "nacos"

  nacos {
    # seata tc服务注册到nacos的服务名称,可以自定义
    application = "seata-server"
    # nacos的地址
    serverAddr = "192.168.204.129:8848" //修改
    # seata服务所在分组
    group = "DEFAULT_GROUP"
    # seata服务所在的名称空间,这里不填就是使用默认的"public"
    namespace = ""
    # TC集群名,默认是"default"
    cluster = "default"
    # 这个是nacos的用户名
    username = ""
    # 这个是nacos的密码
    password = ""
  }
}
config {
  # tc服务的配置中心类型:file、nacos 、apollo、zk、consul、etcd3
  type = "nacos"

  nacos {
    serverAddr = "192.168.204.129:8848" //和上面的保持一致
    namespace = ""
    group = "DEFAULT_GROUP"
    username = ""
    password = ""
    dataId = "seataServer.properties"
  }
}  

 

2.3.4.在Nacos中添加配置信息

# 数据存储方式,db代表数据库
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://192.168.31.18:3306/seata?useUnicode=true&rewriteBatchedStatements=true  //修改成自己
store.db.user=root   //修改
store.db.password=1111 //修改
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
# 事务、日志等配置
server.recovery.committingRetryPeriod=1000
server.recovery.asynCommittingRetryPeriod=1000
server.recovery.rollbackingRetryPeriod=1000
server.recovery.timeoutRetryPeriod=1000
server.maxCommitRetryTimeout=-1
server.maxRollbackRetryTimeout=-1
server.rollbackRetryTimeoutUnlockEnable=false
server.undo.logSaveDays=7
server.undo.logDeletePeriod=86400000

# 客户端与服务端传输方式
transport.serialization=seata
transport.compressor=none
# 关闭metrics功能,提高性能
metrics.enabled=false
metrics.registryType=compact
metrics.exporterList=prometheus
metrics.exporterPrometheusPort=9898

 

  • 效果如下:

2.3.5.创建TC服务数据表

建库

建表语句  

建表语句地址:script/server/db/mysql.sql · Seata/seata - Gitee.com

-- -------------- The script used when storeMode is 'db' --------------------------------
-- the table to store GlobalSession data
CREATE TABLE IF NOT EXISTS `global_table`
(
    `xid`                       VARCHAR(128) NOT NULL,
    `transaction_id`            BIGINT,
    `status`                    TINYINT      NOT NULL,
    `application_id`            VARCHAR(32),
    `transaction_service_group` VARCHAR(32),
    `transaction_name`          VARCHAR(128),
    `timeout`                   INT,
    `begin_time`                BIGINT,
    `application_data`          VARCHAR(2000),
    `gmt_create`                DATETIME,
    `gmt_modified`              DATETIME,
    PRIMARY KEY (`xid`),
    KEY `idx_gmt_modified_status` (`gmt_modified`, `status`),
    KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(
    `branch_id`         BIGINT       NOT NULL,
    `xid`               VARCHAR(128) NOT NULL,
    `transaction_id`    BIGINT,
    `resource_group_id` VARCHAR(32),
    `resource_id`       VARCHAR(256),
    `branch_type`       VARCHAR(8),
    `status`            TINYINT,
    `client_id`         VARCHAR(64),
    `application_data`  VARCHAR(2000),
    `gmt_create`        DATETIME(6),
    `gmt_modified`      DATETIME(6),
    PRIMARY KEY (`branch_id`),
    KEY `idx_xid` (`xid`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(
    `row_key`        VARCHAR(128) NOT NULL,
    `xid`            VARCHAR(96),
    `transaction_id` BIGINT,
    `branch_id`      BIGINT       NOT NULL,
    `resource_id`    VARCHAR(256),
    `table_name`     VARCHAR(32),
    `pk`             VARCHAR(36),
    `gmt_create`     DATETIME,
    `gmt_modified`   DATETIME,
    PRIMARY KEY (`row_key`),
    KEY `idx_branch_id` (`branch_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

2.3.6.启动Seata

[root@localhost local]# cd seata/bin 
[root@localhost bin]# ./seata-server.sh          启动
#或
[root@localhost bin]# ./seata-server.sh -h 192.168.204.135 -p 8091
... ...
io.seata.config.FileConfiguration        : The configuration file used is /usr/local/seata/seata-server-1.4.2/conf/registry.conf
 com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
i.s.core.rpc.netty.NettyServerBootstrap  : Server started, listen port: 8091   

成功 显示 8091

测试seata是否注册成功

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值