首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将NLB绑定到接口

将NLB绑定到接口
EN

Stack Overflow用户
提问于 2012-05-22 22:26:32
回答 1查看 644关注 0票数 1

我已经安装并设置了NLB。我像这样获取接口数据:

代码语言:javascript
复制
Get-NlbClusterNodeNetworkInterface



InterfaceName       : quanet
   NlbBound            : False
   Cluster             :
   DhcpEnabled         : False
   InterfaceIP         : 10.165.250.206
   InterfaceSubnetMask : 255.255.0.0
   ClusterPrimaryIP    :
   ClusterSubnetMask   :

   InterfaceName       : cluster
   NlbBound            : False
   Cluster             :
   DhcpEnabled         : False
   InterfaceIP         : 172.16.1.206
   InterfaceSubnetMask : 255.255.255.0
   ClusterPrimaryIP    :
   ClusterSubnetMask   :

我想使用Powershell将NlbBound设置为true。不用说,设置属性是不起作用的。e.g

代码语言:javascript
复制
   $x = Get-NlbClusterNodeNetworkInterface
   $x[1].nlbbound = $true
   $x = Get-NlbClusterNodeNetworkInterface
   echo $x[1].NlbBound
   False

我希望避免在Network adaptor设置中显式设置该属性,因为此功能将存在于脚本中。如果可能的话,我也想避免使用WMI。

根据Get-Member cmdlet,NlbBound属性是可设置的:

代码语言:javascript
复制
Get-Member -InputObject $x[1]

   TypeName: Microsoft.NetworkLoadBalancingClusters.PowerShell.NetworkInterface

Name                MemberType Definition
----                ---------- ----------
Equals              Method     bool Equals(System.Object obj)
GetHashCode         Method     int GetHashCode()
GetType             Method     type GetType()
ToString            Method     string ToString()
Cluster             Property   System.String Cluster {get;set;}
ClusterPrimaryIP    Property   System.String ClusterPrimaryIP {get;set;}
ClusterSubnetMask   Property   System.String ClusterSubnetMask {get;set;}
DhcpEnabled         Property   System.Boolean DhcpEnabled {get;set;}
InterfaceIP         Property   System.String InterfaceIP {get;set;}
InterfaceName       Property   System.String InterfaceName {get;set;}
InterfaceSubnetMask Property   System.String InterfaceSubnetMask {get;set;}
NlbBound            Property   **System.Boolean NlbBound {get;set;}**
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-28 18:30:45

代码语言:javascript
复制
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
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10704075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档