Я полагаю, вы не используете самодельные сценарии высокой доступности. Они ненадежны, вы можете забыть о них, они не спасают вас от ситуации разделения мозга .
В вашем случае вам следует использовать виртуальный IP, который перемещается между двумя узлами вашего кластера. Для этого существует множество программ:
$MSDeployExe = "C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe"
$RemoteHost = "http://localhost:80/MsDeployAgentService"
$Credentials = ""
$LocalDir = "C:\temp\LocalDir"
$RemoteDir = "C:\temp\RemoteDir"
function Send-Files {
param (
[string]$WebDeployService,
[string]$LocalDir,
[string]$RemoteDir,
[string]$Credentials
)
Write-Host "Sending files to $WebDeployService`: $RemoteDir" -ForegroundColor Yellow
if ($Credentials -ne "") {
$Credentials = ",getCredentials=" + $Credentials
}
& $MSDeployExe "-verb:sync" "-source:dirPath=$LocalDir" "-dest:dirPath=$RemoteDir,computername=$WebDeployService$Credentials" "-verbose"
$successful = $?
if (-not $successful) {
throw "Failed sending files"
}
}
function Execute-RemoteCommand {
param (
[string]$WebDeployService,
[string]$RemoteDir,
[string]$BatchFile,
[string]$Credentials,
[int]$waitInterval = 15000
)
$command = Join-Path $RemoteDir $BatchFile
Write-Host "Executing $command on $WebDeployService" -ForegroundColor Yellow
& $MSDeployExe "-verb:sync" "-source:runCommand=’$command’,waitInterval=$waitInterval,waitAttempts=1" "-dest:auto,computername=$RemoteHost$Credentials" "-verbose"
$successful = $?
if (-not $successful) {
throw "Failed executing command"
}
}
# Test
Send-Files $RemoteHost $LocalDir $RemoteDir $Credentials
Execute-RemoteCommand $RemoteHost $RemoteDir "HelloWorld.bat" $Credentials