zoukankan      html  css  js  c++  java
  • Create Windows Server 2008 cluster from the command line

    How to create a Windows Server 2008 cluster from the command line?

    Creating a cluster in Server 2008 using the cluster.exe command follows essentially the same process as creating a cluster by using the Microsoft Management Console (MMC) Failover Cluster Management snap-in. The process essentially consists of telling the Create Cluster Wizard the nodes that will be in the cluster and then the network name and static IP address (if dynamic IP isn’t used on the NICs).

    Before you attempt to create a Server 2008 cluster, you need to install the Server 2008 Failover Clustering feature. If you’re running Server Core, you’d use the following command to install failover clustering:

    start /w ocsetup FailoverCluster-Core

    On a full Server 2008 installation, you can install failover clustering by running this command:

    servermanagercmd -install Failover-Clustering

    (Of course, you can also use the MMC Server Manager snap-in to install features, but here we’re concentrating on the command line.) To create a Server 2008 cluster from the command line, run cluster.exe using the following format:

    cluster /cluster: /create /nodes:" " /ipaddress: / 

    Here’s a cluster.exe command example and its ouput:

    C:>cluster /cluster:savdalclusfs01 /create /nodes:"savdalclus01 savdalclus02" /ipaddress:192.168.1.105/255.255.255.0

    4% Initializing Cluster savdalclusfs01.
    9% Validating cluster state on node savdalclus01.
    13% Searching the domain for computer object savdalclusfs01
    18% Verifying computer object savdalclusfs01 in the domain
    22% Configuring computer object savdalclusfs01 as cluster name object
    27% Validating installation of the Microsoft Failover Cluster Virtual Adapter o
    n node savdalclus01.
    31% Validating installation of the Cluster Disk Driver on node savdalclus01.
    36% Configuring Cluster Service on node savdalclus01.
    40% Validating installation of the Microsoft Failover Cluster Virtual Adapter o
    n node savdalclus02.
    45% Validating installation of the Cluster Disk Driver on node savdalclus02.
    50% Configuring Cluster Service on node savdalclus02.
    54% Starting Cluster Service on node savdalclus01.
    54% Starting Cluster Service on node savdalclus02.
    59% Forming cluster savdalclusfs01.
    63% Adding cluster common properties to savdalclusfs01.
    68% Creating resource types on cluster savdalclusfs01.
    72% Creating group 'Cluster Group'.
    72% Creating group 'Available Storage'.
    77% Creating IP Address resource 'Cluster IP Address'.
    81% Creating Network Name resource 'savdalclusfs01'.
    86% Searching the domain for computer object savdalclusfs01
    90% Verifying computer object savdalclusfs01 in the domain
    95% Configuring computer object savdalclusfs01 as cluster name object
    100% Bringing resource group 'Cluster Group' online.

    When you create a cluster at the command line, disk resources are not added automatically and Node Majority will be used as the quorum mode.

    How to add disk resources to a Windows Server 2008 cluster from the command line?
    To add a disk resource, you must first create a resource group for the disk, then add the disk into the new resource group. As you can see in the following sample command, which creates a resource group, I've called my resource Quorum Disk (you can name the new resource whatever you want), and I've added the resource to available storage group.

    C:>cluster res "Quorum Disk" /create /group:"Available Storage" /type:"Physical Disk"

    Here’s the command’s output:
    Creating resource 'Quorum Disk'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    Quorum Disk          Available Storage    savdalclus01    Offline

    The next step is to add one or more disks. Before you do so, you’ll need the disk ID, which you can obtain by using the DiskPart tool, as follows:

    C:>diskpart

    You’ll see the following command output and prompts to enter commands (list disk, select disk, and detail disk).

    Microsoft DiskPart version 6.0.6001
    Copyright (C) 1999-2007 Microsoft Corporation.
    On computer: SAVDALCLUS01

    DISKPART> list disk
    Disk ### Status     Size    Free    Dyn Gpt
    -------- ---------- ------- ------- --- ---
    Disk 0   Online     127 GB  0       B
    Disk 1   Offline    512 MB  0       B
    Disk 2   Offline    20 GB   0       B

    DISKPART> select disk 1
    Disk 1 is now the selected disk.

    DISKPART> detail disk

    ROCKET IMAGEFILE SCSI Disk Device
    Disk ID: DB2875A4
    Type : iSCSI
    Bus : 0
    Target : 1
    LUN ID : 0
    Read-only : Yes
    Boot Disk : No
    Pagefile Disk : No
    Hibernation File Disk : No
    Crashdump Disk : No

    There are no volumes.

    You can now add a disk by running cluster.exe and specifying either the disk’s GUID (/priv DiskIDGuid) or its signature (/priv DiskSignature), then bring it online. The previous command output shows the signature—DB2875A4—in hexadecimal (a number means that it’s the signature that’s displayed and not the GUID). You’ll need to convert the hex value to a decimal value for use in the cluster.exe command, as follows:

    C:>cluster res "Quorum Disk" /priv DiskSignature=3676861860

    Now, to bring the disk online, enter this:

    C:>cluster res "Quorum Disk" /on

    You’ll see this output:   
    Bringing resource 'Quorum Disk' online...
    Resource             Group                Node            Status 
    -------------------- -------------------- --------------- ------
    Quorum Disk          Available Storage    savdalclus01    Online

    The disk will now be available in the available storage area of the Microsoft Management Console (MMC) Failover Cluster Management snap-in and via the cluster res command.

    How to change a Windows Server 2008 cluster quorum from the command line?
    You can use the cluster.exe command to change a cluster’s quorum mode. To view the existing quorum mode for a cluster, you use the following command (in the format cluster cluster name /quorum), as follows:

    C:>cluster savdalclusfs01 /quorum

    You’ll get this output:
    Witness Resource Name Path                                       Type
    --------------------- --------------------------------------------------
    (Node Majority)
    Majority


    To change the quorum mode, you add a resource for the type of quorum mode you want—for example, a file-share witness—as follows. (Both the commands you enter and their output are shown.)

    C:>cluster /cluster:savdalclusfs01 res "File Share Witness" /create /group:"Cluster Group" /type:"File Share Witness" /priv SharePath=\savdaldc02fsw

    Creating resource 'File Share Witness'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    File Share Witness   Cluster Group        savdalclus01    Offline


    C:>cluster /cluster:savdalclusfs01 res "File Share Witness" /online

    Bringing resource 'File Share Witness' online...

    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    File Share Witness   Cluster Group        savdalclus01    Online

    C:>cluster savdalclusfs01 /quorum:"File Share Witness"

    Witness Resource Name Path                                       Type
    --------------------- --------------------------------------------------
    File Share Witness
    Majority

    Notice we add the file share as a resource, bring the new resource online, then tell the cluster to use that resource for the quorum. Unlike the procedure for changing the cluster quorum via the Microsoft Management Console (MMC) Failover Cluster Management snap-in, you must give the cluster computer object, and not the administrator, full control on the share. That is, for my cluster I must add account savdalclusfs01$ with full control to the share fsw on server savdaldc02.

    To change quorum to a disk witness, you need to move a disk resource into the cluster group, like this:

    C:>cluster res "Quorum Disk" /move:"Cluster Group"

    Moving resource 'Quorum Disk' to group 'Cluster Group'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    Quorum Disk          Cluster Group        savdalclus01    Online

    Now you need to tell the cluster to use the disk for the quorum:

    C:>cluster /quorum:"Quorum Disk"
    Witness Resource Name Path                                          Type
    --------------------- -----------------------------------------------------
    Quorum Disk           F:Cluster
    Majority

    Note that if you add /disk to the end of the command, you tell the cluster to use disk only and not Node and Disk Majority (the normal mode).

    C:>cluster /quorum:"Quorum Disk" /disk

    Quorum Resource Name Path                           Type
    -------------------- ------------------------------ --------
    Quorum Disk          F:Cluster                    No Majority--Disk
    Only

    You can switch to Node Majority only by running the following command:

    C:>cluster /quorum /node

    Witness Resource Name Path                                       Type
    --------------------- --------------------------------------------------
    (Node Majority)
    Majority


    How 
    to move the default Cluster Group in Windows Server 2008?
    Microsoft simplified Server 2008 clustering and removed certain features that it deemed nonessential for everyday cluster management, among them the Cluster Group. The Cluster Group should only have three resources in it: the cluster IP address, cluster name, and the witness resources; nothing else should ever be in this group, so it isn’t a feature that administrators typically use.

    You can find the Cluster Group’s current location by using either the Microsoft Management Console (MMC) Failover Cluster Management snap-in or the cluster . group command); however, you can move the Cluster Group only by using the command, not the snap-in. In the following command example, I’m moving the group to the savdalclus02 node. Note that if you have only a two-node cluster, you can just use /move without a node name; in that case, the command will simply move the cluster group to the other node in the cluster. (I use the period to show that we’re modifying the local cluster.)

    C:>cluster . group "Cluster Group" /move:savdalclus02

    Moving resource group 'Cluster Group'...

    Group                Node            Status
    -------------------- --------------- ------
    Cluster Group        savdalclus02    Online

    How to create a new Windows Server 2008 cluster resource group from the command line?
    You should never add any resources to the default Cluster Group. Instead, you should create resource groups that you want to use to host resources. When you add a new resource group, at minimum it needs an IP address, a network name, and an instance of a resource type (e.g., file server). Let’s create a new group and a file server resource within it. Note that I use the period (.) to show that we’re modifying the local cluster.

    C:>cluster . group "file server" /create

    Creating resource group 'file server'...
    Group                Node            Status
    -------------------- --------------- ------
    file server          savdalclus01    Offline

    C:>cluster . res "File Server" /create /group:"file server" /type:"File Server"

    Creating resource 'File Server'...

    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    File Server          file server          savdalclus01    Offline

    You can use the cluster restype command to display a full list of resource types, as follows:

    C:>cluster restype

    Listing all available resource types:

    Display Name                         Resource Type Name
    ------------------------------------------------------------------------
    DHCP Service                         DHCP Service
    Distributed File System              Distributed File System
    Distributed Transaction Coordinator  Distributed Transaction Coordinator
    File Server                          File Server
    File Share Quorum Witness            File Share Witness
    Generic Application                  Generic Application
    Generic Script                       Generic Script
    Generic Service                      Generic Service
    IP Address                           IP Address
    IPv6 Address                         IPv6 Address
    IPv6 Tunnel Address                  IPv6 Tunnel Address
    iSNSClusRes                          Microsoft iSNS
    (Resource Type Unavailable)          MSMQ
    (Resource Type Unavailable)          MSMQTriggers
    Network Name                         Network Name
    NFS Share                            NFS Share
    Physical Disk                        Physical Disk
    Print Spooler                        Print Spooler
    Volume Shadow Copy Service Task      Volume Shadow Copy Service Task
    WINS Service                         WINS Service

    Now you add the IP address and network name. Note that I created an IPv4 address, but you can also add an IPv6 address if you’re using IPv6.

    C:>cluster . res "FS IP Address" /create /group:"file server" /type:"IP Address" /priv address=192.168.1.106 subnetmask=255.255.255.0

    Creating resource 'FS IP Address'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    FS IP Address        file server          savdalclus01    Offline

    C:>cluster . res "FS Name" /create /group:"file server" /type:"Network Name" /priv name="savdalclusfsfs01" dnsname="savdalclusfsfs01"

    Creating resource 'FS Name'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    FS Name              file server          savdalclus01    Offline

    Now you need to create a dependency between the IP address and the name, like this:

    C:>cluster . res "FS Name" /adddep:"FS IP Address"

    Making resource 'FS Name' depend on resource 'FS IP Address'...

    C:>cluster . res "FS Name" /listdep

    Listing resource dependency expression for 'FS Name':
    ----------------------------------------------------------------
    ([FS IP Address])

    Listing resource dependencies for 'FS Name':

    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    FS IP Address        file server          savdalclus02    Online

    We can now bring the resources online by using the cluster .res "resource name" /on command.

    For most resource group types, you also need some shared storage to actually do anything useful. So let’s move some available storage into the new resource group:

    C:>cluster res "Data Disk" /move:"file server"

    Moving resource 'Data Disk' to group 'file server'...
    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    Data Disk            file server          savdalclus01    Online

    Now you set the network name and the storage as dependencies for the resource group to be online, like this:

    C:>cluster . res "file server" /adddep:"FS Name"

    Making resource 'file server' depend on resource 'FS Name'...

    C:>cluster . res "file server" /adddep:"Data Disk"

    Making resource 'file server' depend on resource 'Data Disk'...

    C:>cluster . res "file server" /listdep

    Listing resource dependency expression for 'file server':

    ----------------------------------------------------------------

    ([Data Disk]) and ([FS Name])

    Listing resource dependencies for 'file server':

    Resource             Group                Node            Status
    -------------------- -------------------- --------------- ------
    Data Disk            file server          savdalclus01    Online
    FS Name             file server          savdalclus01    Online

    You can bring up the resource group by using the cluster .group group name /on command. Finally, you can actually add items to the resource group as you’d do with a share using typical methods, for example

    net share data=e:data /remark:"Data Share"v

  • 相关阅读:
    什么,你还不会Mysql主从复制???快来看
    MySQL二进制安装(版本:5.7.26)
    MySQL--备份恢复【Mysqdump+xtrabackup(XBK)】
    Mysql日志分析(错误日志,Binlog日志,慢日志),有惊喜哦
    Mysql多实例启动
    Zabbix服务自定义监控和模板
    Centos7安装Zabbix服务端、Zabbix客户端和Win客户端配置(源码编译安装)
    运维工作经验汇总---------高级运维工程师
    手误【删库】 == 跑路,不存在的 ——删瓦辛格
    python——map()函数
  • 原文地址:https://www.cnblogs.com/oskb/p/3529599.html
Copyright © 2011-2022 走看看