DataCore SANsymphony와 Hyper-V로 HCI 구성을 구성할 때의 네트워크를 파워 쉘로 만든다

2019/6/26 전면적으로 재작성했습니다.

준비


  • 서버 당 4 포트 준비
  • 처음의 2개는 팀을 짜서, 관리(이른 이야기가 RDP용), 서비스(일명, VM용이나 업무용등), 라이브 마이그레이션, 하트비트, CSV등에 사용합니다.
  • 나머지 2개는 iSCSI에 사용합니다. 중복은 MPIO를 사용하기 때문에 팀은 사용하지 않습니다.


  • #先に必要な機能をインストール
    Install-WindowsFeature -Name "Hyper-V", "Failover-Clustering", "Data-Center-Bridging", "RSAT-Clustering-PowerShell", "Hyper-V-PowerShell", "FS-FileServer", "FS-Data-Deduplication"  -IncludeManagementTools -IncludeAllSubFeature
    #ついでにファイルサーバーも兼ねるなら
    Install-WindowsFeature -Name "FS-FileServer", "FS-Data-Deduplication"  -IncludeManagementTools -IncludeAllSubFeature
    #OSの再起動が必要
    
    #変数(適宜書き換える)
    ##本番ネットワーク用アダプター名
    $prodNicName1 = ""
    $prodNicName2 = ""
    ##iSCSIネットワーク用アダプター名
    $iSCSINicName1 = ""
    $iSCSINicName2 = ""
    
    ##本番ネットワーク用チーミング名
    $productionTeamName = "Prod_Team"
    
    ##vSwitch名
    $productionvSwitchName = "Prod_vSwitch"
    
    $iSCSIvSwitchName1 = "iSCSI01_vSwitch"
    $iSCSIvSwitchName2 = "iSCSI02_vSwitch"
    
    ##vLAN ID
    $ManagementVlan=0
    $CsvVlan=302
    $HeartbeatVlan=303
    $LiveMigrationVlan=304
    
    $FE1Vlan=101
    $BE1Vlan=101
    $MR1Vlan=102
    
    $FE2Vlan=201
    $BE2Vlan=201
    $MR2Vlan=202
    
    ##MinimumBandwidthWeight
    $ManagementWeight=80
    $CsvWeight=100
    $HeartbeatWeight=90
    $LiveMigrationWeight=20
    
    $FEWeight=80
    $MRWeight=100
    $BEWeight=80
    
    ##IPアドレス設定
    $ManagementIP = "0.0.0.0"
    $ManagementPrefix = "24"
    $ManagementGW = "0.0.0.0"
    $ManagementDNS = "0.0.0.0"
    $CsvIP = "0.0.0.0"
    $CsvPfrefix = "24"
    $HeartbeatIP = "0.0.0.0"
    $HeartbeatPrefix = "24"
    $LiveMigrationIP = "0.0.0.0"
    $LiveMigrationPrefix = "24"
    
    $FE1IP = "0.0.0.0"
    $FE1Prefix = "24"
    $MR1IP = "0.0.0.0"
    $MR1Prefix = "24"
    $BE1IP = "0.0.0.0"
    $BE1Prefix = "24"
    
    $FE2IP = "0.0.0.0"
    $FE2Prefix = "24"
    $MR2IP = "0.0.0.0"
    $MR2Prefix = "24"
    $BE2IP = "0.0.0.0"
    $BE2Prefix = "24"
    
    ##本番用のチーミングを作ります
    $TEAM = New-NetLbfoTeam -Name "$ProductionTeamName" -TeamMembers "$ProdNicName1","$ProdNicName2" -TeamingMode SwitchIndependent -LoadBalancingAlgorithm IPAddresses -confirm:$false
    ##本番用のvSwitchを作ります
    $VS = New-VMSwitch -Name "$productionvSwitchName" -NetAdapterName $TEAM.name -AllowManagementOS $false -MinimumBandwidthMode weight
    ##本番用のvNICを作ります
    ###管理(RDPやインターネット接続)を別のオンボードNICにする時はManagementを削除
    $Usage = "Management","Csv","Heartbeat","LiveMigration"
    Foreach ($i in $Usage){
        $Vlan1 = Get-Variable -Name "${i}Vlan" -ValueOnly
        $IP1 = Get-Variable -Name "${i}IP" -ValueOnly
        $Prefix1 = Get-Variable -Name "${i}Prefix" -ValueOnly
        $Weight1 = Get-Variable -Name "${i}Weight" -ValueOnly
        Add-VMNetworkAdapter -Name $i -ManagementOS -SwitchName $VS.name | Set-VMNetworkAdapterVlan -vlanid $Vlan1 -access | Set-VMNetworkAdapter -ManagementOS -MinimumBandwidthWeight $Weight1
        $NA = Get-NetAdapter | Where-Object{$_.Name -match $i}
        If($i -eq "Management"){ 
            New-NetIPAddress -InterfaceAlias $NA.name -IPAddress $IP1 -AddressFamily IPv4 -PrefixLength $Prefix1 -DefaultGateway $ManagementGW
            Set-DnsClientServerAddress  -InterfaceAlias $NA.Name -ServerAddresses $managementDNS
        }else{
            New-NetIPAddress -InterfaceAlias $NA.Name -IPAddress $IP1 -AddressFamily IPv4 -PrefixLength $Prefix1
            }
    
    }
    
    
    ##iSCSI vSwitchを作ります
    For ($x = 1;$x -le 2;$x++){
        $VMSwitchName = Get-Variable -Name "iSCSIvSwitchName${x}" -ValueOnly
        $iSCSINicName = Get-Variable -Name "iSCSINicName${x}" -ValueOnly
        $VS = New-VMSwitch -Name $VMSwitchName -NetAdapterName $iSCSINicName -AllowManagementOS $false -MinimumBandwidthMode weight
        $Role = "FE","MR","BE"
        Foreach ($y in $Role){
            $Vlan2 = Get-Variable -Name "${y}${x}Vlan" -ValueOnly
            $Weight2 = Get-Variable -Name "${y}Weight" -ValueOnly
            $IP2 = Get-Variable -Name "${y}${x}IP" -ValueOnly
            $Prefix2 = Get-Variable -Name "${y}${x}Prefix" -ValueOnly
            ##iSCSI用のvNICを作ります
            Add-VMNetworkAdapter -Name "iSCSI-${y}0${x}" -ManagementOS -SwitchName $VMSwitchName | Set-VMNetworkAdapterVlan -ManagementOS -vlanid $Vlan2 -access | Set-VMNetworkAdapter -ManagementOS -MinimumBandwidthWeight $Weight2
            Get-NetAdapter | Where-Object{$_.Name -match "iSCSI-${y}0${x}"} | New-NetIPAddress -IPAddress $IP2 -AddressFamily IPv4 -PrefixLength $Prefix2
        }
    }
    

    완료하면 이런 느낌입니다.

    좋은 웹페이지 즐겨찾기