Managing Storage Replica

Storage Replica (SR) is a feature of Windows Server 2019 that replicates storage volumes to other systems. SR is only available with the Windows Server 2019 Datacentre edition.

Getting ready

This recipe makes use of additional disk volumes on SRV1 and SRV2. In the Managing physical disks and disk volumes recipe, you added two additional disks to SRV1. In this recipe, you need to have two additional disks added to SRV2 that form the basis for storage replication. This recipe requires two additional hard disks for SRV2—you can use the Add-DiskstoSrv1+2.ps1 script to create the disks used in this and other recipes in this chapter. You can find the script on this book's GitHub repository (https://github.com/DoctorDNS/PowerShellCookBook2019/blob/master/Chapter%2004%20-%20Managing%20Storage/Add-DiskstoSRV1%2B2.ps1).

Run this recipe on SRV1 with SRV2 and DC1 online:

  1. Create content on the F: drive in SRV1:
    1..100 | ForEach {
      $NF = "F:CoolFolder$_"
      New-Item -Path $NF -ItemType Directory | Out-Null
      1..100 | ForEach {
        $NF2 = "$NFCoolFile$_"
        "Cool File" | Out-File -PSPath $NF2
      }
    }
  2. Show what's on F: locally on SRV1:
    Get-ChildItem -Path F: -Recurse | Measure-Object
  3. Examine the same drives remotely on SRV2:
    $SB = {
      Get-ChildItem -Path F: -Recurse |
        Measure-Object
    }
    Invoke-Command -ComputerName SRV2 -ScriptBlock $SB
  4. Add a Storage Replica feature to SRV1:
    Add-WindowsFeature -Name Storage-Replica
  5. Restart SRV1 to finish the installation process:
    Restart-Computer
  6. Add a storage-replica feature to SRV2:
    $SB= {
      Add-WindowsFeature -Name Storage-Replica | Out-Null
    }
    Invoke-Command -ComputerName SRV2 -ScriptBlock $SB
  7. Restart SRV2 and wait until the restart is complete:
    $RSHT = @{
      ComputerName = 'SRV2'
      Force        = $true
    }
    Restart-Computer @RSHT -Wait -For PowerShell
  8. Create a Storage Replica by replicating from F: on SRV1 to F: on SRV2:
    $SRHT =  @{
      SourceComputerName       = 'SRV1'
      SourceRGName             = 'SRV1RG'
      SourceVolumeName         = 'F:'
      SourceLogVolumeName      = 'G:'
      DestinationComputerName  = 'SRV2'
      DestinationRGName        = 'SRV2RG'
      DestinationVolumeName    = 'F:'
      DestinationLogVolumeName = 'G:'
      LogSizeInBytes           = 2gb
    }
    New-SRPartnership @SRHT -Verbose 
  9. View the storage replication partnership:
    Get-SRPartnership
  10. Examine the same drives remotely on SRV2:
    $SB = {
      Get-Volume |
        Sort-Object -Property DriveLetter |
          Format-Table   
    }
    Invoke-Command -ComputerName SRV2 -ScriptBlock $SB
  11. Reverse the replication:
    $SRHT2 = @{ 
      NewSourceComputerName   = 'SRV2'
      SourceRGName            = 'SRV2RG' 
      DestinationComputerName = 'SRV1'
      DestinationRGName       = 'SRV1RG'
      Confirm                 = $False
    }
    Set-SRPartnership @SRHT2
  12. View the replication partnership after reversing:
    Get-SRPartnership
  13. Examine the same drives remotely on SRV2:
    $SB = {
      Get-ChildItem -Path F: -Recurse |
        Measure-Object
    }
    Invoke-Command -ComputerName SRV2 -ScriptBlock $SB

How it works…

In step 1, you create 100 folders on the F: of SRV1. Inside each folder, you also create 100 files. Each file contains some content. This step produces no output. In step 2, you view what you just created, which looks like this:

How it works…

In step 3, you view the F: drive on SRV2 (which contains no files yet). The output from step 3 looks like this:

How it works…

In step 4, you add the Storage Replica feature to SRV1, which looks like this:

How it works…

In step 5, you reboot SRV1. In step 6 and step 7, you add the Storage Replica feature to SRV2 then reboot SRV2. These three steps produce no output.

In step 8, you create a Storage Replica partnership, replicating the contents of F: on SRV1 to F: on SRV2 (with the G: drive on both servers serving as a log file folder for storage replication). The output from this step looks like this:

How it works…

In step 9, you use the Get-SRPartnership cmdlet to view the now-reversed replication partnership, which looks like this:

How it works…

In step 10, you examine the volumes available on SRV2, which look like this:

How it works…

Thus far, you're replicating from SRV1 to SRV2. In step 11, you reverse the replication, which generates no output. With step 12, you can see that the replication is now reversed, replicating from files on SRV2 to SRV1. The output from this step looks like this:

How it works…

In the final step, step 13, you count the files now available on SRV2, which looks like this:

How it works…

There's more...

In this recipe, you create a set of 100 folders and 10,000 files on SRV1, which you replicate to SRV2. After the replication starts, you can't actually see anything useful on SRV2 since the volume is being used by SR itself. As you can see in step 10, the replicated data isn't viewable on SRV2—the partition into SR is replicating has no apparent filesystem. Once you reverse the replication, as you can see in step 11 and step 12, the files and folders on SRV2 are now viewable (and those on SRV1 wouldn't be viewable). This is a feature of SR that prevents accidentally storing data on the replicated disk.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.120.133