主要是一些组件的配置(linux下,Windows同理)

首先根据文档创建数据库并导入sql文件夹中的几个sql。

nacos配置

单体部署的话需要修改 startuo.sh文件。

windows修改.cmd文件。将 export MODE=“cluster” 修改为 export MODE=“standalone”(windows .cmd文件是 set MODE=“cluster”)。
cluster 表示以集群的方式运行
standalone 表示以单机的方式运行

详见:https://www.cnblogs.com/wang0327/p/15187469.html

修改conf文件夹下的application.properties

这里注意: spring.datasource.platform=mysql 别忘记去掉注释
ry-config库是项目中自带的sql文件夹中sql文件生成的,其中自带各个模块的数据库配置,nacos启动后会自动同步到nacos中

#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=yunmei@2020

这里数据库链接成功启动后的nacos
在这里插入图片描述

如果启动后naocs没有配置文件,就需要确认一下是否nacos配置数据库没有连接成功 或者看一下导入的ry_config库中config-info表中配置是否存在。

在这里插入图片描述

seata安装

百度网盘链接:https://pan.baidu.com/s/1L2n_CBd5dHfYPwCPjgj8TQ
提取码:usks

去官网下载 config.txt 文件 放入conf文件夹中 由于使用的nacos 所以file.conf 不进行配置

或者直接复制创建一个 ry-seata为若依sql文件夹中自带sql生成的

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&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
store.db.user=root
store.db.password=root
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

下载或复制 nacos-config.sh 文件 放入conf文件夹中。

#!/usr/bin/env bash
# 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
do
  case $opt in
  h)
    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
done

urlencode() {
  for ((i=0; i < ${#1}; i++))
  do
    char="${1:$i:1}"
    case $char in
    [a-zA-Z0-9.~_-]) printf $char ;;
    *) printf '%%%02X' "'$char" ;;
    esac
  done
}

if [[ -z ${host} ]]; then
    host=localhost
fi
if [[ -z ${port} ]]; then
    port=8848
fi
if [[ -z ${group} ]]; then
    group="SEATA_GROUP"
fi
if [[ -z ${tenant} ]]; then
    tenant=""
fi
if [[ -z ${username} ]]; then
    username=""
fi
if [[ -z ${password} ]]; then
    password=""
fi

nacosAddr=$host:$port
contentType="content-type:application/json;charset=UTF-8"

echo "set nacosAddr=$nacosAddr"
echo "set group=$group"

failCount=0
tempLog=$(mktemp -u)
function addConfig() {
  curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$(urlencode $1)&group=$group&content=$(urlencode $2)&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null
  if [[ -z $(cat "${tempLog}") ]]; then
    echo " Please check the cluster status. "
    exit 1
  fi
  if [[ $(cat "${tempLog}") =~ "true" ]]; then
    echo "Set $1=$2 successfully "
  else
    echo "Set $1=$2 failure "
    (( failCount++ ))
  fi
}

count=0
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
  (( count++ ))
	key=${line%%=*}
    value=${line#*=}
	addConfig "${key}" "${value}"
done

echo "========================================================================="
echo " Complete initialization parameters,  total-count:$count ,  failure-count:$failCount "
echo "========================================================================="

if [[ ${failCount} -eq 0 ]]; then
	echo " Init nacos config finished, please start seata-server. "
else
	echo " init nacos config fail. "
fi

运行 nacos-config.sh 》》》》》》》》》》》》》》》》

切换/bin目录 命令 nohup sh seata-server.sh > seata.log 2>%1 & 后台启动 seata
此时在查看nacos 配置列表发现多了组为SEATA_GROUP 的配置

项目启动

首先修改你需要启动模块的nacos 配置信息(数据库 redis nacos seata 等)
必须修改启动的有
nacos以及项目中的 auth、gateway 后台模块 systemy 中的配置地址

然后启动前端(我这里用的软件 vsCode)

Logo

快速构建 Web 应用程序

更多推荐