2012-05-03 2 views
4

클러스터가 있는지 확인하는 powershell 프로그램을 작성하려고했습니다. 그렇지 않은 경우 생성하고 자체에 추가합니다. 다른 컴퓨터가 깨어 나면 클러스터가 있는지 확인하고 클러스터가 있으면 클러스터에 자신을 추가합니다.기존 NLB 클러스터에 가입

클러스터 IP 주소에서 클러스터 개체에 대한 참조를 가져 오는 데 문제가 있습니다. 모든 노드는 주소와 클러스터 주소를 알고 있습니다. 모든 노드가 클러스터의 다른 모든 노드 목록을 가지지 않도록하고 싶습니다.

get-nlbcluster를 작동 시키려면 비 클러스터 IP 주소를 확인해야합니다. 클러스터 IP 주소를 지정하면 오류 만 발생합니다.

클러스터에서 노드를 추가하거나 제거 할 때마다 모든 노드에서이 목록을 업데이트하지 않고도이 작업을 수행 할 수있는 방법이 있습니까? 나는 또한 노드가 깨어나서 "마스터"목록에있는 각각의 머신을 폴링하여 자신을 클러스터에 추가하기 위해 올라있는 머신을 찾고자하는 상황을 피하고자한다.

답변

1

: 나는 얼마 전에 그것을했지만 완전히 테스트 할 수있는 기회를 가진 적이 없어 현재 컴퓨터를 기존 클러스터에 추가합니다. 클러스터의 모든 컴퓨터에 동일한 이름의 전용 카드가 있는지 확인하십시오. 아래 예제에서 네트워크 카드의 이름은 'NLB'입니다.

Import-Module ServerManager 

# Interface cards should be named the same and have a fixed IP 
$interfaceName = "NLB" 
$clusterName = "NLB-Cluster" 
$clusterIpAddress = "1.2.3.0" 
$clusterSubnet = "255.0.0.0" 

# Install Network Load Balancing and Tools 
Write-Host "Install Network Load Balancing and Tools" 
Add-WindowsFeature NLB, RSAT-NLB 
Import-Module NetworkLoadBalancingClusters 

# If the cluster hasn't been created yet then create it 
if (!(Get-NlbCluster -HostName $clusterIpAddress -ErrorAction SilentlyContinue)) 
{ 
    Write-Host "Creating NLB Cluster: $clusterName" -ForegroundColor yellow 

    # Create Cluster (default unicast) 
    New-NlbCluster -InterfaceName $interfaceName -ClusterName $clusterName -ClusterPrimaryIP $clusterIpAddress -SubnetMask $clusterSubnet 

    # Remove defaults 
    Write-Host "Removing default port rules" -ForegroundColor yellow 
    Get-NlbClusterPortRule | Remove-NlbClusterPortRule -Force 

    # Create port rules 
    Get-NlbCluster | Add-NlbClusterPortRule -StartPort 80 -EndPort 80 -Protocol TCP -Affinity None | Out-Null 
    Get-NlbCluster | Add-NlbClusterPortRule -StartPort 443 -EndPort 443 -Protocol TCP -Affinity None | Out-Null 
} 
else 
{ 
    Get-NlbCluster 
} 

# if this node isn't already a member of a cluster then add it 
if(!(Get-NlbClusterNode -HostName $env:COMPUTERNAME)) 
{ 
    # Add node to cluster 
    Write-Host "Adding node to cluster: $clusterName" -ForegroundColor yellow 
    Get-NlbCluster -HostName $clusterIpAddress | Add-NlbClusterNode -NewNodeName $env:COMPUTERNAME -NewNodeInterface $interfaceName 
} 
else 
{ 
    Get-NlbClusterNode 
} 
2

이 정보가 도움이 되나요? 그렇지 않으면 단지 추가, 클러스터가 다음 존재를 작성하지 않는 경우 다음 스크립트는 클러스터의 모든 노드에서 실행할 수 있습니다

#Add a new node to NLB cluster 
#Tested with Windows Server 2008 R2 only 
#Requires WSManCredSSP Server Role Enabled on cluster Host 
Function join-NlbCluster { 
    Param(
     [Parameter(Mandatory=$true)] 
     $clusterHostname, 
     [Parameter(Mandatory=$true)] 
     $newNodename, 
     [Parameter(Mandatory=$true)] 
     $newNodeinterfaceName, 
     [Parameter(Mandatory=$true)] 
     $userName, 
     [Parameter(Mandatory=$true)] 
     $password 
     ) 
    Write-Verbose "Verifiying if the remote node has NLB installed" 
    If (!((Get-OSFeature -computerName $newNodename -featureName NLB).Installed)) { 
     Write-Error "NLB feature is not installed on $newNodename. Cannot continue." 
     return $false 
    } 
    $cmdBlock = "Import-Module networkLoadBalancingClusters 
    `$nlbCluster = Get-nlbCluster -HostName $clusterHostName 
    if (`$nlbCluster) { 
     `$newNode = Add-NlbClusterNode -InputObject `$nlbCluster -NewNodeName $newNodename -NewNodeInterface `"$newNodeinterfaceName`" 
     if (`$newNode) { 
      Write-Host `"New node is added to cluster`" 
      return `$newNode 
     } else { 
      Write-Host `"Error Creating the NLB Cluster`" 
      return `$false 
     } 
    } else { 
     Write-Host `"No NLB cluster found on $clusterHostname`" 
     return `$false 
    }" 

    Write-Verbose $cmdBlock 
    $scriptBlock = $ExecutionContext.InvokeCommand.NewScriptBlock($cmdBlock) 
    try { 
     Write-Verbose "Creating new NLB Cluster" 
     Invoke-Command -ComputerName $clusterHostName -ScriptBlock $scriptBlock -HideComputerName -Authentication Credssp -Credential (Get-PSCredential -userName $userName -Password $password) 
    } 
    catch { 
     Write-Verbose $_ 
     return $false 
    } 
} 
+0

음, 좋은 시도! 호출하는 메소드에 대해 다른 시스템에 대해 알았습니다. 부모 호출자는 계속 얘기 할 모든 시스템을 알아야하므로 클러스터의 다른 모든 노드 목록이 필요합니다 (유지해야합니다). –

관련 문제