日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

RuoYi-Cloud 进阶篇_03( Seata 高可用集群与 NacosConfig配置中心整合)

發(fā)布時(shí)間:2024/9/27 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 RuoYi-Cloud 进阶篇_03( Seata 高可用集群与 NacosConfig配置中心整合) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

            • 1. 創(chuàng)建文件config.txt
            • 2. 創(chuàng)建nacos-config.sh
            • 3. 配置導(dǎo)入nacos配置中心
            • 4. 配置驗(yàn)證

1. 創(chuàng)建文件config.txt

在seata的安裝文件夾下創(chuàng)建文件config.txt

[root@node2 ~]# cd /app/seata/seata-server-1.4.2/ [root@node2 seata-server-1.4.2]# vim config.txt

說明:
第一行:這里order-service值得是訂單模塊的服務(wù)
從第二行開始:下面是數(shù)據(jù)庫信息根據(jù)自己的實(shí)際情況配置
注意點(diǎn):不能添加中文注釋

添加以下內(nèi)容:

service.vgroupMapping.order-service=default store.mode=db store.db.datasource=druid store.db.dbType=mysql store.db.driverClassName=com.mysql.cj.jdbc.Driver store.db.url=jdbc:mysql://127.0.0.1:3306/ry-seata?useUnicode=true store.db.user=root store.db.password=123456 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

上面的文件是精簡后的部分,完整文件可在github中找到

https://github.com/seata/seata/blob/develop/script/config-center/config.txt

2. 創(chuàng)建nacos-config.sh

在conf/文件夾下下載文件
https://github.com/seata/seata/blob/develop/script/config-center/nacos/nacos-config.sh
用于將上面的seata配置信息導(dǎo)入到nacos 執(zhí)行下面的命令

[root@node2 seata-server-1.4.2]# cd conf [root@node2 conf]# vim nacos-config.sh 內(nèi)容比較多,建議直接下載吧 #!/bin/sh # Copyright 1999-2019 Seata.io Group. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at、 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.while getopts ":h:p:g:t:u:w:" opt docase $opt inh)host=$OPTARG;;p)port=$OPTARG;;g)group=$OPTARG;;t)tenant=$OPTARG;;u)username=$OPTARG;;w)password=$OPTARG;;?)echo " USAGE OPTION: $0 [-h host] [-p port] [-g group] [-t tenant] [-u username] [-w password] "exit 1;;esac doneif [ -z ${host} ]; thenhost=localhost fi if [ -z ${port} ]; thenport=8848 fi if [ -z ${group} ]; thengroup="SEATA_GROUP" fi if [ -z ${tenant} ]; thentenant="" fi if [ -z ${username} ]; thenusername="" fi if [ -z ${password} ]; thenpassword="" finacosAddr=$host:$port contentType="content-type:application/json;charset=UTF-8"echo "set nacosAddr=$nacosAddr" echo "set group=$group"urlencode() {length="${#1}"i=0while [ $length -gt $i ]; dochar="${1:$i:1}"case $char in[a-zA-Z0-9.~_-]) printf $char ;;*) printf '%%%02X' "'$char" ;;esaci=`expr $i + 1`done }failCount=0 tempLog=$(mktemp -u) function addConfig() {dataId=`urlencode $1`content=`urlencode $2`curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$dataId&group=$group&content=$content&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/nullif [ -z $(cat "${tempLog}") ]; thenecho " Please check the cluster status. "exit 1fiif [ "$(cat "${tempLog}")" == "true" ]; thenecho "Set $1=$2 successfully "elseecho "Set $1=$2 failure "failCount=`expr $failCount + 1`fi }count=0 for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); docount=`expr $count + 1`key=${line%%=*}value=${line#*=}addConfig "${key}" "${value}" doneecho "=========================================================================" echo " Complete initialization parameters, total-count:$count , failure-count:$failCount " echo "========================================================================="if [ ${failCount} -eq 0 ]; thenecho " Init nacos config finished, please start seata-server. " elseecho " init nacos config fail. " fi
3. 配置導(dǎo)入nacos配置中心

將seata配置信息導(dǎo)入到nacos config配置中心

sh nacos-config.sh -h 127.0.0.1
  • -h后面是nacos配置中心的地址
    操作記錄:
[root@node2 conf]# sh nacos-config.sh -h 127.0.0.1 set nacosAddr=127.0.0.1:8848 set group=SEATA_GROUP Set service.vgroupMapping.order-service=default successfully Set store.mode=db successfully Set store.db.datasource=druid successfully Set store.db.dbType=mysql successfully Set store.db.driverClassName=com.mysql.cj.jdbc.Driver successfully Set store.db.url=jdbc:mysql://127.0.0.1:3306/ry-seata?useUnicode=true successfully Set store.db.user=root successfully Set store.db.password=123456 successfully Set store.db.minConn=5 successfully Set store.db.maxConn=30 successfully Set store.db.globalTable=global_table successfully Set store.db.branchTable=branch_table successfully Set store.db.queryLimit=100 successfully Set store.db.lockTable=lock_table successfully Set store.db.maxWait=5000 successfully =========================================================================Complete initialization parameters, total-count:15 , failure-count:0 =========================================================================Init nacos config finished, please start seata-server. [root@node2 conf]#

4. 配置驗(yàn)證

執(zhí)行完成后登錄到nacos 查看配置中心的數(shù)據(jù)是否導(dǎo)入完畢,如圖所示

總結(jié)

以上是生活随笔為你收集整理的RuoYi-Cloud 进阶篇_03( Seata 高可用集群与 NacosConfig配置中心整合)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。