initial commit
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
|
||||
# 🧩 Zerto WSFC VPG Ownership Automation
|
||||
|
||||
## Overview
|
||||
This PowerShell script automates synchronization between **Windows Server Failover Cluster (WSFC)** node ownership and **Zerto Virtual Protection Groups (VPGs)**.
|
||||
|
||||
When WSFC ownership changes, the script automatically:
|
||||
- **Resumes** replication for the active node’s VPG
|
||||
- **Pauses** replication for the standby node’s VPG
|
||||
- Ensures only the current WSFC owner continues replication to maintain CBT consistency
|
||||
|
||||
It supports two detection modes: **Disk-based** and **Group-based** ownership detection.
|
||||
|
||||
---
|
||||
|
||||
## 🖼️ Architecture Overview
|
||||
|
||||
### Owner: Node 1
|
||||

|
||||
|
||||
- **WSFC Node1** owns the shared disk or owns the cluster group.
|
||||
- **VPG Node1** is **Active** (replicating).
|
||||
- **VPG Node2** is **Paused**.
|
||||
- ZVM Prod and ZVM DR maintain CBT replication across sites.
|
||||
|
||||
### Owner: Node 2
|
||||

|
||||
|
||||
- Ownership of the **WSFC shared disk** transfers to **Node2**.
|
||||
- The script detects the ownership change.
|
||||
- **VPG Node2** is resumed; **VPG Node1** is paused.
|
||||
- Zerto continues replication with no data collision.
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Features
|
||||
- ✅ Disk-based and Group-based WSFC ownership detection
|
||||
- ✅ Automatic VPG resume/pause alignment
|
||||
- ✅ Detailed timestamped logging (`C:\Temp\PwshCompat`)
|
||||
- ✅ Compatible with PowerShell 5.1+ and PowerShell 7
|
||||
- ✅ Safe retry and graceful error handling
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
All configuration is centralized at the top of the script:
|
||||
|
||||
```powershell
|
||||
# --- HARD-CODED CONFIG ---
|
||||
$ZvmHost = '192.168.222.20'
|
||||
$ZvmUser = 'admin'
|
||||
$ZvmPassPlain = 'password'
|
||||
|
||||
$NodeUser = '.\wsfcadm'
|
||||
$NodePassPlain = 'password'
|
||||
|
||||
$ClusterFqdn = 'TOR-HV01.lab.local'
|
||||
$WSFCGroupName = 'Cluster Group'
|
||||
$Node1 = 'TOR-HV01-N1'
|
||||
$Node2 = 'TOR-HV01-N2'
|
||||
|
||||
# OWNERSHIP DETECTION MODE
|
||||
# 'Disk' => determine active owner by shared disk ownership (preferred)
|
||||
# 'Group' => determine active owner by Cluster Group ownership (legacy behavior)
|
||||
$OwnershipSource = 'Disk'
|
||||
|
||||
# DISK MONITORING CONFIGURATION (used when OwnershipSource = 'Disk')
|
||||
$SharedDiskUniqueId = '6589CFC000000307DC30980C15CE8818'
|
||||
$SharedDiskLabel = 'WSFCData1'
|
||||
$DiskResourceName = 'Cluster Disk 1'
|
||||
|
||||
# Zerto VPG names
|
||||
$VpgName1 = 'Node1'
|
||||
$VpgName2 = 'node2'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Detection Modes
|
||||
|
||||
### Disk Mode (Preferred)
|
||||
In this mode, the script determines the active WSFC node by checking:
|
||||
1. The **Physical Disk Resource Owner** in the cluster (`Get-CimInstance root\MSCluster`).
|
||||
2. If unavailable, it checks which node has the disk **Online and Read/Write**.
|
||||
|
||||
This is the most reliable method for shared-disk clusters.
|
||||
|
||||
### Group Mode (Legacy)
|
||||
In this mode, the script determines ownership by checking the **Cluster Group owner** instead of a shared disk.
|
||||
Useful when the cluster has no shared disks (e.g., cluster-only workloads).
|
||||
|
||||
```powershell
|
||||
$OwnershipSource = 'Group'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🪵 Logging
|
||||
|
||||
Logs are created under:
|
||||
```
|
||||
C:\Temp\PwshCompat\cluster-monitor-YYYYMMDD-HHMMSS.log
|
||||
```
|
||||
|
||||
Each log line includes timestamp, component, and log level (`DEBUG`, `INFO`, `WARN`, `ERROR`).
|
||||
|
||||
---
|
||||
|
||||
## 🧠 How It Works
|
||||
1. Loads **FailoverClusters** and **Zerto.ZvmLinux.Commandlets** modules.
|
||||
2. Connects to the ZVM using the provided credentials.
|
||||
3. Retrieves both VPGs and their current states.
|
||||
4. Determines the active WSFC owner (via disk or group).
|
||||
5. Resumes or pauses VPGs to match ownership.
|
||||
6. Logs all actions with timestamps.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Execution
|
||||
|
||||
Run from a system with network access to both WSFC nodes and ZVM:
|
||||
|
||||
```powershell
|
||||
.\WSFC-Zerto-Monitor.ps1
|
||||
```
|
||||
|
||||
Administrator privileges are recommended.
|
||||
|
||||
The script should run on a scheduled basis (i.e. every minute)
|
||||
|
||||
---
|
||||
|
||||
## 🧾 Legal Disclaimer
|
||||
|
||||
This script is provided as an **example only** and is **not supported** under any Zerto support program or service.
|
||||
|
||||
> The author and Zerto disclaim all implied warranties, including merchantability and fitness for a particular purpose.
|
||||
> In no event shall Zerto or the author be liable for damages arising from the use or inability to use this script.
|
||||
> Use at your own risk.
|
||||
|
||||
---
|
||||
|
||||
**Author:** Kosta Mushkin
|
||||
**Company:** Zerto (HPE)
|
||||
**Version:** 1.0
|
||||
**Date:** October 2025
|
||||
Reference in New Issue
Block a user