您好,登錄后才能下訂單哦!
這篇文章主要介紹了Springcloud seata nacos環(huán)境怎么搭建,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
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)來(lái)了,注意上面的紅框,如果你網(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/h3/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)過(guò),將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ù)都要有
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Springcloud seata nacos環(huán)境怎么搭建”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。