Creating a scheduled batch job to force replication
hello,
i checked on synchronization health today , in critical state replication. hadn't synced since last server reboot. clicked on synchronize force , did - no problem. didn't have go services , restart - clicked on replicate in hyper-v manager. don't want have check on replication , manually replicate after every reboot. there batch file can run force replication did manually?
the error got after reboot until manually forced replication - hyper-v failed enable replication virtual machine operation aborted (0x80004004). didn't need delete replication or make replication work - had resume it. not using certificates replicate isn't bad cert.
i think found answer here. notice issue occurs on sundays after scheduled reboot @ 5am updates.
i think i'll have put in script this courtesy of jeremy houp
http://community.spiceworks.com/scripts/show/2565-resume-vmreplication
$vmhosts = "host1","host2","host3","host4"
$replicationdata = get-vm -computername $vmhosts | get-vmreplication | where-object replicationmode -eq primary
$replicationdata
foreach ($vmreplica in $replicationdata) {
write-host "starting replication on" $vmreplica.name
do{
if ($vmreplica.health -eq "critical" -and $vmreplica.state -eq "error") {
write-host "vm replication in critical error state, resetting stats , resuming replication"
reset-vmreplicationstatistics -computername $vmreplica.primaryserver -vmname $vmreplica.name
resume-vmreplication -computername $vmreplica.primaryserver -vmname $vmreplica.name
write-host "waiting 60 seconds..."
start-sleep -seconds 60
}
elseif ($vmreplica.health -eq "warning" -and $vmreplica.state -eq "suspended") {
write-host "vm replication in suspended state, resetting stats , resuming replication"
reset-vmreplicationstatistics -computername $vmreplica.primaryserver -vmname $vmreplica.name
resume-vmreplication -computername $vmreplica.primaryserver -vmname $vmreplica.name
write-host "waiting 60 seconds..."
start-sleep -seconds 60
}
elseif ($vmreplica.health -eq "critical" -and $vmreplica.state -eq "waitingforstartresynchronize") {
write-host "vm replication waiting start resynchronize, resuming replication"
reset-vmreplicationstatistics -computername $vmreplica.primaryserver -vmname $vmreplica.name
resume-vmreplication -computername $vmreplica.primaryserver -vmname $vmreplica.name -resynchronize
write-host "waiting 60 seconds..."
start-sleep -seconds 60
}
elseif ($vmreplica.health -eq "warning" -and $vmreplica.state -eq "readyforinitialreplication") {
write-host "vm replication ready initial replication, starting initial replication"
reset-vmreplicationstatistics -computername $vmreplica.primaryserver -vmname $vmreplica.name
start-vminitialreplication -computername $vmreplica.primaryserver -vmname $vmreplica.name
write-host "waitingfor 60 seconds..."
start-sleep -seconds 60
}
elseif($vmreplica.health -eq "warning") {
reset-vmreplicationstatistics -computername $vmreplica.primaryserver -vmname $vmreplica.name
}
$vmreplicahealth = get-vm -computername $vmreplica.computername -name $vmreplica.vmname | get-vmreplication
start-sleep -seconds 10
}
until($vmreplicahealth.health -eq "normal" -and $vmreplicahealth.state -eq "replicating")
}
Windows Server > Hyper-V
Comments
Post a Comment