加入现有的 NLB 集群 [英] Joining an existing NLB cluster

查看:67
本文介绍了加入现有的 NLB 集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试编写一个 powershell 程序来检查集群是否存在.如果没有,那么它会创建它并将自己添加到它.如果另一台计算机唤醒,它会检查集群是否存在,如果存在,则将自己添加到集群中.

I have been trying to write a powershell program that checks to see if a cluster exists. If it doesn't then it creates it and adds itself to it. If another computer wakes up, it checks to see if the cluster exists and if it does, then it adds itself to the cluster.

我在尝试从集群 IP 地址获取对集群对象的引用时遇到问题.每个节点都知道它的地址和集群地址.我想避免每个节点都有其集群中所有其他节点的列表.

I'm having trouble trying to get a reference to the cluster object from the cluster ip address. Every node knows its address and the cluster address. I want to avoid every node having a list of all the other nodes in its cluster.

我发现我需要查看非集群 IP 地址才能让-nlbcluster 工作.指定集群IP地址只是错误.

I'm finding that I need to sight the non-cluster ip address to get-nlbcluster to work. Specifying the cluster ip address just errors.

有什么办法可以做到这一点,而不必每次在集群中添加或删除节点时都在每个节点上更新此列表.我想我还想避免节点唤醒并且必须轮询主"列表中的每台机器以查找已启动的机器以便将自己添加到集群的情况.

Is there any way I can do this, without having to update this list on every node each time I add or remove nodes from the cluster. I suppose I also want to avoid the situation where a node wakes up and has to poll each of the machines in the "master" list looking for one that is up in order to add itself to the cluster.

推荐答案

下面的脚本可以在你集群的所有节点上运行,如果集群不存在就创建它,否则只需将当前计算机添加到现有的簇.您需要做的就是确保集群中的所有计算机都有一个同名的专用卡.在下面的例子中,网卡被命名为NLB".

The following script can be run on all nodes in your cluster, if the cluster doesn't exist then create it, otherwise just add the current computer to the existing cluster. All you need to do is ensure that all your computers in the cluster have a dedicated card with the same name. In the example below the network card is named '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
}

这篇关于加入现有的 NLB 集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆