使用cluster.exe为MS SQL Failover AOAG创建批处理脚本



我想使用cluster.exe 创建一个批处理脚本

我的初始批处理脚本(FAILOVER_TO_DRDB01.BAT(是:

ECHO ON
cluster.exe node DRDB01 /status  -o  C:FAILOVER_TO_DRDB01_LOG.txt

当我尝试运行它时,没有创建任何输出。

我的主要目标是它将输出以下内容:

Listing status for node 'DRDB01':
Node           Node ID Status
-------------- ------- ---------------------
DRDB01               3 Joining

一旦它看到Status是正在加入,它将运行以下脚本:

net.exe stop clussvc  
net.exe start clussvc /forcequorum  

一旦故障转移,它将运行以下脚本:

cluster.exe node DRDB01 /prop nodeweight=1 /prop:NodeWeight /status
cluster.exe node PDCDB01 /prop nodeweight=0 /prop:NodeWeight /status
cluster.exe node PDCDB02 /prop nodeweight=0 /prop:NodeWeight /status

我假设您想在的末尾找到节点

@(setlocal enableextensions enabledelayedexpansion
echo off 
set "DRNode=DRDB01"
)
CALL :Main
( ENDLOCAL
CALL :End
EXIT /B 0
)
:Main
REM Loop Until the status of the cluster node indefinitly:
CALL :Do_Until_Status "%DRNode%" "Joining"
CALL :Restart_Cluster_Svc
CALL :Do_Until_Status "%DRNode%" "Up"
CALL :On_Status_Up
GOTO :EOF

:Do_Until_Status
cluster.exe node %~1 /status
cluster.exe node %~1 /status | FIND /I "%~1" | FIND /I "%~2" && ( GOTO :EOF)
GOTO :Do_Until_Status
:Restart_Cluster_Svc
REM stop the cluster service and start it using force quorum
net.exe stop clussvc  
net.exe start clussvc /forcequorum  
GOTO :EOF
:On_Status_Up
cluster.exe node DRDB01 /prop nodeweight=1 /prop:NodeWeight /status
cluster.exe node PDCDB01 /prop nodeweight=0 /prop:NodeWeight /status
cluster.exe node PDCDB02 /prop nodeweight=0 /prop:NodeWeight /status
GOTO :EOF

相关内容

  • 没有找到相关文章

最新更新