[root@node2 seata-server-1.4.2]# cd conf[root@node2 conf]# vim nacos-config.sh
內容比較多,建議直接下載吧
#!/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.whilegetopts":h:p:g:t:u:w:" opt
docase$optinh)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] "exit1;;esacdoneif[ -z ${host}];thenhost=localhost
fiif[ -z ${port}];thenport=8848fiif[ -z ${group}];thengroup="SEATA_GROUP"fiif[ -z ${tenant}];thentenant=""fiif[ -z ${username}];thenusername=""fiif[ -z ${password}];thenpassword=""finacosAddr=$host:$portcontentType="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$charin[a-zA-Z0-9.~_-])printf$char;;*)printf'%%%02X'"'$char";;esaci=`expr $i + 1`done}failCount=0tempLog=$(mktemp -u)functionaddConfig(){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. "exit1fiif["$(cat"${tempLog}")"=="true"];thenecho"Set $1=$2 successfully "elseecho"Set $1=$2 failure "failCount=`expr $failCount + 1`fi}count=0forlinein$(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. 配置導入nacos配置中心
將seata配置信息導入到nacos config配置中心
sh nacos-config.sh -h 127.0.0.1
-h后面是nacos配置中心的地址 操作記錄:
[root@node2 conf]# sh nacos-config.sh -h 127.0.0.1setnacosAddr=127.0.0.1:8848
setgroup=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]#