Introduction to Microsoft cluster service (MSC)

Source: Internet
Author: User
Tags addgroup failover

Introduction
In any case, it is not enough to deliver a high-quality application with a rich set of features. In more and more cases, it must meet high availability standards. Are you
Why does cluster technology seem too advanced, difficult to understand and use without increasing the application layer? With Microsoft's cluster service in Windows NT? 4
Introduced in Windows Server 2003
The series is officially provided. developers can use some simple tools to deploy applications in the cluster environment. These tools can register applications in the cluster as general applications and
Windows Script to control application configurations.
The cluster connects two or more servers to present them to a single computer on the client. Connecting to the server in a group can share the workload and achieve single-point operations/management, and provide a way to meet the increasing needs for corresponding adjustments. Therefore, clusters can generate highly available applications.
This article focuses on one of the three Microsoft server technologies that support clusters: cluster service. We will explain how to easily perform performance checks on applications in a cluster environment without changing the application code.
Three cluster technologies
Microsoft Server provides three clustering technologies: network load balancing (NLB), Component Load Balancing (CLB), and Microsoft cluster service (MSC ).
Network Load Balancing
Network
Server Load balancer acts as a front-end cluster to distribute incoming IP traffic in the entire server group. It is an ideal choice for e-commerce web sites to achieve incremental scalability and outstanding availability.
You can connect up to 32 computers running Windows Server 2003 series to share a virtual IP address. NLB
The scalability is enhanced by allocating client requests among multiple servers in the cluster. As traffic increases, you can add more servers to the cluster. Any cluster can accommodate up to 32
Servers. While providing continuous services to users, NLB also provides high availability, that is, it automatically detects server faults and re-allocates client traffic to other servers within 10 seconds.
Component Load Balancing
Group
Server Load balancer distributes loads among servers running the business logic of multiple sites. It dynamically balances COM + components in a server group containing up to eight equivalent servers. In CLB
The COM + component is located on a server in a separate COM + cluster. The call to activate the COM + component balances the load on different servers in the COM + cluster. CLB
It works with NLB and cluster services through the intermediate layer acting on the multi-layer cluster network. CLB is used as application center 2000
Which can run on the same group of computers as Microsoft cluster services.
Cluster Service
The cluster Service acts as a backend cluster and provides high availability for applications such as databases, message passing, and file and print services. When any node (the server in the cluster) fails or is offline, the MSC attempts to minimize the impact of the fault on the system.

 

Figure 1. Three Microsoft server technologies supporting clusters

Failover through Microsoft cluster service
MSC
The failover function is implemented through redundancy among multiple computers connected in a group. Each computer has an independent fault state. To achieve redundancy, you need to install applications on multiple servers in the cluster. However
At any time, the application is online on only one node. When the application fails or the server is down, the application restarts on another node. Windows
Server 2003 data center edition supports a maximum of eight nodes in a group.
Each node has its own memory, system disk, operating system, and a subset of cluster resources. For example
If a node fails, the other node will take over the resources of the faulty node (this process is called "failover "). Then, Microsoft
The cluster service registers the network address of the resource on the new node to route the client traffic to the available system with the resource. When the faulty resource is back online
You can configure to allocate resources and client requests as appropriate (this process is called "fault recovery "). To restore the application to the point where failover occurs, the node must be able to access the common
Exclusive storage zone.
Note that Microsoft
The cluster service is designed to provide high availability rather than true fault tolerance. The word "Fault Tolerance" is generally used to describe technologies that provide higher-level recovery capabilities. Fault Tolerant servers usually use advanced hardware or
Data redundancy provides near-instantaneous recovery from a single hardware or software fault. This type of solution costs much higher than the cluster solution because you have to purchase redundant hardware, which is only idle
Fault recovery. The Microsoft cluster service uses affordable standard hardware to provide outstanding high availability solutions while maximizing the use of computing resources.
Microsoft
The cluster service is based on the non-shared cluster model. No shared model stipulates that although multiple nodes in the cluster can access devices or resources, the resources can only be occupied and managed by one system at a time. (In
MSC group, A resource is a physical or logical component that can be online or offline, managed in a group, and can only be hosted by one node at a time and moved between nodes .)

 

Figure 2. Microsoft cluster service

Cluster service structure
The Microsoft cluster service consists of three main components: cluster service, Resource Monitor, and resource DLL. You can also use the Cluster Manager to create an extended DLL that provides management functions.
Cluster Service
The cluster service is a core component and runs as a high-priority system service. The cluster service controls cluster activities and executes the following tasks: Coordinating Event Notifications, accelerating communication between cluster components, handling failover operations, and managing configurations. Each cluster node runs its own cluster service.
Resource Monitor
Capital
The source monitor is an interface between the cluster service and cluster resources and runs as an independent process. The cluster Service uses the resource monitor to communicate with the resource DLL. Dll processes all communications with resources, so
DLL
Using resource monitor as the host can protect cluster services from the impact of abnormal or stopped resources. Multiple copies of the Resource Monitor can run on a single node, so that unpredictable resources and
Other resources are isolated.
When you need to perform operations on a resource, the cluster service sends a request to the resource monitor that is allocated to the resource. If the process of the Resource Monitor does not support processing resources of this type
DLL, then use the registration information to load the DLL associated with the resource type. Then, pass the cluster service request to the entry point function of one of the DLL. Resource DLL
The operation details are processed to meet the specific resource needs.
Resource DLL
The third key Microsoft cluster service component is resource DLL. Resource Monitor and resource DLL use resource API for communication. Resource API is a collection of entry points, callback functions, related structures, and macros used to manage resources.
Pair
For the cluster service, resources are any physical or logical components that can be managed, such as disks, network names, IP addresses, databases, and Web
Websites, applications, and any other entities that can be online or offline. Resources can be organized by type. Resource types include physical hardware (such as disk drives) and logical items (such as IP
Address, file sharing, and general applications ).
Every resource uses resource DLL, which is a passive conversion layer between resource monitor and resource. The Resource Monitor calls the resource DLL entry point function to view the resource status and bring the resource online and offline. Resource DLL is responsible for communicating with resources through any convenient IPC Mechanism to implement these methods.
Real
The applications whose resource DLL communicates with the cluster service and the applications that request and update cluster information using the cluster API are defined as the application that recognizes the cluster. Do not use clusters or resources
The application and service of APIs and cluster control code functions do not recognize the cluster, nor do they know that the cluster service is running. Applications that do not recognize clusters are generally managed as common applications or services.
Knowledge
Applications of other clusters and applications that do not recognize clusters can run on cluster nodes and can be managed as cluster resources. However, only the application that identifies the cluster can use the cluster service to pass the Cluster
Set API
Provided functions. To develop an application that identifies a cluster, you must create a custom resource type. By customizing the resource type, developers can make their applications have various events in the cluster (for example, the node is about to be offline,
Will close the database connection), make a response and take necessary measures.
For most applications that need to be run in a group, it is best to invest some time and resources to develop custom resource types. No
You can test the application in the cluster environment without modifying the application code or creating a new resource type. In Windows Server 2003
In the series, unmodified applications can run as "Unrecognized cluster" applications at the basic level. The cluster service provides general application resource types for this purpose.
Cluster Manager extension DLL
The Cluster Manager extension DLL provides application-specific management functions in the Cluster Manager, allowing users to manage their applications in the same way, whether the application is running inside the cluster or outside the cluster. Developers can provide application management functions within the framework of Cluster Manager, or simply link these functions to existing management tools.
Developers can compile extended DLL to extend the functions of the Cluster Manager. The Cluster Manager application communicates with the extended DLL through a set of defined com interfaces. The extension DLL must implement a specific set of interfaces and be registered on each node of the cluster.

 

Figure 3. Key components: cluster service, Resource Monitor, and resource DLL

Application that does not recognize the Cluster
No
Applications or services that provide their own resource dll can still be configured in the cluster environment. Windows Server 2003
The cluster services in the series include general resource DLL for this purpose only: general application resource DLL and general service resource
DLL. The cluster Service regards these applications or services as general applications or services that do not recognize clusters.
Generally, resource DLL only provides the most basic control. For example, the application resource DLL checks whether the application fails by determining whether the application's process still exists, and takes the application offline by terminating the process. However, it does not depend on other resources, but provides a simple way to test applications in a cluster environment.
High Availability notepad
And
Not all applications can work efficiently in a group. The most effective evaluation method is to deploy applications in the cluster. The simplest mechanism for executing the initial test is to use the built-in general application resource type
Register the application to the cluster. "Generic application" (general application) resource type as Windows Server 2003
Some of the cluster services in the series are provided. You can view the Cluster
The "resource types" (resource type) node under configuration (cluster configuration) can view this type and other built-in resource types (see figure 4 ).

 

Figure 4. Resource Type nodes in the Cluster Manager Tool

The Cluster Manager has an interactive wizard that allows you to create resources for any resource types listed. The cluster Service also provides a COM interface that allows you to create and manage resources programmatically.
Note that the latest Cluster Manager tools and related development resources can be obtained from the platform SDK.
Cluster Automation server
The cluster Automation server provides a set of automation objects to publish a complete cluster management interface to the scripting language, enabling you to develop web-based remote management tools. Cluster Automation Servers simplify and enhance the process of creating cluster management applications.
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 operation to be performed.
Search for cluster Automation server objects with properties or methods to complete the operation.
Determine how to obtain objects in step 2. Msdn? The object hierarchy provided in.
Obtain the object and call properties or methods.
For instructions, we will use Windows Scripting Host and Microsoft VBScript to program the creation of general application resources.
Cluster Object
The Cluster Object is a top-level object that allows you to create a new instance. The Cluster Object's progid is "mscluster. Cluster ":
Set ocluster = Createobject ("mscluster. Cluster ")
Open a cluster
Before using any methods on the cluster, you must first connect to the cluster. The open method can open the connection to the cluster. Pass the Null String ("") as a parameter to the open method to open the connection to the cluster on localhost. The script will run on the local host server:
Ocluster. Open ("")
Create Group
Group
A set group is a container of cluster resources. When a resource in the group fails and must be transferred to another node, all resources in the group will be moved. The Group also defines dependency boundaries. A resource can only be created
Establish dependencies with another resource, provided that the resource is in the same group. To perform the test, we will create a unique group named "High Availability
Notepad "(High Availability notepad ):
Set ogroup = ocluster. resourcegroups. createitem ("High Availability
Notepad ")
Create Resources
Each group contains a resource set. The createitem method creates a new resource and adds it to the set of the group. 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 attributes
Each
Generally, application resources have two basic attributes that can bring resources online: CommandLine and currentdirectory. CommandLine
Contains the command to be executed when the resource is online, while currentdirectory specifies the file system directory from which the command is executed. When the script executes a statement to bring the resource online
Notepad. To view notepad, we also need to set the interactwithdesktop attribute 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
Online method to bring resources online. Online is a state that describes the availability of resources to clusters. For general applications, bringing resources online means starting notepad.
Oresource. Online 10
Complete script list
Option explicit
Main
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''
Main subroutine.
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''
Sub main
Dim ogroup
Dim ocluster
Dim oresource
'Create the Cluster Object.
Set ocluster = Createobject ("mscluster. Cluster ")
'Open the cluster. Empty string means open the local cluster.
Ocluster. Open ("")
'Create or open the group.
Addgroup ocluster, ogroup
'Create or open the resource.
Addresource ogroup, oresource
'Bring the resource online and wait for up to 10 seconds
'For it to come online.
Oresource. Online 10
End sub
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
'This subroutine will create or open the group.
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
Sub addgroup (ocluster, ogroup)
Set ogroup = ocluster. resourcegroups. createitem ("High Availability
Notepad ")
End sub
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
This subroutine will add the resource to the group.
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
Sub addresource (ogroup, oresource)
Dim ogroupresources
Dim oproperties
Dim oclproperty
Dim ocdpropery
Set ogroupresources = ogroup. Resources
Set oresource = ogroupresources. createitem ("Notepad", "Generic
Application ", 0) 'cluster _ resource_default_monitor
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
End sub
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
'Wait for a specified number of time.
'''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
Sub sleep (pausetime)
Dim start
Start = Timer
Do While timer <start + pausetime
Loop
End sub
Run this simple script to create a new "Notepad" resource and put it into its own group ("High Availability Notepad.
Verification Result
We can use the Cluster Manager to verify the results. By viewing the notepad resource attributes in "Cluster Manager", you can see that the parameters have been correctly set (see figure 5 ).

 

Figure 5. notepad resource parameters

Query
On the "advanced" tab, you will see the default properties, indicating that the application can be restarted up to three times in the event of a fault. Looksalive and isalive
By default, the polling interval is a value in the resource type, but other values can be rewritten by specifying other values. Because this application has no special code to make it an application that recognizes a cluster, it only runs through processes running in the system
Determines whether it is active or not.

 

Figure 6. notepad resource "advanced" tab

Test the application
Notepad
After the resources are online, they will be started on the server. If notepad
The process is terminated and starts again immediately. This is because the cluster service plays a role in trying to keep the application open and running. As a general application resource, no matter what time, as long as the application process
If the cluster service is no longer running, the cluster service will immediately notice and take corrective actions based on the policy.
If the application fails, the process will not be terminated (for example, network failure, suspension, or background thread termination ).
). What is the result? Unfortunately, for general application resource types, you can only perform general fault detection. Most developers who write applications that run in a cluster environment tend to generate custom
Resource DLL to handle issues related to the application. If it is not a shortcut for evaluating applications in a group, the application resource type will not be applied.
Conclusion
Microsoft
The cluster service uses standard hardware that is affordable to provide high availability while maximizing the use of computing resources. Windows Server 2003
The cluster service in the series provides powerful tools to make your applications highly available. For some developers, writing an application that identifies a cluster may be costly and difficult.
To enable developers to use clusters with low investment, the cluster service provides a general application resource type that allows simple configuration of applications within the cluster. Although the general application resource type may not
Will provide the complexity required by the production application, but it provides a test method to view the application's execution in the cluster.

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.