当前位置: 代码迷 >> 综合 >> Windows10下 nacos集群脚本
  详细解决方案

Windows10下 nacos集群脚本

热度:53   发布时间:2023-11-21 05:58:08
  1. 执行 nacos-mysql.sql

  2. 进入conf 下配置环境
    在这里插入图片描述

  3. application.properties (替换数据库用户和密码)
    在这里插入图片描述

  4. cluster.conf

172.20.10.3:8847
172.20.10.3:8848
172.20.10.3:8849
  1. nacos\bin 下创建 cluster.cmd
@echo off
set PORT=%1
set PATH=%~dp0
set cluster=..\cluster
set d=nacos-%PORT%if not exist %cluster% (
mkdir %cluster%
)
cd %cluster%
if not exist %d% (
mkdir %d%
)
cd %d%if not exist bin (
mkdir bin
)if not exist conf (
mkdir conf
)if not exist target (
mkdir target
)copy ..\..\bin\startup.cmd bin\
copy ..\..\bin\shutdown.cmd bin\ 
copy ..\..\conf\*.* conf\ 
copy ..\..\target\*.jar target\ cd conf\
echo.>>application.properties
echo server.port=%PORT% >>application.properties
cd ..
cd bin
startup.cmd
  1. 传入对应的端口即可启动
    在这里插入图片描述
    会在nacos 目录下创建 cluster文件夹
    在这里插入图片描述
    会自动在cluster下创建一个以nacos-端口命名的文件夹,里面则是一个新的nacos,进入新的nacos\bin执行startup.cmd

在这里插入图片描述
7. 修改nginx配置在这里插入图片描述
8. nginx.bat 脚本

@echo off
rem 提供Windows下nginx的启动,重启,关闭功能echo ==================begin========================cls 
::ngxin 所在的盘符
set NGINX_PATH=D:::nginx 所在目录
set NGINX_DIR=%~dp0TITLE Nginx 管理程序增强版CLS echo. 
echo. ** Nginx 管理程序  *** 
echo. *** create 2017-09-22 *** 
echo. :MENU echo. ***** nginx 进程list ****** 
::tasklist|findstr /i "nginx.exe"
tasklist /fi "imagename eq nginx.exe"echo. if ERRORLEVEL 1 (echo nginx.exe不存在) else (echo nginx.exe存在)echo. 
::*************************************************************************************************************
echo. echo.  [1] 启动Nginx  echo.  [2] 关闭Nginx  echo.  [3] 重启Nginx echo.  [4] 刷新控制台  echo.  [5] 重新加载Nginx配置文件echo.  [6] 检查测试nginx配置文件echo.  [7] 查看nginx versionecho.  [0] 退 出 
echo. echo.请输入选择的序号:
set /p ID=IF "%id%"=="1" GOTO start IF "%id%"=="2" GOTO stop IF "%id%"=="3" GOTO restart IF "%id%"=="4" GOTO MENUIF "%id%"=="5" GOTO reloadConf IF "%id%"=="6" GOTO checkConf IF "%id%"=="7" GOTO showVersion IF "%id%"=="0" EXIT
PAUSE ::*************************************************************************************************************
::启动
:start call :startNginxGOTO MENU::停止
:stop call :shutdownNginxGOTO MENU::重启
:restart call :shutdownNginxcall :startNginxGOTO MENU::检查测试配置文件
:checkConf call :checkConfNginxGOTO MENU::重新加载Nginx配置文件
:reloadConf call :checkConfNginxcall :reloadConfNginxGOTO MENU::显示nginx版本
:showVersion call :showVersionNginxGOTO MENU	::*************************************************************************************
::底层
::*************************************************************************************
:shutdownNginxecho. echo.关闭Nginx...... taskkill /F /IM nginx.exe > nulecho.OK,关闭所有nginx 进程goto :eof:startNginxecho. echo.启动Nginx...... IF NOT EXIST "%NGINX_DIR%nginx.exe" (echo "%NGINX_DIR%nginx.exe"不存在goto :eof)%NGINX_PATH% cd "%NGINX_DIR%" IF EXIST "%NGINX_DIR%nginx.exe" (echo "start '' nginx.exe"start "" nginx.exe)echo.OKgoto :eof:checkConfNginxecho. echo.检查测试 nginx 配置文件...... IF NOT EXIST "%NGINX_DIR%nginx.exe" (echo "%NGINX_DIR%nginx.exe"不存在goto :eof)%NGINX_PATH% cd "%NGINX_DIR%" nginx -t -c conf/nginx.confgoto :eof::重新加载 nginx 配置文件
:reloadConfNginxecho. echo.重新加载 nginx 配置文件...... IF NOT EXIST "%NGINX_DIR%nginx.exe" (echo "%NGINX_DIR%nginx.exe"不存在goto :eof)%NGINX_PATH% cd "%NGINX_DIR%" nginx -s reloadgoto :eof::显示nginx版本
:showVersionNginxecho. %NGINX_PATH% cd "%NGINX_DIR%" nginx -Vgoto :eof

注意修改

::ngxin 所在的盘符
set NGINX_PATH=D:::nginx 所在目录
set NGINX_DIR=%~dp0

在这里插入图片描述
选择 1

在这里插入图片描述
访问:http://localhost:8850/nacos
在这里插入图片描述
在这里插入图片描述
集群完成

chsengni@163.com