天天看點

Seata 單機環境搭建_01

文章目錄

  • ​​一、整合版本說明​​
  • ​​1. 畢業版本依賴關系(推薦使用)​​
  • ​​2. 元件版本關系​​
  • ​​3. 示範版本​​
  • ​​二、部署單機 TC Server​​
  • ​​2.1. 下載下傳Seata​​
  • ​​2.2. 解壓縮​​
  • ​​2.3. 啟動​​
  • ​​2.4. 監聽日志​​
  • ​​2.5. 啟動指令講解​​
一、整合版本說明

1. 畢業版本依賴關系(推薦使用)

Spring Cloud Version Spring Cloud Alibaba Version Spring Boot Version
Spring Cloud 2020.0.0 2021.1 2.4.2
Spring Cloud Hoxton.SR9 2.2.6.RELEASE 2.3.2.RELEASE
Spring Cloud Greenwich.SR6 2.1.4.RELEASE 2.1.13.RELEASE
Spring Cloud Hoxton.SR3 2.2.1.RELEASE 2.2.5.RELEASE
Spring Cloud Hoxton.RELEASE 2.2.0.RELEASE 2.2.X.RELEASE
Spring Cloud Greenwich 2.1.2.RELEASE 2.1.X.RELEASE

2. 元件版本關系

Spring Cloud Alibaba Version Sentinel Version Nacos Version RocketMQ Version Dubbo Version Seata Version
2.2.6.RELEASE 1.8.1 1.4.2 4.4.0 2.7.8 1.3.0
2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE 1.8.0 1.4.1 4.4.0 2.7.8 1.3.0
2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE 1.8.0 1.3.3 4.4.0 2.7.8 1.3.0
2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE 1.7.1 1.2.1 4.4.0 2.7.6 1.2.0
2.2.0.RELEASE 1.7.1 1.1.4 4.4.0 2.7.4.1 1.0.0

3. 示範版本

Spring Cloud Version Spring Cloud Alibaba Version Spring Boot Version Nacos Version jdk
Spring Cloud Hoxton.SR9 2.2.6.RELEASE 2.3.2.RELEASE 1.4.2 1.8.202

按我們使用的SpringCloudAlibaba的版本是2.2.6, 此次我們應該使用1.3.0版本的Seata進行安裝。

版本說明:

​​​https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E​​

二、部署單機 TC Server

2.1. 下載下傳Seata

在​​https://github.com/seata/seata/releases​​ 這裡找到對應的版本軟體包進行下載下傳

下載下傳位址:​​https://github.com/seata/seata/releases/download/v1.3.0/seata-server-1.3.0.zip​​

Seata 單機環境搭建_01

注:單機模式隻适用于學習或者本地測試階段,生産環境推薦使用叢集模式。

2.2. 解壓縮

Seata 單機環境搭建_01
cd /app
unzip      

2.3. 啟動

[root@node2 app]# cd seata/bin/
[root@node2 bin]# nohup ./seata-server.sh &      

2.4. 監聽日志

[root@node2 bin]# 
[root@node2 bin]# tail -f nohup.out      
Seata 單機環境搭建_01

可以看到日志中已經預設啟動了 8091端口

因為 TC 需要進行全局事務和分支事務的記錄,是以需要對應的存儲。目前,TC 有兩種存儲模式( store.mode ):

file 模式:适合單機模式,全局事務會話資訊在記憶體中讀寫,并持久化本地檔案 root.data,性能較高。

db 模式:适合叢集模式,全局事務會話資訊通過 db 共享,相對性能差點。

顯然,我們将采用 file 模式,最終我們部署單機 TC Server 如下圖所示:

Seata 單機環境搭建_01

因為我們使用 file 模式,是以可以看到用于持久化的本地檔案 root.data。操作指令如下:

ls      
Seata 單機環境搭建_01

可以看到,已經預設生成了root.data檔案

2.5. 啟動指令講解

sh seata-server.sh -p $LISTEN_PORT -m $MODE(file or db) -h $HOST -e $ENV

-p seata-server 監聽服務端口号

-m 存儲模式,可選值:file、db。file 用于單點模式,db用于ha模式,當使用db存儲模式,需要修改配置中store配置節點的資料庫配置,同時在資料庫中初始化的sql

-h 用于解決seata-server和業務側跨網絡問題,其配置的host值直接顯示到注冊中心的服務可用位址host,當跨網絡時這裡需要配置為公網IP或NATIP,若都在同一區域網路則無需配置