Springcloud seata nacos環(huán)境搭建過程圖解
最近學(xué)習(xí)了一下seata,由于nacos現(xiàn)在也挺火,于是學(xué)習(xí)了seata注冊(cè)到nacos,然后集成springcloud
1.nacos配置(自行上官網(wǎng)下載)
將nacos/conf/nacos-mysql.sql導(dǎo)入自己的數(shù)據(jù)庫(kù)
2.配置修改nacos/conf/application.properties
spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=root db.password=123456
3.啟動(dòng)nacos
windows直接雙擊startup.cmd
linux不要直接sh startup.sh 加入?yún)?shù) -m standalone或者改startup.sh -m參數(shù),linux腳本默認(rèn)集群?jiǎn)?dòng),不改參數(shù)也不加啟動(dòng)參數(shù)會(huì)報(bào)錯(cuò)

啟動(dòng)成功
4.下載seata,建議直接下載源碼編譯
mvn -Prelease-all -DskipTests clean install -U
5.使用db模式導(dǎo)入配置

上面是源碼目錄,mysql.sql為seata庫(kù)必須的表,執(zhí)行sql即可

將上面的config.txt文件復(fù)制到seata目錄,nacos中的nacos-config.shnacos-config.py復(fù)制到seata的conf目錄

git 命令框執(zhí)行 sh nacos-config.sh hostip 即可,位置為什么這樣自己看下腳本就知道了

配置都進(jìn)來了,注意上面的紅框,如果你網(wǎng)上搜的腳本導(dǎo)入的,seata是1.0及之前的版本上面是對(duì)的,如果1.1及最新的源碼改成vgroupMapping了,報(bào)錯(cuò)參考另一篇博客
5.修改seata配置
修改file.conf
service {
#transaction service group mapping
vgroupMapping.my_tx_group="default" #此處根據(jù)自己的情況修改
default.grouplist="127.0.0.1:8091"
disableGlobalTransaction=false
}
## transaction log store, only used in seata-server
store {
## store mode: file、db
mode = "db"
## 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) etc.
datasource = "druid"
## mysql/oracle/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "com.mysql.jdbc.Driver" #不要用mysql8的驅(qū)動(dòng),否則報(bào)錯(cuò)
url = "jdbc:mysql://127.0.0.1:3306/seata"
user = "root"
password = "123456"
minConn = 1
maxConn = 10
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
}
}
registry.conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
serverAddr = "localhost:8848"
namespace = ""
cluster = "default"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
group = "SEATA_GROUP"
}
}
然后將上面兩個(gè)配置文件復(fù)制到你的springcloud模塊中
6.啟動(dòng)seata

如果之前在其他ip啟動(dòng)過,將file_store/data下的文件清掉,不然會(huì)報(bào)錯(cuò)
7.springcloud代碼
去https://gitee.com/code_fun/example.git 把demo.zip下載跑就可以了,前提是建好數(shù)據(jù)庫(kù)哦
demo.sql有表結(jié)構(gòu),undo_log表每個(gè)庫(kù)都要有
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Alibaba?SpringCloud集成Nacos、openFeign實(shí)現(xiàn)負(fù)載均衡的解決方案
- SpringCloud使用Nacos保存和讀取變量的配置方法
- SpringBoot項(xiàng)目改為SpringCloud項(xiàng)目使用nacos作為注冊(cè)中心的方法
- 關(guān)于springcloud集成nacos遇到的問題
- SpringCloud2020整合Nacos-Bootstrap配置不生效的解決
- SpringCloud整合Nacos實(shí)現(xiàn)流程詳解
- SpringCloud-Alibaba-Nacos啟動(dòng)失敗解決方案
- Springcloud-nacos實(shí)現(xiàn)配置和注冊(cè)中心的方法
- springcloud nacos的賦值均衡和動(dòng)態(tài)刷新
相關(guān)文章
Java中jqGrid 學(xué)習(xí)筆記整理——進(jìn)階篇(二)
這篇文章主要介紹了Java中jqGrid 學(xué)習(xí)筆記整理——進(jìn)階篇(二)的相關(guān)資料,需要的朋友可以參考下2016-04-04
教你用Java實(shí)現(xiàn)一個(gè)簡(jiǎn)單的代碼生成器
今天給大家?guī)淼氖顷P(guān)于Java的相關(guān)知識(shí),文章圍繞著如何用Java實(shí)現(xiàn)一個(gè)簡(jiǎn)單的代碼生成器展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下2021-06-06
Java獲取當(dāng)前系統(tǒng)事件System.currentTimeMillis()方法
下面小編就為大家?guī)硪黄狫ava獲取當(dāng)前系統(tǒng)事件System.currentTimeMillis()方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-06-06
SpringBoot?+DynamicDataSource切換多數(shù)據(jù)源的全過程
這篇文章主要介紹了SpringBoot?+DynamicDataSource切換多數(shù)據(jù)源的全過程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-01-01
java Comparator.comparing排序使用示例
本文主要介紹了java Comparator.comparing排序使用示例,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10
SpringMVC表單標(biāo)簽知識(shí)點(diǎn)詳解
這篇文章主要為大家詳細(xì)介紹了SpringMVC表單標(biāo)簽知識(shí)點(diǎn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10

