70-740, Teil 5.2.1. Arbeitsgruppen, Einfachen und Mehrere Domänen- Cluster implementieren

70-740, Teil 5.2.1.

Arbeitsgruppen, Einfachen und Mehrere Domänen- Cluster implementieren

Ideen für die Recherche im Web:

youtube NLB Solutions failover cluster

Zum Nachschlagen:

https://docs.microsoft.com/de-de/windows-server/failover-clustering/failover-clustering-overview

https://docs.microsoft.com/de-de/windows-server/failover-clustering/whats-new-in-failover-clustering

https://docs.microsoft.com/de-de/windows-server/failover-clustering/fault-domains

https://www.youtube.com/channel/UCNzrVTbi4fe_PbYCJvhPQ8A/videos

https://www.youtube.com/watch?v=4bCeqfhoW0c

https://www.youtube.com/watch?v=CvRwTJCScQY

Übungen:

###

#Beispiel 1

###

$mountResult = Mount-DiskImage -ImagePath „C:\ISOs\Windows2016.iso“ -PassThru

$mountResult | Get-Volume

$driveLetter = (($mountResult | Get-Volume).DriveLetter) + „:\“

$isoPath=$driveLetter + „NanoServer\NanoServerImageGenerator“

$isoPath

If(Test-Path „C:\NanoServerImageGenerator“)
{
}
else
{
Copy-Item $isoPath -Destination C:\ -Recurse
}

cd C:\NanoServerImageGenerator

Get-ExecutionPolicy
# Bei Bedarf: Set-ExecutionPolicy RemoteSigned
# https://technet.microsoft.com/de-de/library/ee176961.aspx

Import-Module .\NanoServerImageGenerator -Verbose

#get-help New-NanoServerImage -ShowWindow

#get-help New-NanoServerImage -Online

dir $driveLetter

Get-VMSwitch

(Get-VMSwitch | Where-Object -Property SwitchType -EQ External).Name
$var_VMSwitch_Name = (Get-VMSwitch | Where-Object {$_.SwitchType -eq ‚External‘}).Name

Rename-VMSwitch -Name $var_VMSwitch_Name -NewName ‚Management‘

New-VMSwitch -Name Storage -SwitchType Private

New-VMSwitch -Name Heartbeat -SwitchType Private

New-VMSwitch -Name LiveMigration -SwitchType Private

$Secure = Read-Host -AsSecureString
#https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/convertto-securestring?view=powershell-5.1

1..2 | % {

$User_Name=“wdc$_“+“\administrator“

$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User_Name,$Secure

New-NanoServerImage -DeploymentType Guest -Edition Datacenter -TargetPath .\wdc$_.vhdx -Clustering -Storage -ComputerName wdc$_ -DomainName kaffee.pause -EnableRemoteManagementPort -InterfaceNameOrIndex Ethernet -Ipv4Address 10.110.4.$_ -Ipv4Dns 10.10.4.1 -Ipv4Gateway 10.0.4.1 -Ipv4SubnetMask 255.0.0.0 -MaxSize 100GB -MediaPath $driveLetter -ReuseDomainNode -AdministratorPassword $Secure
#https://docs.microsoft.com/en-us/powershell/module/nanoserverimagegenerator/new-nanoserverimage?view=win10-ps

New-VM -VHDPath C:\NanoServerImageGenerator\wdc$_.vhdx -Generation 2 -MemoryStartupBytes 2GB -Name wdc$_ -SwitchName Management
#https://technet.microsoft.com/de-de/library/hh848537.aspx

Add-VMNetworkAdapter -VMName wdc$_ -Name Storage -SwitchName Storage

Add-VMNetworkAdapter -VMName wdc$_ -Name Heartbeat -SwitchName Heartbeat

Add-VMNetworkAdapter -VMName wdc$_ -Name LiveMigration -SwitchName LiveMigration

New-VHD –Path C:\NanoServerImageGenerator\wdfAc$_.vhdx –SizeBytes 100GB -Dynamic

Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfAc$_.vhdx

New-VHD –Path C:\NanoServerImageGenerator\wdfBc$_.vhdx –SizeBytes 100GB -Dynamic

Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfBc$_.vhdx

New-VHD –Path C:\NanoServerImageGenerator\wdfCc$_.vhdx –SizeBytes 100GB -Dynamic

Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfCc$_.vhdx

Start-VM -VMName wdc$_

}

Get-VM wdc*

if ((Get-WindowsFeature RSAT-Clustering).InstallState -eq ‚Available‘)
{
Install-WindowsFeature RSAT-Clustering, RSAT-Clustering-PowerShell, RSAT-Clustering-Mgmt, RSAT-Clustering-CmdInterface, RSAT-Clustering-AutomationServer
}
###

#$Secure = Read-Host -AsSecureString

#$User_Name=“kaffee“+“\administrator“

#$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User_Name,$Secure

2..2 | % {

$User_Name=“wdc$_“ + “\administrator“

$User_Name

$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User_Name,$Secure

$ps_wdc=New-PSSession -VMName wdc$_ -Credential $Credential

$var_Management = (Get-VMNetworkAdapter -VMName wdc$_ | Where-Object {($_.SwitchName -like ‚Management‘)})

$var_Storage = Get-VMNetworkAdapter -VMName wdc$_ | Where-Object {($_.SwitchName -like ‚Storage‘)}

$var_Heartbeat = Get-VMNetworkAdapter -VMName wdc$_ | Where-Object {($_.SwitchName -like ‚Heartbeat‘)}

$var_LiveMigration = Get-VMNetworkAdapter -VMName wdc$_ | Where-Object {($_.SwitchName -like ‚LiveMigration‘)}

$var_Management.MacAddress

Invoke-Command -Session $ps_wdc -ScriptBlock {

Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Management.MacAddress))} | ft InterfaceIndex, Name, InterfaceDescription, MacAddress

$var_ifIndex=Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Management.MacAddress))}

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

Set-NetIPInterface -InterfaceIndex $var_ifIndex.InterfaceIndex -Dhcp Disabled

Remove-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -Confirm:$false

New-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -IPAddress 10.110.4.11$_ -PrefixLength 8 #–DefaultGateway 10.0.4.1

Set-NetRoute -InterfaceIndex $var_ifIndex.InterfaceIndex –DestinationPrefix ‚0.0.0.0/0‘ -NextHop ‚10.0.4.1‘

Set-DnsClientServerAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -ServerAddresses („10.8.4.1“)

#Set-NetIPAddress –InterfaceIndex $var_ifIndex.InterfaceIndex –IPAddress 10.110.4.11 –PrefixLength 8 -InterfaceAlias ‚Management‘

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

}

Invoke-Command -Session $ps_wdc -ScriptBlock {Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex}

$var_Storage.MacAddress

Invoke-Command -Session $ps_wdc -ScriptBlock {

Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Storage.MacAddress))} | ft InterfaceIndex, Name, InterfaceDescription, MacAddress

$var_ifIndex=Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Storage.MacAddress))}

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

Set-NetIPInterface -InterfaceIndex $var_ifIndex.InterfaceIndex -Dhcp Disabled

Remove-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -Confirm:$false

New-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -IPAddress 10.110.4.12$_ -PrefixLength 8

Set-DnsClientServerAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -ServerAddresses („10.8.4.1“)

#Set-NetIPAddress –InterfaceIndex $var_ifIndex.InterfaceIndex –IPAddress 10.110.4.12 –PrefixLength 8 -InterfaceAlias ‚Storage‘

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

}

Invoke-Command -Session $ps_wdc -ScriptBlock {Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex}

$var_Heartbeat.MacAddress

Invoke-Command -Session $ps_wdc -ScriptBlock {

Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Heartbeat.MacAddress))} | ft InterfaceIndex, Name, InterfaceDescription, MacAddress

$var_ifIndex=Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_Heartbeat.MacAddress))}

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

Set-NetIPInterface -InterfaceIndex $var_ifIndex.InterfaceIndex -Dhcp Disabled

Remove-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -Confirm:$false

New-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -IPAddress 10.110.4.13$_ -PrefixLength 8

Set-DnsClientServerAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -ServerAddresses („10.8.4.1“)

#Set-NetIPAddress –InterfaceIndex $var_ifIndex.InterfaceIndex –IPAddress 10.110.4.13 –PrefixLength 8 -InterfaceAlias ‚Heartbeat‘

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

}

Invoke-Command -Session $ps_wdc -ScriptBlock {Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex}

$var_LiveMigration.MacAddress

Invoke-Command -Session $ps_wdc -ScriptBlock {

Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_LiveMigration.MacAddress))} | ft InterfaceIndex, Name, InterfaceDescription, MacAddress

$var_ifIndex=Get-NetAdapter | Where-Object {($_.MacAddress.replace(„-„,““) -like ($Using:var_LiveMigration.MacAddress))}

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

Set-NetIPInterface -InterfaceIndex $var_ifIndex.InterfaceIndex -Dhcp Disabled

Remove-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -Confirm:$false

New-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -IPAddress 10.110.4.14$_ -PrefixLength 8

Set-DnsClientServerAddress -InterfaceIndex $var_ifIndex.InterfaceIndex -ServerAddresses („10.8.4.1“)

#Set-NetIPAddress –InterfaceIndex $var_ifIndex.InterfaceIndex –IPAddress 10.110.4.14 –PrefixLength 8 -InterfaceAlias ‚LiveMigration‘

Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex

}

Invoke-Command -Session $ps_wdc -ScriptBlock {Get-NetIPAddress -InterfaceIndex $var_ifIndex.InterfaceIndex}

}

Get-VMNetworkAdapter -VMName wdc1, wdc2

New-Cluster -name wdNanoCluster1 -Node wdc1, wdc2 -StaticAddress 10.110.4.10 -NoStorage

Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule -DisplayGroup „*Remote*“ | ft DisplayName, Enabled}

Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule -DisplayGroup „*Remote*“ | Enable-NetFirewallRule}

Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule –Name “FPS-ICMP4-ERQ-Out” | Enable-NetFirewallRule}

###

#Beispiel 2

###

$mountResult = Mount-DiskImage -ImagePath „D:\WindowsServer2016.iso“ -PassThru

$mountResult | Get-Volume

$driveLetter = (($mountResult | Get-Volume).DriveLetter) + „:\“

$isoPath=$driveLetter + „NanoServer\NanoServerImageGenerator“

$isoPath

If(Test-Path „C:\NanoServerImageGenerator“)
{
}
else
{
Copy-Item $isoPath -Destination C:\ -Recurse
}

cd C:\NanoServerImageGenerator

Get-ExecutionPolicy
# Bei Bedarf: Set-ExecutionPolicy RemoteSigned
# https://technet.microsoft.com/de-de/library/ee176961.aspx

Import-Module .\NanoServerImageGenerator -Verbose

#get-help New-NanoServerImage -ShowWindow

#get-help New-NanoServerImage -Online

dir $driveLetter

Get-VMSwitch

New-VMSwitch -Name Management -SwitchType Private
New-VMSwitch -Name Storage -SwitchType Private
New-VMSwitch -Name Heartbeat -SwitchType Private
New-VMSwitch -Name LiveMigration -SwitchType Private
Get-VMSwitch

$Secure = Read-Host -AsSecureString
#https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/convertto-securestring?view=powershell-5.1

1..3 | % {
New-NanoServerImage -DeploymentType Guest -Edition Datacenter -TargetPath .\wdc$_.vhdx -Clustering -Compute -ComputerName wdc$_ -Containers -DomainName gemuetliche.pause -EnableRemoteManagementPort -InterfaceNameOrIndex Management -Ipv4Address 10.104.4.$_ -Ipv4Dns 10.4.4.1 -Ipv4Gateway 10.0.4.1 -Ipv4SubnetMask 255.255.255.0 -MaxSize 100GB -MediaPath $driveLetter -Package Microsoft-NanoServer-DNS-Package -ReuseDomainNode -Storage -AdministratorPassword $Secure
#https://docs.microsoft.com/en-us/powershell/module/nanoserverimagegenerator/new-nanoserverimage?view=win10-ps

New-VM -VHDPath C:\NanoServerImageGenerator\wdc$_.vhdx -Generation 2 -MemoryStartupBytes 1GB -Name wdc$_ -SwitchName Management
#https://technet.microsoft.com/de-de/library/hh848537.aspx

Add-VMNetworkAdapter -VMName wdc$_ -Name Storage -SwitchName Storage
Add-VMNetworkAdapter -VMName wdc$_ -Name Heartbeat -SwitchName Heartbeat
Add-VMNetworkAdapter -VMName wdc$_ -Name LiveMigration -SwitchName LiveMigration

New-VHD –Path C:\NanoServerImageGenerator\wdfAc$_.vhdx –SizeBytes 10GB
Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfAc$_.vhdx
New-VHD –Path C:\NanoServerImageGenerator\wdfBc$_.vhdx –SizeBytes 10GB
Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfBc$_.vhdx
New-VHD –Path C:\NanoServerImageGenerator\wdfCc$_.vhdx –SizeBytes 10GB
Add-VMHardDiskDrive -VMName wdc$_ -Path C:\NanoServerImageGenerator\wdfCc$_.vhdx
Start-VM -VMName wdc$_

$User_Name=“wdc$_“+“\administrator“
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User_Name,$Secure
Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule -DisplayGroup „*Remote*“ | ft DisplayName, Enabled}
Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule -DisplayGroup „*Remote*“ | Enable-NetFirewallRule}
Invoke-Command -VMName wdc$_ -Credential $Credential -ScriptBlock {Get-NetFirewallRule –Name “FPS-ICMP4-ERQ-Out” | Enable-NetFirewallRule}
}
###
New-Cluster -name wdNanoCluster1 -Node wdc1, wdc2 -StaticAddress 10.104.4.100 -S2D

 

###

 

 

###

#Beispiel 3

###

Get-VM
Start-VM ag-core1,ag-core2
.\HOSTNAME.EXE
Get-WindowsFeature *iscsi*
Install-WindowsFeature FS-iSCSITarget-Server -IncludeAllSubFeature -IncludeManagementTools
Get-Command new*iscsi*
Get-Help New-IscsiVirtualDisk -ShowWindow
New-IscsiVirtualDisk -Path C:\iSCSI\iSCSI-Target-1.vhdx -SizeBytes 500MB -UseFixed
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsivirtualdisk?view=win10-ps
New-IscsiServerTarget -TargetName „iSCSI-Ziel-1“ -InitiatorId @(„IPAddress:10.101.2.201″,“IPAddress:10.101.2.202“)
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsiservertarget?view=win10-ps
Add-IscsiVirtualDiskTargetMapping -TargetName „iSCSI-Ziel-1“ -DevicePath „C:\iSCSI\iSCSI-Target-1.vhdx“
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/add-iscsivirtualdisktargetmapping?view=win10-ps
New-IscsiVirtualDisk -Path C:\iSCSI\iSCSI-Target-2.vhdx -SizeBytes 100GB
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsivirtualdisk?view=win10-ps
New-IscsiServerTarget -TargetName „iSCSI-Ziel-2“ -InitiatorId @(„IPAddress:10.101.2.201″,“IPAddress:10.101.2.202“)
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/new-iscsiservertarget?view=win10-ps
Add-IscsiVirtualDiskTargetMapping -TargetName „iSCSI-Ziel-2“ -DevicePath „C:\iSCSI\iSCSI-Target-2.vhdx“
#https://docs.microsoft.com/en-us/powershell/module/iscsitarget/add-iscsivirtualdisktargetmapping?view=win10-ps

1..2 | % {
Enter-PSSession -VMName ag-core$_
#Invoke-Command
Set-Service -Name msiscsi -StartupType Automatic
#https://blogs.msdn.microsoft.com/san/2012/07/31/managing-iscsi-initiator-connections-with-windows-powershell-on-windows-server-2012/
Get-Service -Name msiscsi
Set-Service -Name msiscsi -Status Running
Get-Service -Name msiscsi
Get-NetFirewallServiceFilter -Service msiscsi | Get-NetFirewallRule | Select DisplayGroup,DisplayName,Enabled
Get-NetFirewallServiceFilter -Service msiscsi | Get-NetFirewallRule | Set-NetFirewallRule -Enabled True
Get-NetFirewallServiceFilter -Service msiscsi | Get-NetFirewallRule | Select DisplayGroup,DisplayName,Enabled
New-IscsiTargetPortal –TargetPortalAddress 10.1.2.1
#https://docs.microsoft.com/en-us/powershell/module/iscsi/new-iscsitargetportal?view=win10-ps
Get-IscsiTarget | Connect-IscsiTarget #-IsMultipathEnabled $true -IsPersistent $true
Get-IscsiTarget | ft NodeAddress, IsConnected
Get-iSCSIConnection
Get-iSCSISession
Get-iSCSISession | Get-Disk | ft Size,OperationalStatus
Get-Disk | Where-Object IsOffline –Eq $True
Get-Disk | Where-Object IsOffline –Eq $True | Set-Disk -IsOffline $false
Get-Disk | ft Size,OperationalStatus
Exit-PSSession
}

#Bei Bedarf
#Auf beiden Knoten Cmdlet „iscsicpl“ ausführen und die Einstellungen mit Hilfe von  iSCSI-Initiator konfigurieren.

#Bei Bedarf
#Auf beiden Knoten „diskpart“ aufrufen und die Einstellungen anpassen
#diskpart
#list disk
#select disk 1
#online disk
#attributes disk clear readonly
#create partition primary
#select partition 1
#format fs=ntfs label=(Zeuge) quick
#list partition
#list disk
#select disk 2
#online disk
#attributes disk clear readonly
#create partition primary
#select partition 1
#format fs=ntfs label=(Daten) quick
#list partition

Get-WindowsFeature *cluster*

Invoke-Command -ComputerName ag-core1,ag-core2 -ScriptBlock {Install-WindowsFeature failover-clustering -IncludeAllSubFeature -IncludeManagementTools}

#Bei Bedarf
Stop-VM -Name ag-core1,ag-core2 -Confirm -Force
Get-VM ag-core1,ag-core2

Get-VMProcessor -VMName * | ft VMName, ExposeVirtualizationExtensions

Set-VMProcessor -VMName ag-core1,ag-core2 -ExposeVirtualizationExtensions $true

Get-VMProcessor -VMName ag-core1,ag-core2 | ft VMName, ExposeVirtualizationExtensions

Get-VMMemory ag-core1,ag-core2 | ft VMName, DynamicMemoryEnabled

#Bei Bedarf
Set-VMMemory ag-core1,ag-core2 -DynamicMemoryEnabled $false
Get-VMMemory ag-core1,ag-core2 | ft VMName, DynamicMemoryEnabled

Get-VMMemory -VMName ag-core1,ag-core2 | fl VMName, Startup
#Bei Bedarf
#Mindestens 4GB
Set-VM -name ag-core1,ag-core2 –MemoryStartupBytes 4GB
Get-VMMemory -VMName ag-core1,ag-core2 | fl VMName, Startup

Get-VMNetworkAdapter -VMName ag-core1,ag-core2 | ft VMName, MacAddressSpoofing
#Bei Bedarf
Get-VMNetworkAdapter -VMName ag-core1,ag-core2 | Set-VMNetworkAdapter -MacAddressSpoofing On
Get-VMNetworkAdapter -VMName ag-core1,ag-core2 | ft VMName, MacAddressSpoofing

Start-VM -Name ag-core1,ag-core2 -Confirm

Get-VM -Name ag-core1,ag-core2

Invoke-Command -ComputerName ag-core1,ag-core2 -ScriptBlock {Install-WindowsFeature Hyper-V -IncludeAllSubFeature -IncludeManagementTools}

Restart-VM msclustercore1,msclustercore2

Get-VM msclustercore1,msclustercore2

Install-WindowsFeature RSAT-Clustering-PowerShell, RSAT-Clustering-Mgmt

get-command test*cluster*
Test-Cluster -Node msclustercore1,msclustercore2 -Include Storage
get-command new*cluster*
New-Cluster -Name mscluster1 -Node msclustercore1,msclustercore2 -StaticAddress 10.202.4.200