Introduction to Microsoft Cluster Services (MSCS) in the Windows Server 2003 family

Source: Internet
Author: User
Tags addgroup failover

Brief Introduction

In any case, it is not enough to deliver a high-quality application that has a rich set of features, and it must meet high availability standards more and more. Do you not raise your application to another level because clustering technology looks too sophisticated, difficult to understand, and uses. As Microsoft's Cluster service is introduced in Windows NT™4 and is officially available in the Windows Server 2003 family, developers can use simple tools to deploy applications in a clustered environment. These tools can register applications in a cluster as generic applications, and can control the configuration of applications by writing Windows scripts.

A cluster connects two or more servers together so that it renders the client as a single computer. Connecting to a server in a cluster can share workloads, achieve a single point of operation/management, and provide a way to adjust the growth requirements accordingly. Therefore, you can create applications with high availability through clustering.

This article focuses on one of the three cluster-supported Microsoft server technologies: the Cluster service. We'll show you how to easily perform performance checks on an application in a clustered environment without changing the application code.

three species set technique

The Microsoft server provides three clustering-enabled technologies: Network Load Balancing (NLB), Component load Balancing (CLB), and Microsoft Cluster Service (MSCS).

Network Load Balancing

Network Load Balancing, which serves as a front-end cluster for allocating incoming IP traffic across a server cluster, is an ideal choice for incremental scalability and excellent availability for e-commerce Web sites. You can connect up to 32 computers running the Windows Server 2003 series to share a virtual IP address. NLB enhances scalability by assigning its client requests across multiple servers within the cluster. As traffic increases, you can add more servers to the cluster, and any cluster can hold up to 32 servers. NLB provides a continuous service to users while also providing high availability, that is, automatically detect server failures and reallocate client traffic in the remaining servers within 10 seconds.

Component Load Balancing

Component load Balancing can distribute the load between multiple servers running the site's business logic. It implements a dynamic balance of COM + components in a server cluster that contains up to eight identical servers. In CLB, the COM + component is located on a server in a separate COM + cluster. A call to activate a COM + component is a load that balances the different servers in the COM + cluster. CLB works with NLB and the Cluster service through a middle tier that functions on a multi-tiered cluster network. CLB is provided as a feature of application Center 2000 and can be run on the same set of computers as Microsoft Cluster service.

Cluster Service

The Cluster service acts as a back-end cluster, providing high availability for applications such as databases, messaging, and file and print services. When any node (the server in the cluster) fails or goes offline, MSCS tries to minimize the impact of the failure on the system.

Figure 1. Three cluster-supported Microsoft server technologies
failover via Microsoft Cluster service

The MSCS failover function is implemented through redundancy in multiple computers connected to a cluster, each with a separate fault state. To achieve redundancy, you need to install applications on multiple servers in the cluster. However, at any one time, the application is online only on one node. When the application fails or the server is down, the application restarts on another node. Windows Server 2003 Data Center Edition supports up to 8 nodes in a cluster.

Each node has its own memory, system disk, operating system, and a subset of the cluster resources. If one node fails, another node takes over the resource of the failed node (this process is known as "failover"). Microsoft Cluster service then registers the network address of the resource on the new node to route client traffic to the available system that currently owns the resource. When a failed resource is brought back online, MSCS can be configured to reallocate resources and client requests appropriately (this process is known as "failback"). For the application to revert to the point at which failover occurred, the node must have access to the shared store that holds the application state.

Note that the Microsoft Cluster service is designed to provide high availability rather than true fault tolerance. The term "fault tolerance" is often used to describe techniques that provide a higher level of recovery functionality. Fault-tolerant servers typically use advanced hardware or data redundancy that combines specific software to provide almost instantaneous recovery from a single hardware or software failure. This type of solution costs far more than a clustered solution because you have to buy redundant hardware, and redundant hardware is simply idle there for recovery. Microsoft Cluster service uses affordable standard hardware to provide excellent high-availability solutions while maximizing the use of computing resources.

The Microsoft Cluster service is based on a cluster model that is not shared. No shared model stipulates that although multiple nodes in a cluster can access a device or resource, the resource can only be occupied and managed by one system at a time. (In an MSCS cluster, a resource is any physical component or logical component that can be brought online or taken offline, managed in a cluster, and can be hosted at one time and moved between nodes.) )

Figure 2. Microsoft Cluster Service
Cluster Service Structure

Microsoft Cluster service consists of three major components: Cluster service, Resource Monitor, and resource DLL. In addition, you can use Cluster Administrator to create extension DLLs that provide administrative functionality.

Cluster Service

The Cluster service is the core component and runs as a high-priority system service. The Cluster service controls cluster activity and performs the following tasks: Reconciling event notifications, speeding up communication between cluster components, handling failover operations, and managing configurations. Each cluster node runs its own cluster service.

Resource Monitor

The Resource monitor is the interface between the Cluster service and the cluster resources and runs as a stand-alone process. The Cluster service uses Resource Monitor to communicate with the resource DLL. The DLL handles all communication with the resource, so the DLL can protect the Cluster service from resources that are not running or stopped working, with Resource Monitor as the host. Multiple copies of a resource monitor can be run on a single node so that unpredictable resources can be isolated from other resources.

The Cluster service sends requests to the resource Monitor assigned to the resource when it needs to perform operations on the resource. If there are no DLLs in the Resource Monitor's process that can handle the type of resource, the DLL associated with the resource type is loaded with the registration information. The request for the Cluster service is then passed to the entry point function of one of the DLLs. The resource DLL handles the details of the operation to meet the specific needs of the resource.

Resource DLL

The third key Microsoft Cluster service component is the resource DLL. Resource monitors and resource DLLs communicate using the resource APIs. A resource API is a collection of entry points, callback functions, and related structures and macros that are used to manage resources.

For cluster services, resources are any physical or logical component that can be managed, such as disks, network names, IP addresses, databases, Web sites, applications, and any other entities that can be brought online and offline. Resources can be organized by type. Resource types include physical hardware (such as disk drives) and logical items (such as IP addresses, file shares, and generic applications).

Each resource uses a resource DLL, which is primarily a passive transition layer between the Resource monitor and the resource. Resource Monitor calls the resource DLL's entry point function to view the state of the resource, bringing the resource online and offline. The resource DLL is responsible for communicating with its resources through any convenient IPC mechanism to implement these methods.

Applications that implement their own resource DLLs to communicate with the Cluster service and applications that use the cluster APIs to request and update cluster information are defined as cluster-aware applications. Applications and services that do not use the cluster or resource APIs, as well as cluster control code functions, do not recognize the cluster and do not know that the Cluster service is running. These cluster-unaware applications are typically managed as generic applications or services.

Cluster-aware and cluster-aware applications can run on cluster nodes and can be managed as cluster resources. However, only cluster-aware applications can take advantage of the functionality that the Cluster service provides through the cluster APIs. Developing a cluster-aware application requires establishing a custom resource type. By customizing the resource types, developers can respond and take the necessary action when their applications occur within the cluster, such as when the node is about to go offline, and therefore close the database connection.

For most applications that need to run in a cluster, it is a good idea to devote some time and resources to developing custom resource types. However, you can test your application in a clustered environment without having to modify the application's code or create a new resource type. In the Windows Server 2003 series, an unmodified application can run as a basic level as an "cluster-unaware" application. Cluster service provides a generic application resource type for this purpose.

Cluster Administrator extension DLL

The Cluster Administrator extension DLL provides application-specific administrative functionality within Cluster Administrator, allowing users to manage their applications in the same way, whether the application is running within the cluster or outside the cluster. Developers can provide application management functionality within the framework of Cluster Administrator, or simply link these features to existing administrative tools.

Developers can extend the functionality of the Cluster Administrator by writing extension DLLs. The Cluster Administrator application communicates with an extension DLL through a set of defined COM interfaces. An extension DLL must implement a specific set of interfaces and register on each node of the cluster.

Figure 3. Key components: Cluster service, Resource Monitor, and resource DLL
applications that do not recognize the cluster

Applications or services that do not provide their own resource DLLs can still be configured in a clustered environment. The Cluster service in the Windows Server 2003 family includes generic resource DLLs for this purpose only: Generic Application resource DLLs and Generic Service resource DLLs. The Cluster service sees these applications or services as generic applications or services that do not recognize the cluster.

Generic resource DLLs provide only the most basic control. For example, the generic Application resource DLL checks the application for failure by determining whether the application's process is still present and takes the application offline by terminating the process. But instead of relying on other resources, it provides a simple way to test your application in a clustered environment.
High Availability Notepad

Not all applications can work efficiently in a cluster. The most effective way to evaluate this is to actually deploy the application in the cluster. The simplest mechanism for performing initial testing is to enlist an application into a cluster using the built-in Generic Application resource type. The Generic application resource type is provided as part of the Cluster service in the Windows Server 2003 series and can be viewed by viewing the Cluster Administrator (Cluster Administrator) tool The Resource Types (resource Type) node under Cluster Configuration (cluster configuration) looks at the type and other built-in resource types (see Figure 4).

Figure 4. Resource type node in Cluster Administrator tool

The Cluster Administrator has an interactive wizard that enables you to create resources for any of the resource types listed. The Cluster service also provides a COM interface that enables you to create and manage resources programmatically.

Note The latest Cluster Administrator tools and associated development resources are available from the Platform SDK.

Cluster Automation server

The Cluster Automation server provides a set of automation objects to expose a complete cluster management interface to the scripting language, enabling you to develop web-based remote administration tools. The cluster Automation server simplifies and enhances the process of creating a cluster management application.

The nature of the cluster Automation server is object-oriented, which means that almost all cluster programming tasks involve the following steps:

Determine the cluster operations that need to be performed.

Finds a cluster Automation server object with a property or method to complete the operation.

Determines how to get the object in step 2. The object hierarchy provided in MSDN® can be used for this purpose.

Gets the object and invokes the property or method.

For illustration purposes, we will use Windows scripting Host and Microsoft VBScript to programmatically create generic application resources.

Cluster Objects

The cluster object is a top-level object that allows a new instance to be created. The ProgID of the cluster object is "Mscluster." CLUSTER ":

    Set Ocluster = CreateObject ("Mscluster.cluster")

Open Cluster

Before you can use any of the methods on a cluster, you must first open a connection to that cluster. The Open method can open a connection to a cluster. The empty string ("") is passed as a parameter to the open method to open the connection to the cluster on the localhost. The script will run on the local host server:

    Ocluster.open ("")

creating Groups

A cluster group is a container for cluster resources. When one of the resources in a group fails and the resource must be transferred to another node, all resources in that group are moved. The group also defines a dependency boundary. A resource can only establish a dependency on another resource, provided that the resource is in the same group. To test, we will create a unique group called High Availability Notepad (high-availability Notepad):

    Set ogroup = OCluster.ResourceGroups.CreateItem ("High Availability
      Notepad")

Create a resource

Each group contains a collection of resources. The CreateItem method creates a new resource and adds it to the group's collection. In this example, we will create a resource named "Notepad" with the resource type "Generic application":

    Set Oresource = Ogroupresources.createitem ("Notepad", "Generic 
      Application", 0)

Set resource Properties

Each generic Application resource has two basic properties to bring the resource online: CommandLine and CurrentDirectory. CommandLine contains the commands to execute when the resource is online, and currentdirectory specifies the file system directory from which to execute the command. When this script executes a statement to bring the resource online, Notepad starts. To see Notepad, we also need to set the InteractWithDesktop property to 1.

    Set oproperties = Oresource.privateproperties

    ' Set the properties of the Generic application
    oproperties.item (" CommandLine ") =" Notepad " 
    oproperties.item (" currentdirectory ") =" C:\ "
    oProperties.Item (" InteractWithDesktop ") = 1

    oproperties.savechanges

Bring resources online

The online method brings the resource online. Online is a state that describes the resources available to the cluster. For a generic application, bringing the resource online means starting Notepad.

    Oresource.online 10

complete list of scripts

Option Explicit Main ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' Main subroutine.
    "" "" "" "" "" "" "" "" "" "" "" "" "" "
    Dim Oresource ' Create the Cluster object. Set Ocluster = CreateObject ("Mscluster.cluster") ' Open ' Cluster.
    Empty string means open the local cluster.
    Ocluster.open ("") ' Create or Open ' group.
    AddGroup ocluster, ogroup ' Create or open the resource.
    AddResource ogroup, Oresource ' Bring ' resource online and wait for up to ten seconds ' for it to come online. Oresource.online "" "" "" "" "" "" "" "" "" "" "" "" "' ' ' ', ' ' ', ', ', ', ', ', ', ' this subroutine
Would create or open the group. "" "" "" "" "" "" "" "" "" "" "" "" "" ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ', ' ' ' addgroup ', Ocluster, ogroup) Set ogroup = OC Luster. Resourcegroups.createitem ("High Availability NotepaD "" "" "" "" "" "", "" "" "," "" "" "" ' ', ' ' ', ' ', ' ', ' ', ', ', ', ' This subroutine ' Resour
Ce to the group. "" "" "" "" "" "" "" "" "" "" "" "" "" ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ', ' ' ' AddResource ', Ogroup, Oresource) Dim ogroup Resources Dim Oproperties Dim Oclproperty Dim ocdpropery Set ogroupresources = Ogroup.resources set O
    Resource = Ogroupresources.createitem ("Notepad", "Generic Application", 0) ' Cluster_resource_default_monitor Set oproperties = Oresource.privateproperties ' Set the properties of the Generic application oProperties.Item ("C 

    Ommandline ") =" Notepad "oProperties.Item (" currentdirectory ") =" C:\ "oProperties.Item (" interactwithdesktop ") = 1 Oproperties.savechanges end Sub ' ' "'" ' "'" ' "" "" "" "" "" "" "' ' ' ' ', ' ' ', ' ', ', ', ', ', ', '
Specified number of time. "" "" "" "" "" "" "" "" "" "" "" "" "" ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' Sub Sleep (pausetime) Dim StaRT Start = Timer Do While timer < Start + pausetime Loop End Sub
 

By running this simple script, you will create a new "Notepad" resource and put it into its own group ("High Availability Notepad").

Validation Results

We can use Cluster Administrator to verify the results. By looking at the properties of the Notepad resource in Cluster Administrator, you can see that the parameters have been set correctly (see Figure 5).

Figure 5. Notepad Resource Parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.