2x5 Scalable Cluster Tutorial: Difference between revisions

From Alteeve Wiki
Jump to navigation Jump to search
No edit summary
 
(100 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{howto_header}}
{{howto_header}}


= Overview =


This paper has one goal;
{{warning|1=This document is old, abandoned and very out of date. DON'T USE ANYTHING HERE! Consider it only as historical note taking.}}


* Creating a 2-node, high-availability cluster hosting [[Xen]] virtual machines.
= The Design =


== Technologies We Will Use ==
== Storage ==


We will introduce and use the following technologies:
Storage, high-level:
<source lang="text">
[ Storage Cluster ]                                                     
    _____________________________            _____________________________
  | [ an-node01 ]              |          | [ an-node02 ]              |
  |  _____    _____            |          |            _____    _____  |
  | ( HDD )  ( SSD )            |          |            ( SSD )  ( HDD ) |
  | (_____)  (_____)  __________|          |__________  (_____)  (_____) |
  |    |        |    | Storage  =--\    /--=  Storage |    |        |    |
  |    |        \----| Network ||  |    |  || Network |----/        |    |
  |    \-------------|_________||  |    |  ||_________|-------------/    |
  |_____________________________|  |    |  |_____________________________|
                                  __|_____|__                             
                                |  HDD LUN  |                             
                                |  SDD LUN  |                             
                                |___________|                             
                                      |                                   
                                  _____|_____                           
                                | Floating  |                           
                                |  SAN IP  |                               
[ VM Cluster ]                  |___________|                               
  ______________________________  | | | | |  ______________________________
| [ an-node03 ]                |  | | | | |  |                [ an-node06 ] |
|  _________                  |  | | | | |  |                  _________  |
| | [ vmA ] |                  |  | | | | |  |                  | [ vmJ ] | |
| |  _____  |                  |  | | | | |  |                  |  _____  | |
| | (_hdd_)-=----\            |  | | | | |  |            /----=-(_hdd_) | |
| |_________|    |            |  | | | | |  |            |    |_________| |
|  _________    |            |  | | | | |  |            |    _________  |
| | [ vmB ] |    |            |  | | | | |  |            |    | [ vmK ] | |
| |  _____  |    |            |  | | | | |  |            |    |  _____  | |
| | (_hdd_)-=--\ |  __________|  | | | | |  |__________  | /--=-(_hdd_) | |
| |_________|  | \--| Storage  =--/ | | | \--=  Storage |--/ |  |_________| |
|  _________  \----| Network ||    | | |    || Network |----/  _________  |
| | [ vmC ] |  /----|_________||    | | |    ||_________|----\  | [ vmL ] | |
| |  _____  |  |              |    | | |    |              |  |  _____  | |
| | (_hdd_)-=--/              |    | | |    |              \--=-(_hdd_) | |
| |_________|                  |    | | |    |                  |_________| |
|______________________________|    | | |    |______________________________|           
  ______________________________    | | |    ______________________________
| [ an-node04 ]                |    | | |    |                [ an-node07 ] |
|  _________                  |    | | |    |                  _________  |
| | [ vmD ] |                  |    | | |    |                  | [ vmM ] | |
| |  _____  |                  |    | | |    |                  |  _____  | |
| | (_hdd_)-=----\            |    | | |    |            /----=-(_hdd_) | |
| |_________|    |            |    | | |    |            |    |_________| |
|  _________    |            |    | | |    |            |    _________  |
| | [ vmE ] |    |            |    | | |    |            |    | [ vmN ] | |
| |  _____  |    |            |    | | |    |            |    |  _____  | |
| | (_hdd_)-=--\ |  __________|    | | |    |__________  | /--=-(_hdd_) | |
| |_________|  | \--| Storage  =----/ | \----=  Storage |--/ |  |_________| |
|  _________  \----| Network ||      |      || Network |----/  _________  |
| | [ vmF ] |  /----|_________||      |      ||_________|----\  | [ vmO ] | |
| |  _____  |  |              |      |      |              |  |  _____  | |
| | (_hdd_)-=--+              |      |      |              \--=-(_hdd_) | |
| | (_ssd_)-=--/              |      |      |                  |_________| |
| |_________|                  |      |      |                              |
|______________________________|      |      |______________________________|           
  ______________________________      |                                     
| [ an-node05 ]                |      |                                     
|  _________                  |      |                                     
| | [ vmG ] |                  |      |                                     
| |  _____  |                  |      |                                     
| | (_hdd_)-=----\            |      |                                     
| |_________|    |            |      |                                     
|  _________    |            |      |                                     
| | [ vmH ] |    |            |      |                                     
| |  _____  |    |            |      |                                     
| | (_hdd_)-=--\ |            |      |                                     
| | (_sdd_)-=--+ |  __________|      |                                     
| |_________|  | \--| Storage  =------/                                     
|  _________  \----| Network ||                                           
| | [ vmI ] |  /----|_________||                                           
| |  _____  |  |              |                                           
| | (_hdd_)-=--/              |                                           
| |_________|                  |                                           
|______________________________|                                                       
</source>
 
== Long View ==
 
{{note|1=Yes, this is a big graphic, but this is also a big project. I am no artist though, and any help making this clearer is greatly appreciated!}}
 
[[Image:2x5_the-plan_01.png|center|thumb|800px|The planned network. This shows separate IPMI and full redundancy through-out the cluster. This is the way a production cluster should be built, but is not expected for dev/test clusters.]]
 
== Failure Mapping ==
 
VM Cluster; Guest VM failure migration planning;
 
* Each node can host 5 VMs @ 2GB/VM.
* This is an N-1 cluster with five nodes; 20 VMs total.
 
<source lang="text">
          |    All    | an-node03 | an-node04 | an-node05 | an-node06 | an-node07 |
          | on-line  |  down    |  down    |  down    |  down    |  down    |
----------+-----------+-----------+-----------+-----------+-----------+-----------+
an-node03 |  vm01    |    --    |  vm01    |  vm01    |  vm01    |  vm01    |
          |  vm02    |    --    |  vm02    |  vm02    |  vm02    |  vm02    |
          |  vm03    |    --    |  vm03    |  vm03    |  vm03    |  vm03    |
          |  vm04    |    --    |  vm04    |  vm04    |  vm04    |  vm04    |
          |    --    |    --    |  vm05    |  vm09    |  vm13    |  vm17    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node04 |  vm05    |  vm05    |    --    |  vm05    |  vm05    |  vm05    |
          |  vm06    |  vm06    |    --    |  vm06    |  vm06    |  vm06    |
          |  vm07    |  vm07    |    --    |  vm07    |  vm07    |  vm07    |
          |  vm08    |  vm08    |    --    |  vm08    |  vm08    |  vm08    |
          |    --    |  vm01    |    --    |  vm10    |  vm14    |  vm18    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node05 |  vm09    |  vm09    |  vm09    |    --    |  vm09    |  vm09    |
          |  vm10    |  vm10    |  vm10    |    --    |  vm10    |  vm10    |
          |  vm11    |  vm11    |  vm11    |    --    |  vm11    |  vm11    |
          |  vm12    |  vm12    |  vm12    |    --    |  vm12    |  vm12    |
          |    --    |  vm02    |  vm06    |    --    |  vm15    |  vm19    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node06 |  vm13    |  vm13    |  vm13    |  vm13    |    --    |  vm13    |
          |  vm14    |  vm14    |  vm14    |  vm14    |    --    |  vm14    |
          |  vm15    |  vm15    |  vm15    |  vm15    |    --    |  vm15    |
          |  vm16    |  vm16    |  vm16    |  vm16    |    --    |  vm16    |
          |    --    |  vm03    |  vm07    |  vm11    |    --    |  vm20    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node07 |  vm17    |  vm17    |  vm17    |  vm17    |  vm17    |    --    |
          |  vm18    |  vm18    |  vm18    |  vm18    |  vm18    |    --    |
          |  vm19    |  vm19    |  vm19    |  vm19    |  vm19    |    --    |
          |  vm20    |  vm20    |  vm20    |  vm20    |  vm20    |    --    |
          |    --    |  vm04    |  vm08    |  vm12    |  vm16    |    --    |
----------+-----------+-----------+-----------+-----------+-----------+-----------+
</source>
 
== Cluster Overview ==
 
{{note|1=This is not programatically accurate!}}
 
This is meant to show, at a logical level, how the parts of a cluster work together. It is the first draft and is likely defective in terrible ways.
 
<source lang="text">
[ Resource Managment ]                                                                                                         
  ___________    ___________                                                                                               
|          |  |          |                                                                                             
| Service A |  | Service B |                                                                                             
|___________|  |___________|                                                                                             
            |    |        |                                                                                                   
          __|_____|__    ___|_______________                                                                                   
        |          |  |                  |                                                                                   
        | RGManager |  | Clustered Storage |================================================.                                 
        |___________|  |___________________|                                                |                                 
              |                  |                                                          |                                 
              |__________________|______________                                            |                               
                            |                    \                                          |                               
        _________      ____|____                |                                          |                               
        |        |    |        |                |                                          |                               
/------| Fencing |----| Locking |                |                                          |                               
|      |_________|    |_________|                |                                          |                               
_|___________|_____________|______________________|__________________________________________|_____
|          |            |                      |                                          |                                 
|    ______|_____    ____|___                  |                                          |                                 
|    |            |  |        |                  |                                          |                                 
|    | Membership |  | Quorum |                  |                                          |                                 
|    |____________|  |________|                  |                                          |                                 
|          |____________|                      |                                          |                                 
|                      __|__                    |                                          |                                 
|                    /    \                    |                                          |                                 
|                    { Totem }                  |                                          |                                 
|                    \_____/                    |                                          |                                 
|      __________________|_______________________|_______________ ______________            |                                   
|    |-----------|-----------|----------------|-----------------|--------------|          |                                   
|  ___|____    ___|____    ___|____        ___|____        _____|_____    _____|_____    __|___                               
| |        |  |        |  |        |      |        |      |          |  |          |  |      |                               
| | Node 1 |  | Node 2 |  | Node 3 |  ...  | Node N |      | Storage 1 |==| Storage 2 |==| DRBD |                               
| |________|  |________|  |________|      |________|      |___________|  |___________|  |______|                               
\_____|___________|___________|________________|_________________|______________|                                               
                                                                                                                               
[ Cluster Communication ]                                                                                                       
</source>
 
== Network IPs ==
 
<source lang="text">
SAN: 10.10.1.1
 
Node:
          | IFN        | SN        | BCN      | IPMI      |
----------+-------------+------------+-----------+-----------+
an-node01 | 10.255.0.1  | 10.10.0.1  | 10.20.0.1 | 10.20.1.1 |                                               
an-node02 | 10.255.0.2  | 10.10.0.2  | 10.20.0.2 | 10.20.1.2 |                                               
an-node03 | 10.255.0.3  | 10.10.0.3  | 10.20.0.3 | 10.20.1.3 |                                               
an-node04 | 10.255.0.4  | 10.10.0.4  | 10.20.0.4 | 10.20.1.4 |                                               
an-node05 | 10.255.0.5  | 10.10.0.5  | 10.20.0.5 | 10.20.1.5 |                                               
an-node06 | 10.255.0.6  | 10.10.0.6  | 10.20.0.6 | 10.20.1.6 |                                               
an-node07 | 10.255.0.7  | 10.10.0.7  | 10.20.0.7 | 10.20.1.7 |                                               
----------+-------------+------------+-----------+-----------+
 
Aux Equipment:
          | BCN        |
----------+-------------+
pdu1      | 10.20.2.1  |                                                                                                 
pdu2      | 10.20.2.2  |                                                                                                 
switch1  | 10.20.2.3  |                                                                                                 
switch2  | 10.20.2.4  |                                                                                                 
ups1      | 10.20.2.5  |                                                                                       
ups2      | 10.20.2.6  |                                                                                       
----------+-------------+
                                                                                                                 
VMs:                                                                                                             
          | VMN        |                                                                                       
----------+-------------+
vm01      | 10.254.0.1  |                                                                                       
vm02      | 10.254.0.2  |                                                                                       
vm03      | 10.254.0.3  |                                                                                       
vm04      | 10.254.0.4  |                                                                                       
vm05      | 10.254.0.5  |                                                                                       
vm06      | 10.254.0.6  |                                                                                       
vm07      | 10.254.0.7  |                                                                                       
vm08      | 10.254.0.8  |                                                                                       
vm09      | 10.254.0.9  |                                                                                       
vm10      | 10.254.0.10 |                                                                                       
vm11      | 10.254.0.11 |                                                                                       
vm12      | 10.254.0.12 |                                                                                       
vm13      | 10.254.0.13 |                                                                                       
vm14      | 10.254.0.14 |                                                                                       
vm15      | 10.254.0.15 |                                                                                       
vm16      | 10.254.0.16 |                                                                                       
vm17      | 10.254.0.17 |                                                                                       
vm18      | 10.254.0.18 |                                                                                       
vm19      | 10.254.0.19 |                                                                                       
vm20      | 10.254.0.20 |                                                                                       
----------+-------------+
</source>
 
= Install The Cluster Software =
 
If you are using Red Hat Enterprise Linux, you will need to add the <span class="code">RHEL Server Optional (v. 6 64-bit x86_64)</span> channel for each node in your cluster. You can do this in [[RHN]] by going the your subscription management page, clicking on each server, clicking on "Alter Channel Subscriptions", click to enable the <span class="code">RHEL Server Optional (v. 6 64-bit x86_64)</span> channel and then by clicking on "Change Subscription".
 
This actual installation is simple, just use <span class="code">yum</span> to install <span class="code">cman</span>.
 
<source lang="bash">
yum install cman fence-agents rgmanager resource-agents lvm2-cluster gfs2-utils python-virtinst libvirt qemu-kvm-tools qemu-kvm virt-manager virt-viewer virtio-win
</source>
 
== Initial Config ==
 
Everything uses <span class="code">ricci</span>, which itself needs to have a password set. I set this to match <span class="code">root</span>.
 
'''Both''':
 
<source lang="bash">
passwd ricci
</source>
<source lang="bash">
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
</source>
 
With these decisions and the information gathered, here is what our first <span class="code">/etc/cluster/cluster.conf</span> file will look like.
 
<source lang="bash">
touch /etc/cluster/cluster.conf
vim /etc/cluster/cluster.conf
</source>
<source lang="xml">
<?xml version="1.0"?>
<cluster config_version="1" name="an-cluster">
<cman expected_votes="1" two_node="1" />
<clusternodes>
<clusternode name="an-node01.alteeve.ca" nodeid="1">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an01" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="1" />
<device action="reboot" name="pdu2" port="1" />
</method>
</fence>
</clusternode>
<clusternode name="an-node02.alteeve.ca" nodeid="2">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an02" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="2" />
<device action="reboot" name="pdu2" port="2" />
</method>
</fence>
</clusternode>
<clusternode name="an-node03.alteeve.ca" nodeid="3">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an03" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="3" />
<device action="reboot" name="pdu2" port="3" />
</method>
</fence>
</clusternode>
<clusternode name="an-node04.alteeve.ca" nodeid="4">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an04" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="4" />
<device action="reboot" name="pdu2" port="4" />
</method>
</fence>
</clusternode>
<clusternode name="an-node05.alteeve.ca" nodeid="5">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an05" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="5" />
<device action="reboot" name="pdu2" port="5" />
</method>
</fence>
</clusternode>
<clusternode name="an-node06.alteeve.ca" nodeid="6">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an06" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="6" />
<device action="reboot" name="pdu2" port="6" />
</method>
</fence>
</clusternode>
<clusternode name="an-node07.alteeve.ca" nodeid="7">
<fence>
<method name="ipmi">
<device action="reboot" name="ipmi_an07" />
</method>
<method name="pdu">
<device action="reboot" name="pdu1" port="7" />
<device action="reboot" name="pdu2" port="7" />
</method>
</fence>
</clusternode>
</clusternodes>
<fencedevices>
<fencedevice agent="fence_ipmilan" ipaddr="an-node01.ipmi" login="root" name="ipmi_an01" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node02.ipmi" login="root" name="ipmi_an02" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node03.ipmi" login="root" name="ipmi_an03" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node04.ipmi" login="root" name="ipmi_an04" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node05.ipmi" login="root" name="ipmi_an05" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node06.ipmi" login="root" name="ipmi_an06" passwd="secret" />
<fencedevice agent="fence_ipmilan" ipaddr="an-node07.ipmi" login="root" name="ipmi_an07" passwd="secret" />
<fencedevice agent="fence_apc_snmp" ipaddr="pdu1.alteeve.ca" name="pdu1" />
<fencedevice agent="fence_apc_snmp" ipaddr="pdu2.alteeve.ca" name="pdu2" />
</fencedevices>
<fence_daemon post_join_delay="30" />
<totem rrp_mode="none" secauth="off" />
<rm>
<resources>
<ip address="10.10.1.1" monitor_link="on" />
<script file="/etc/init.d/tgtd" name="tgtd" />
<script file="/etc/init.d/drbd" name="drbd" />
<script file="/etc/init.d/clvmd" name="clvmd" />
<script file="/etc/init.d/gfs2" name="gfs2" />
<script file="/etc/init.d/libvirtd" name="libvirtd" />
</resources>
<failoverdomains>
<!-- Used for storage -->
<!-- SAN Nodes -->
<failoverdomain name="an1_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node01.alteeve.ca" />
</failoverdomain>
<failoverdomain name="an2_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node02.alteeve.ca" />
</failoverdomain>
<!-- VM Nodes -->
<failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" />
</failoverdomain>
<failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca" />
</failoverdomain>
<failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca" />
</failoverdomain>
<failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca" />
</failoverdomain>
<failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca" />
</failoverdomain>
<!-- Domain for the SAN -->
<failoverdomain name="an1_primary" nofailback="1" ordered="1" restricted="0">
<failoverdomainnode name="an-node01.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node02.alteeve.ca" priority="2" />
</failoverdomain>
<!-- Domains for VMs running primarily on an-node03 -->
<failoverdomain name="an3_an4" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an3_an5" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an3_an6" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an3_an7" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
</failoverdomain>
<!-- Domains for VMs running primarily on an-node04 -->
<failoverdomain name="an4_an3" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an4_an5" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an4_an6" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an4_an7" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
</failoverdomain>
<!-- Domains for VMs running primarily on an-node05 -->
<failoverdomain name="an5_an3" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an5_an4" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an5_an6" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an5_an7" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
</failoverdomain>
<!-- Domains for VMs running primarily on an-node06 -->
<failoverdomain name="an6_an3" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an6_an4" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an6_an5" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an6_an7" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
</failoverdomain>
<!-- Domains for VMs running primarily on an-node07 -->
<failoverdomain name="an7_an3" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an7_an4" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an7_an5" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
</failoverdomain>
<failoverdomain name="an7_an6" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
</failoverdomain>
</failoverdomains>
<!-- SAN Services -->
<service autostart="1" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="tgtd" />
</script>
</script>
</service>
<service autostart="1" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="tgtd" />
</script>
</script>
</service>
<service autostart="1" domain="an1_primary" name="san_ip" recovery="relocate">
<ip ref="10.10.1.1" />
</service>
<!-- VM Storage services. -->
<service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="gfs2">
<script ref="libvirtd" />
</script>
</script>
</script>
</service>
<service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="gfs2">
<script ref="libvirtd" />
</script>
</script>
</script>
</service>
<service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="gfs2">
<script ref="libvirtd" />
</script>
</script>
</script>
</service>
<service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="gfs2">
<script ref="libvirtd" />
</script>
</script>
</script>
</service>
<service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart" restart_expire_time="0">
<script ref="drbd">
<script ref="clvmd">
<script ref="gfs2">
<script ref="libvirtd" />
</script>
</script>
</script>
</service>
<!-- VM Services -->
<!-- VMs running primarily on an-node03 -->
<vm name="vm01" domain="an03_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm02" domain="an03_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm03" domain="an03_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm04" domain="an03_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<!-- VMs running primarily on an-node04 -->
<vm name="vm05" domain="an04_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm06" domain="an04_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm07" domain="an04_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm08" domain="an04_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<!-- VMs running primarily on an-node05 -->
<vm name="vm09" domain="an05_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm10" domain="an05_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm11" domain="an05_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm12" domain="an05_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<!-- VMs running primarily on an-node06 -->
<vm name="vm13" domain="an06_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm14" domain="an06_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm15" domain="an06_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm16" domain="an06_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<!-- VMs running primarily on an-node07 -->
<vm name="vm17" domain="an07_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm18" domain="an07_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm19" domain="an07_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
<vm name="vm20" domain="an07_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
</rm>
</cluster>
</source>
 
Save the file, then validate it. If it fails, address the errors and try again.
 
<source lang="bash">
ip addr list | grep <ip>
rg_test test /etc/cluster/cluster.conf
ccs_config_validate
</source>
<source lang="text">
Configuration validates
</source>
 
Push it to the other node:
 
<source lang="bash">
rsync -av /etc/cluster/cluster.conf root@an-node02:/etc/cluster/
</source>
<source lang="text">
sending incremental file list
cluster.conf
 
sent 781 bytes  received 31 bytes  541.33 bytes/sec
total size is 701  speedup is 0.86
</source>
 
Start:
 
 
 
'''''DO NOT PROCEED UNTIL YOUR cluster.conf FILE VALIDATES!'''''
 
Unless you have it perfect, your cluster will fail.
 
Once it validates, proceed.
 
== Starting The Cluster For The First Time ==
 
By default, if you start one node only and you've enabled the <span class="code"><cman two_node="1" expected_votes="1"/></span> option as we have done, the lone server will effectively gain quorum. It will try to connect to the cluster, but there won't be a cluster to connect to, so it will fence the other node after a timeout period. This timeout is <span class="code">6</span> seconds by default.
 
For now, we will leave the default as it is. If you're interested in changing it though, the argument you are looking for is <span class="code">[[RHCS v3 cluster.conf#post_join_delay|post_join_delay]]</span>.
 
This behaviour means that we'll want to start both nodes well within six seconds of one another, least the slower one get needlessly fenced.
 
'''Left off here'''
 
Note to help minimize dual-fences:
* <span class="code">you could add FENCED_OPTS="-f 5" to /etc/sysconfig/cman on *one* node</span> (ilo fence devices may need this)
 
== DRBD Config ==
 
Install from source:
 
'''Both''':
 
<source lang="bash">
# Obliterate peer - fence via cman
wget -c https://alteeve.ca/files/an-cluster/sbin/obliterate-peer.sh -O /sbin/obliterate-peer.sh
chmod a+x /sbin/obliterate-peer.sh
ls -lah /sbin/obliterate-peer.sh
 
# Download, compile and install DRBD
wget -c http://oss.linbit.com/drbd/8.3/drbd-8.3.11.tar.gz
tar -xvzf drbd-8.3.11.tar.gz
cd drbd-8.3.11
./configure \
  --prefix=/usr \
  --localstatedir=/var \
  --sysconfdir=/etc \
  --with-utils \
  --with-km \
  --with-udev \
  --with-pacemaker \
  --with-rgmanager \
  --with-bashcompletion
make
make install
chkconfig --add drbd
chkconfig drbd off
</source>
 
== Configure ==
 
'''<span class="code">an-node01</span>''':
 
<source lang="bash">
# Configure DRBD's global value.
cp /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.orig
vim /etc/drbd.d/global_common.conf
diff -u /etc/drbd.d/global_common.conf
</source>
<source lang="diff">
--- /etc/drbd.d/global_common.conf.orig 2011-08-01 21:58:46.000000000 -0400
+++ /etc/drbd.d/global_common.conf 2011-08-01 23:18:27.000000000 -0400
@@ -15,24 +15,35 @@
# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";
# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";
# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
+ fence-peer "/sbin/obliterate-peer.sh";
}
startup {
# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb
+ become-primary-on both;
+ wfc-timeout 300;
+ degr-wfc-timeout 120;
}
disk {
# on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes
# no-disk-drain no-md-flushes max-bio-bvecs
+ fencing resource-and-stonith;
}
net {
# sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers
# max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret
# after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork
+ allow-two-primaries;
+ after-sb-0pri discard-zero-changes;
+ after-sb-1pri discard-secondary;
+ after-sb-2pri disconnect;
}
syncer {
# rate after al-extents use-rle cpu-mask verify-alg csums-alg
+ # This should be no more than 30% of the maximum sustainable write speed.
+ rate 20M;
}
}
</source>
<source lang="bash">
vim /etc/drbd.d/r0.res
</source>
<source lang="text">
resource r0 {
        device          /dev/drbd0;
        meta-disk      internal;
        on an-node01.alteeve.ca {
                address        192.168.2.71:7789;
                disk            /dev/sda5;
        }
        on an-node02.alteeve.ca {
                address        192.168.2.72:7789;
                disk            /dev/sda5;
        }
}
</source>
<source lang="bash">
cp /etc/drbd.d/r0.res /etc/drbd.d/r1.res
vim /etc/drbd.d/r1.res
</source>
<source lang="text">
resource r1 {
        device          /dev/drbd1;
        meta-disk      internal;
        on an-node01.alteeve.ca {
                address        192.168.2.71:7790;
                disk            /dev/sdb1;
        }
        on an-node02.alteeve.ca {
                address        192.168.2.72:7790;
                disk            /dev/sdb1;
        }
}
</source>
 
{{note|1=If you have multiple DRBD resources on on (set of) backing disks, consider adding <span class="code">syncer { after <minor-1>; }</span>. For example, tell <span class="code">/dev/drbd1</span> to wait for <span class="code">/dev/drbd0</span> by adding <span class="code">syncer { after 0; }</span>. This will prevent simultaneous resync's which could seriously impact performance. Resources will wait in <span class="code"></span> state until the defined resource has completed sync'ing.}}
 
Validate:
 
<source lang="bash">
drbdadm dump
</source>
<source lang="text">
  --==  Thank you for participating in the global usage survey  ==--
The server's response is:
 
you are the 369th user to install this version
# /usr/etc/drbd.conf
common {
    protocol              C;
    net {
        allow-two-primaries;
        after-sb-0pri    discard-zero-changes;
        after-sb-1pri    discard-secondary;
        after-sb-2pri    disconnect;
    }
    disk {
        fencing          resource-and-stonith;
    }
    syncer {
        rate            20M;
    }
    startup {
        wfc-timeout      300;
        degr-wfc-timeout 120;
        become-primary-on both;
    }
    handlers {
        pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        local-io-error  "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
        fence-peer      /sbin/obliterate-peer.sh;
    }
}
 
# resource r0 on an-node01.alteeve.ca: not ignored, not stacked
resource r0 {
    on an-node01.alteeve.ca {
        device          /dev/drbd0 minor 0;
        disk            /dev/sda5;
        address          ipv4 192.168.2.71:7789;
        meta-disk        internal;
    }
    on an-node02.alteeve.ca {
        device          /dev/drbd0 minor 0;
        disk            /dev/sda5;
        address          ipv4 192.168.2.72:7789;
        meta-disk        internal;
    }
}
 
# resource r1 on an-node01.alteeve.ca: not ignored, not stacked
resource r1 {
    on an-node01.alteeve.ca {
        device          /dev/drbd1 minor 1;
        disk            /dev/sdb1;
        address          ipv4 192.168.2.71:7790;
        meta-disk        internal;
    }
    on an-node02.alteeve.ca {
        device          /dev/drbd1 minor 1;
        disk            /dev/sdb1;
        address          ipv4 192.168.2.72:7790;
        meta-disk        internal;
    }
}
</source>
 
<source lang="bash">
rsync -av /etc/drbd.d root@an-node02:/etc/
</source>
<source lang="text">
drbd.d/
drbd.d/global_common.conf
drbd.d/global_common.conf.orig
drbd.d/r0.res
drbd.d/r1.res
 
sent 3523 bytes  received 110 bytes  7266.00 bytes/sec
total size is 3926  speedup is 1.08
</source>
 
== Initialize and First start ==
 
'''Both''':
 
Create the meta-data.
 
<source lang="bash">
modprobe
drbdadm create-md r{0,1}
</source>
<source lang="text">
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
</source>
 
Attach, connect and confirm (after both have attached and connected):
 
<source lang="bash">
drbdadm attach r{0,1}
drbdadm connect r{0,1}
cat /proc/drbd
</source>
<source lang="text">
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:441969960
1: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:29309628
</source>
 
There is no data, so force both devices to be instantly UpToDate:
 
<source lang="bash">
drbdadm -- --clear-bitmap new-current-uuid r{0,1}
cat /proc/drbd
</source>
<source lang="text">
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
1: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
</source>
 
Set both to primary and run a final check.
 
<source lang="bash">
drbdadm primary r{0,1}
cat /proc/drbd
</source>
<source lang="text">
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:672 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:672 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
</source>


* [[RHCS]], Red Hat Cluster Services version 3, aka "Cluster 3", running on Red Hat Enterprise Linux 6.0 x86_64.
== Update the cluster ==
** RHCS implements:
*** <span class="code">cman</span>; The cluster manager.
*** <span class="code">corosync</span>; The cluster engine, implementing the <span class="code">totem</span> protocol and <span class="code">[[cpg]]</span> and other core cluster services.
*** <span class="code">rgmanager</span>; The resource group manager handles restoring and failing over services in the cluster, including our Xen [[VM]]s.
* [[Fencing]] devices needed to keep a cluster safe.
** Two fencing types are discussed;
*** [[IPMI]]; The most common fence method used in servers.
*** [[Node Assassin]]; A home-brew fence device ideal for learning or as a backup to [[IPMI]].
* Xen; The virtual server [[hypervisor]].
** Converting the host OS into the special access [[dom0]] virtual machine.
** Provisioning [[domU]] VMs.
* Putting all cluster-related daemons under the control of <span class="code">rgmanager</span>.
** Making the VMs highly available.


== Prerequisites ==
<source lang="bash">
vim /etc/cluster/cluster.conf
</source>
<source lang="xml">
<?xml version="1.0"?>
<cluster config_version="17" name="an-clusterA">
        <cman expected_votes="1" two_node="1"/>
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node01.alteeve.ca" nodeid="1">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="1"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node02.alteeve.ca" nodeid="2">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="2"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <ip address="192.168.2.100" monitor_link="on"/>
                        <script file="/etc/init.d/drbd" name="drbd"/>
                        <script file="/etc/init.d/clvmd" name="clvmd"/>
                        <script file="/etc/init.d/tgtd" name="tgtd"/>
                </resources>
                <failoverdomains>
                        <failoverdomain name="an1_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node01.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an2_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node02.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an1_primary" nofailback="1" ordered="1" restricted="0">
                                <failoverdomainnode name="an-node01.alteeve.ca" priority="1"/>
                                <failoverdomainnode name="an-node02.alteeve.ca" priority="2"/>
                        </failoverdomain>
                </failoverdomains>
                <service autostart="0" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="0" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd"/>
                        </script>
                </service>
        </rm>
</cluster>
</source>
<source lang="bash">
rg_test test /etc/cluster/cluster.conf
</source>
<source lang="text">
Running in test mode.
Loading resource rule from /usr/share/cluster/oralistener.sh
Loading resource rule from /usr/share/cluster/apache.sh
Loading resource rule from /usr/share/cluster/SAPDatabase
Loading resource rule from /usr/share/cluster/postgres-8.sh
Loading resource rule from /usr/share/cluster/lvm.sh
Loading resource rule from /usr/share/cluster/mysql.sh
Loading resource rule from /usr/share/cluster/lvm_by_vg.sh
Loading resource rule from /usr/share/cluster/service.sh
Loading resource rule from /usr/share/cluster/samba.sh
Loading resource rule from /usr/share/cluster/SAPInstance
Loading resource rule from /usr/share/cluster/checkquorum
Loading resource rule from /usr/share/cluster/ocf-shellfuncs
Loading resource rule from /usr/share/cluster/svclib_nfslock
Loading resource rule from /usr/share/cluster/script.sh
Loading resource rule from /usr/share/cluster/clusterfs.sh
Loading resource rule from /usr/share/cluster/fs.sh
Loading resource rule from /usr/share/cluster/oracledb.sh
Loading resource rule from /usr/share/cluster/nfsserver.sh
Loading resource rule from /usr/share/cluster/netfs.sh
Loading resource rule from /usr/share/cluster/orainstance.sh
Loading resource rule from /usr/share/cluster/vm.sh
Loading resource rule from /usr/share/cluster/lvm_by_lv.sh
Loading resource rule from /usr/share/cluster/tomcat-6.sh
Loading resource rule from /usr/share/cluster/ip.sh
Loading resource rule from /usr/share/cluster/nfsexport.sh
Loading resource rule from /usr/share/cluster/openldap.sh
Loading resource rule from /usr/share/cluster/ASEHAagent.sh
Loading resource rule from /usr/share/cluster/nfsclient.sh
Loading resource rule from /usr/share/cluster/named.sh
Loaded 24 resource rules
=== Resources List ===
Resource type: ip
Instances: 1/1
Agent: ip.sh
Attributes:
  address = 192.168.2.100 [ primary unique ]
  monitor_link = on
  nfslock [ inherit("service%nfslock") ]


It is expected that you are already comfortable with the Linux command line, specifically <span class="code">[[bash]]</span>, and that you are familiar with general administrative tasks in Red Hat based distributions. You will also need to be comfortable using editors like [[vim]], [[nano]], [[gedit]], [[kate]] or similar. This paper uses <span class="code">vim</span> in examples. Simply substitute your favourite editor in it's place.
Resource type: script
Agent: script.sh
Attributes:
  name = drbd [ primary unique ]
  file = /etc/init.d/drbd [ unique required ]
  service_name [ inherit("service%name") ]


You are also expected to be comfortable with networking concepts. You will be expected to understand [[TCP/IP]], [[multicast]], [[broadcast]], [[subnets]] and [[netmasks]], routing and other relatively basic networking concepts. Please take the time to become familiar with these concepts before proceeding.
Resource type: script
Agent: script.sh
Attributes:
  name = clvmd [ primary unique ]
  file = /etc/init.d/clvmd [ unique required ]
  service_name [ inherit("service%name") ]


Where feasible, as much detail as is possible will be provided. For example, all configuration file locations will be shown and functioning sample files will be provided.
Resource type: script
Agent: script.sh
Attributes:
  name = tgtd [ primary unique ]
  file = /etc/init.d/tgtd [ unique required ]
  service_name [ inherit("service%name") ]


== Platform ==
Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = an1_storage [ primary unique required ]
  domain = an1_only [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = restart [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0


Red Hat Cluster Service version 3, also known as "Cluster Stable 3" or "RHCS 3", entered the server distribution world with the release of [[RHEL]] 6. It is used by downstream distributions like CentOS and Scientific Linux. This tutorial should be easily adapted to any Red Hat derivative distribution. It is expected that most users will have 64-[[bit]] [[CPU]]s, thus, we will use the [[x86_64]] distribution and packages.
Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = an2_storage [ primary unique required ]
  domain = an2_only [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = restart [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0


If you are on an 32-bit system, you should be able to follow along fine. Simply replace <span class="code">x86_64</span> with <span class="code">i386</span> or <span class="code">i686</span> in package names. Be aware though that issues arising from the need for [[PAE]] will not be discussed.
Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = san_ip [ primary unique required ]
  domain = an1_primary [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = relocate [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0


If you do not have a Red Hat Network account, you can download [[CentOS]] or another derivative of the same release, currently <span class="code">6.0</span>.
=== Resource Tree ===
service (S0) {
  name = "an1_storage";
  domain = "an1_only";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "restart";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  script (S0) {
    name = "drbd";
    file = "/etc/init.d/drbd";
    service_name = "an1_storage";
    script (S0) {
      name = "clvmd";
      file = "/etc/init.d/clvmd";
      service_name = "an1_storage";
    }
  }
}
service (S0) {
  name = "an2_storage";
  domain = "an2_only";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "restart";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  script (S0) {
    name = "drbd";
    file = "/etc/init.d/drbd";
    service_name = "an2_storage";
    script (S0) {
      name = "clvmd";
      file = "/etc/init.d/clvmd";
      service_name = "an2_storage";
    }
  }
}
service (S0) {
  name = "san_ip";
  domain = "an1_primary";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "relocate";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  ip (S0) {
    address = "192.168.2.100";
    monitor_link = "on";
    nfslock = "0";
  }
}
=== Failover Domains ===
Failover domain: an1_only
Flags: Restricted No Failback
  Node an-node01.alteeve.ca (id 1, priority 0)
Failover domain: an2_only
Flags: Restricted No Failback
  Node an-node02.alteeve.ca (id 2, priority 0)
Failover domain: an1_primary
Flags: Ordered No Failback
  Node an-node01.alteeve.ca (id 1, priority 1)
  Node an-node02.alteeve.ca (id 2, priority 2)
=== Event Triggers ===
Event Priority Level 100:
  Name: Default
    (Any event)
    File: /usr/share/cluster/default_event_script.sl
[root@an-node01 ~]# cman_tool version -r
You have not authenticated to the ricci daemon on an-node01.alteeve.ca
Password:
[root@an-node01 ~]# clusvcadm -e service:an1_storage
Local machine trying to enable service:an1_storage...Success
service:an1_storage is now running on an-node01.alteeve.ca
[root@an-node01 ~]# cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:924 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:916 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
</source>
<source lang="bash">
cman_tool version -r
</source>
<source lang="text">
You have not authenticated to the ricci daemon on an-node01.alteeve.ca
Password:
</source>


'''Note''': When last checked, down-stream distributions have not yet been released. It is expected that they will be available around mid to late December.
'''<span class="code">an-node01</span>''':


== Focus and Goal ==
<source lang="bash">
clusvcadm -e service:an1_storage
</source>
<source lang="text">
service:an1_storage is now running on an-node01.alteeve.ca
</source>


Clusters can serve to solve three problems; '''Reliability''', '''Performance''' and '''Scalability'''.
'''<span class="code">an-node02</span>''':


This paper will build a cluster designed to be more reliable, also known as a '''High-Availability cluster''' or simply '''HA Cluster'''. At the end of this paper, you should have a fully functioning two-node cluster capable of hosting a "floating" virtual servers. That is, VMs that exist on one node that can be easily moved to the other node with minimal or no down time.
<source lang="bash">
clusvcadm -e service:an2_storage
</source>
<source lang="text">
service:an2_storage is now running on an-node02.alteeve.ca
</source>


= Base System Setup =
'''Either'''


This paper is admittedly long-winded. There is a "cheat-sheet" version planned, but it will be written only after this main tutorial is complete. Please be patient! Clustering is not inherently difficult, but there are a lot of pieces that need to work together for anything to work. Grab a coffee or tea and settle in.
<source lang="bash">
cat /proc/drbd
</source>
<source lang="text">
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:924 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:916 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
</source>


== Hardware ==
== Configure Clustered LVM ==


We will need two physical servers each with the following hardware:
<span class="code">an-node01</span>''':


* One or more multi-core [[CPU]]s with Virtualization support.
<source lang="bash">
* Three network cards; At least one should be gigabit or faster.
cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig
* One or more hard drives.
vim /etc/lvm/lvm.conf
* You will need some form of a [[fence|fence device]]. This can be an [[IPMI]]-enabled server, a [http://nodeassassin.org Node Assassin], a fenceable [http://www.apc.com/products/resource/include/techspec_index.cfm?base_sku=AP7900&tab=features PDU] or similar.
diff -u /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf
</source>
<source lang="diff">
--- /etc/lvm/lvm.conf.orig 2011-08-02 21:59:01.000000000 -0400
+++ /etc/lvm/lvm.conf 2011-08-02 22:00:17.000000000 -0400
@@ -50,7 +50,8 @@
    # By default we accept every block device:
-    filter = [ "a/.*/" ]
+    #filter = [ "a/.*/" ]
+    filter = [ "a|/dev/drbd*|", "r/.*/" ]
    # Exclude the cdrom drive
    # filter = [ "r|/dev/cdrom|" ]
@@ -308,7 +309,8 @@
    # Type 3 uses built-in clustered locking.
    # Type 4 uses read-only locking which forbids any operations that might
    # change metadata.
-    locking_type = 1
+    #locking_type = 1
+    locking_type = 3
    # Set to 0 to fail when a lock request cannot be satisfied immediately.
    wait_for_locks = 1
@@ -324,7 +326,8 @@
    # to 1 an attempt will be made to use local file-based locking (type 1).
    # If this succeeds, only commands against local volume groups will proceed.
    # Volume Groups marked as clustered will be ignored.
-    fallback_to_local_locking = 1
+    #fallback_to_local_locking = 1
+    fallback_to_local_locking = 0
    # Local non-LV directory that holds file-based locks while commands are
    # in progress.  A directory like /tmp that may get wiped on reboot is OK.
</source>
<source lang="bash">
rsync -av /etc/lvm/lvm.conf root@an-node02:/etc/lvm/
</source>
<source lang="text">
sending incremental file list
lvm.conf


This paper uses the following hardware, and would suggest these be "minimum specifications":
sent 2412 bytes  received 247 bytes  5318.00 bytes/sec
total size is 24668  speedup is 9.28
</source>


* ASUS [http://support.asus.com/search/search.aspx?keyword=m4a78l-m&SLanguage=en-us M4A78L-M]
Create the LVM PVs, VGs and LVs.
* AMD Athlon II x2 250
* 2GB Kingston DDR2 KVR800D2N6K2/4G (4GB kit split between the two nodes)
* 1x Intel 82540 PCI NICs
* 1x D-Link DGE-560T
* Node Assassin


This is not an endorsement of the above hardware. I bought what was within my budget that would serve the purposes of creating this document. What you purchase shouldn't matter, so long as the minimum requirements are met.
'''<span class="code">an-node01</span>''':


'''Note''': I use three physical [[NIC]]s, but you can get away with fewer by using [[VLAN]]s or by simply re-using a given interface. Neither appealed to me given the minimal cost of add-in network cards and the relative complexity of VLANs. If you wish to alter your network setup, please do so.
<source lang="bash">
pvcreate /dev/drbd{0,1}
</source>
<source lang="text">
  Physical volume "/dev/drbd0" successfully created
  Physical volume "/dev/drbd1" successfully created
</source>
 
'''<span class="code">an-node02</span>''':


== Pre-Assembly Information ==
<source lang="bash">
pvscan
</source>
<source lang="text">
  PV /dev/drbd0                      lvm2 [421.50 GiB]
  PV /dev/drbd1                      lvm2 [27.95 GiB]
  Total: 2 [449.45 GiB] / in use: 0 [0  ] / in no VG: 2 [449.45 GiB]
</source>


With multiple NICs, it is quite likely that the mapping of physical devices to logical <span class="code">ethX</span> devices may not be ideal. This is a particular issue if you decide to [[Setting Up a PXE Server in Fedora|network boot]] your install media.
'''<span class="code">an-node01</span>''':


There is no requirement, from a clustering point of view, that any given network card be mapped to any given <span class="code">ethX</span> device. However, you will be jumping between servers fairly often and having various setups adds one more level of complexity. For this reason, I strongly recommend you follow this section.
<source lang="bash">
vgcreate -c y hdd_vg0 /dev/drbd0 && vgcreate -c y sdd_vg0 /dev/drbd1
</source>
<source lang="text">
  Clustered volume group "hdd_vg0" successfully created
  Clustered volume group "ssd_vg0" successfully created
</source>


Before you assemble your servers, record their network cards' [[MAC]] addresses. I like to keep simple text files like these:
'''<span class="code">an-node02</span>''':


<source lang="bash">
<source lang="bash">
cat an-node01.mac
vgscan
</source>
</source>
<source lang="text">
<source lang="text">
90:E6:BA:71:82:EA eth0 # Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
  Reading all physical volumes.  This may take a while...
00:21:91:19:96:53 eth1 # D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter
  Found volume group "ssd_vg0" using metadata type lvm2
00:0E:0C:59:46:E4 eth2 # Intel Corporation 82540EM Gigabit Ethernet Controller
  Found volume group "hdd_vg0" using metadata type lvm2
</source>
</source>
'''<span class="code">an-node01</span>''':


<source lang="bash">
<source lang="bash">
cat an-node02.mac
lvcreate -l 100%FREE -n lun0 /dev/hdd_vg0 && lvcreate -l 100%FREE -n lun1 /dev/ssd_vg0
</source>
</source>
<source lang="text">
<source lang="text">
90:E6:BA:71:82:D8 eth0 # Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
  Logical volume "lun0" created
00:21:91:19:96:5A eth1 # D-Link System Inc DGE-560T PCI Express Gigabit Ethernet Adapter
  Logical volume "lun1" created
00:0E:0C:59:45:78 eth2 # Intel Corporation 82540EM Gigabit Ethernet Controller
</source>
</source>


This will prove very handy later.
'''<span class="code">an-node02</span>''':


== OS Install ==
<source lang="bash">
lvscan
</source>
<source lang="text">
  ACTIVE            '/dev/ssd_vg0/lun1' [27.95 GiB] inherit
  ACTIVE            '/dev/hdd_vg0/lun0' [421.49 GiB] inherit
</source>


There is no hard and fast rule on how you install the host operating systems. Ultimately, it's a question of what you prefer. There are some things that you should keep in mind though.
= iSCSI notes =


* Balance the desire for tools against the reality that all programs have bugs.
IET vs tgt pros and cons needed.
** Bugs could be exploited to gain access to your server. If the host is compromised, all of the virtual servers are compromised.
* The host operating system, known as <span class="code">[[dom0]]</span> in Xen, should do nothing but run the [[hypervisor]].
* If you install a graphical interface, like [[Xorg]] and [[Gnome]], consider disabling it.
** This paper takes this approach and will cover disabling the graphical interface.


Below is the kickstart script used by the nodes for this paper. You should be able to adapt it easily to suit your needs. All options are documented.
default iscsi port is 3260


* [https://alteeve.com/files/an-cluster/generic_server_rhel6.ks generic_server_rhel6.ks]
''initiator'': This is the client.
''target'': This is the server side.
''sid'': Session ID; Found with <span class="code">iscsiadm -m session -P 1</span>. SID and sysfs path are not persistent, partially start-order based.
''iQN'': iSCSI Qualified Name; This is a string that uniquely identifies targets and initiators.


== Post OS Install ==
'''Both''':


There are a handful of changes we will want to make now that the install is complete. Some of these are optional and you may skip them if you prefer. However, the remainder of this paper assumes these changes have been made. If you used the [[kickstart]] script, then some of these steps will have already been completed.
<source lang="bash">
yum install iscsi-initiator-utils scsi-target-utils
</source>


=== Disable selinux ===
'''<span class="code">an-node01</span>''':


Given the complexity of clustering, we will disable <span class="code">selinux</span> to keep it from being more complex. Obviously, this introduces security issues that you may not be comfortable with.
<source lang="bash">
cp /etc/tgt/targets.conf /etc/tgt/targets.conf.orig
vim /etc/tgt/targets.conf
diff -u /etc/tgt/targets.conf.orig /etc/tgt/targets.conf
</source>
<source lang="bash">
--- /etc/tgt/targets.conf.orig 2011-07-31 12:38:35.000000000 -0400
+++ /etc/tgt/targets.conf 2011-08-02 22:19:06.000000000 -0400
@@ -251,3 +251,9 @@
#        vendor_id VENDOR1
#    </direct-store>
#</target>
+
+<target iqn.2011-08.com.alteeve:an-clusterA.target01>
+ direct-store /dev/drbd0
+ direct-store /dev/drbd1
+ vendor_id Alteeve
</source>
<source lang="bash">
rsync -av /etc/tgt/targets.conf root@an-node02:/etc/tgt/
</source>
<source lang="text">
sending incremental file list
targets.conf


To disable <span class="code">selinux</span>, edit <span class="code">/etc/selinux/config</span> and change <span class="code">SELINUX=enforcing</span> to <span class="code">SELINUX=permissive</span>. You will need to reboot in order for the changes to take effect, but don't do it yet as some changes to come may also need a reboot.
sent 909 bytes  received 97 bytes  670.67 bytes/sec
total size is 7093  speedup is 7.05
</source>


=== Change the Default Run-Level ===
=== Update the cluster ===


This is an optional step intended to improve performance.
<source lang="xml">
              <service autostart="0" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd">
                                        <script ref="tgtd"/>
                                </script>
                        </script>
                </service>
                <service autostart="0" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd">
                                        <script ref="tgtd"/>
                                </script>
                        </script>
                </service>
</source>


If you don't plan to work on your nodes directly, it makes sense to switch the default run level from <span class="code">5</span> to <span class="code">3</span>. This prevents the window manager, like Gnome or KDE, from starting at boot. This frees up a fair of memory and system resources and reduces the possible attack vectors.
= Connect to the SAN from a VM node =


To do this, edit <span class="code">/etc/inittab</span>, change the <span class="code">id:5:initdefault:</span> line to <span class="code">id:3:initdefault:</span> and then switch to run level 3:
'''<span class="code">an-node03+</span>''':


<source lang="bash">
<source lang="bash">
vim /etc/inittab
iscsiadm -m discovery -t sendtargets -p 192.168.2.100
</source>
</source>
<source lang="text">
<source lang="text">
id:3:initdefault:
192.168.2.100:3260,1 iqn.2011-08.com.alteeve:an-clusterA.target01
</source>
</source>
<source lang="bash">
<source lang="bash">
init 3
iscsiadm --mode node --portal 192.168.2.100 --target iqn.2011-08.com.alteeve:an-clusterA.target01 --login
</source>
<source lang="text">
Logging in to [iface: default, target: iqn.2011-08.com.alteeve:an-clusterA.target01, portal: 192.168.2.100,3260]
Login to [iface: default, target: iqn.2011-08.com.alteeve:an-clusterA.target01, portal: 192.168.2.100,3260] successful.
</source>
</source>


=== Make Boot Messages Visible ===
<source lang="bash">
fdisk -l
</source>
<source lang="text">
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a
 
  Device Boot     Start        End      Blocks  Id  System
/dev/sda1  *          1          33      262144  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040  83  Linux
/dev/sda3            5255        5777    4194304  82  Linux swap / Solaris
 
Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/sdb doesn't contain a valid partition table
 
Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/sdc doesn't contain a valid partition table
</source>
 
== Setup the VM Cluster ==
 
Install RPMs.


This is another optional step that disables the <span class="code">rhgb</span> (Red Hat Graphical Boot) and <span class="code">quiet</span> kernel arguments. These options provide the nice boot-time splash screen. I like to turn them off though as they also hide a lot of boot messages that can be helpful.
<source lang="bash">
yum -y install lvm2-cluster cman fence-agents
</source>


To make this change, edit the grub menu and remove the <span class="code">rhgb quiet</span> arguments from the <span class="code">kernel /vmlinuz...</span> line.
Configure <span class="code">lvm.conf</span>.


<source lang="bash">
<source lang="bash">
vim /boot/grub/menu.lst
cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig
vim /etc/lvm/lvm.conf
diff -u /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf
</source>
<source lang="diff">
--- /etc/lvm/lvm.conf.orig 2011-08-02 21:59:01.000000000 -0400
+++ /etc/lvm/lvm.conf 2011-08-03 00:35:45.000000000 -0400
@@ -308,7 +308,8 @@
    # Type 3 uses built-in clustered locking.
    # Type 4 uses read-only locking which forbids any operations that might
    # change metadata.
-    locking_type = 1
+    #locking_type = 1
+    locking_type = 3
    # Set to 0 to fail when a lock request cannot be satisfied immediately.
    wait_for_locks = 1
@@ -324,7 +325,8 @@
    # to 1 an attempt will be made to use local file-based locking (type 1).
    # If this succeeds, only commands against local volume groups will proceed.
    # Volume Groups marked as clustered will be ignored.
-    fallback_to_local_locking = 1
+    #fallback_to_local_locking = 1
+    fallback_to_local_locking = 0
    # Local non-LV directory that holds file-based locks while commands are
    # in progress.  A directory like /tmp that may get wiped on reboot is OK.
</source>
</source>


Change:
<source lang="bash">
rsync -av /etc/lvm/lvm.conf root@an-node04:/etc/lvm/
</source>
<source lang="text">
sending incremental file list
lvm.conf


sent 873 bytes  received 247 bytes  2240.00 bytes/sec
total size is 24625  speedup is 21.99
</source>
<source lang="bash">
rsync -av /etc/lvm/lvm.conf root@an-node05:/etc/lvm/
</source>
<source lang="text">
<source lang="text">
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
sending incremental file list
        root (hd0,0)
lvm.conf
        kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=UUID=ef8ebd1b-8c5f-4bc8-b683-ead5f4603fec rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
 
        initrd /initramfs-2.6.32-71.el6.x86_64.img
sent 873 bytes  received 247 bytes  2240.00 bytes/sec
total size is 24625  speedup is 21.99
</source>
</source>


To:
Config the cluster.


<source lang="bash">
vim /etc/cluster/cluster.conf
</source>
<source lang="xml">
<?xml version="1.0"?>
<cluster config_version="5" name="an-clusterB">
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node03.alteeve.ca" nodeid="1">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="3"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node04.alteeve.ca" nodeid="2">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="4"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node05.alteeve.ca" nodeid="3">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="5"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <script file="/etc/init.d/iscsi" name="iscsi" />
                        <script file="/etc/init.d/clvmd" name="clvmd" />
                </resources>
                <failoverdomains>
                        <failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node03.alteeve.ca" />
                        </failoverdomain>
                        <failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node04.alteeve.ca" />
                        </failoverdomain>
                        <failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node05.alteeve.ca" />
                        </failoverdomain>
                </failoverdomains>
                <service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
        </rm> 
</cluster>
</source>
<source lang="bash">
ccs_config_validate
</source>
<source lang="text">
<source lang="text">
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
Configuration validates
        root (hd0,0)
        kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=UUID=ef8ebd1b-8c5f-4bc8-b683-ead5f4603fec rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto
        initrd /initramfs-2.6.32-71.el6.x86_64.img
</source>
</source>


= Setup Inter-Node Networking =
Make sure iscsi and clvmd do not start on boot, stop both, then make sure they start and stop cleanly.
 
<source lang="bash">
chkconfig clvmd off; chkconfig iscsi off; /etc/init.d/iscsi stop && /etc/init.d/clvmd stop
</source>
<source lang="text">
Stopping iscsi:                                            [  OK  ]
</source>
<source lang="bash">
/etc/init.d/clvmd start && /etc/init.d/iscsi start && /etc/init.d/iscsi stop && /etc/init.d/clvmd stop
</source>
<source lang="text">
Starting clvmd:
Activating VG(s):  No volume groups found
                                                          [  OK  ]
Starting iscsi:                                            [  OK  ]
Stopping iscsi:                                            [  OK  ]
Signaling clvmd to exit                                    [  OK  ]
clvmd terminated                                          [  OK  ]
</source>


This is the first stage of our network setup. Here we will walk through setting up the three networks between our two nodes. Later we will revisit networking to tie the virtual machines together.
Use the cluster to stop (in case it autostarted before now) and then start the services.


== Warning About Managed Switches ==
<source lang="bash">
# Disable (stop)
clusvcadm -d service:an3_storage
clusvcadm -d service:an4_storage
clusvcadm -d service:an5_storage
# Enable (start)
clusvcadm -e service:an3_storage -m an-node03.alteeve.ca
clusvcadm -e service:an4_storage -m an-node04.alteeve.ca
clusvcadm -e service:an5_storage -m an-node05.alteeve.ca
# Check
clustat
</source>
<source lang="text">
Cluster Status for an-clusterB @ Wed Aug  3 00:25:10 2011
Member Status: Quorate


'''WARNING''': Please pay attention to this warning! The vast majority of cluster problems end up being network related. The hardest ones to diagnose are usually [[multicast]] issues.
Member Name                            ID  Status
------ ----                            ---- ------
an-node03.alteeve.ca                        1 Online, Local, rgmanager
an-node04.alteeve.ca                        2 Online, rgmanager
an-node05.alteeve.ca                        3 Online, rgmanager


If you use a managed switch, be careful about enabling [[Multicast IGMP Snooping]] or [[Spanning Tree Protocol]]. They have been known to cause problems by not allowing multicast packets to reach all nodes. This can cause somewhat random break-downs in communication between your nodes, leading to seemingly random fences and DLM lock timeouts. If your switches support [[PIM Routing]], be sure to use it!
Service Name                  Owner (Last)                  State       
------- ----                  ----- ------                  -----       
service:an3_storage            an-node03.alteeve.ca          started     
service:an4_storage            an-node04.alteeve.ca          started     
service:an5_storage            an-node05.alteeve.ca          started     
</source>


If you have problems with your cluster not forming, or seemingly random fencing, try using a cheap [http://dlink.ca/products/?pid=230 unmanaged] switch. If the problem goes away, you are most likely dealing with a managed switch configuration problem.
== Flush iSCSI's Cache ==


== Network Layout ==
If you remove an iQN (or change the name of one), the <span class="code">/etc/init.d/iscsi</span> script will return errors. To flush it and re-scan:


This setup expects you to have three physical network cards connected to three independent networks. Each network serves a purpose:
I am sure there is a more elegant way.


* Network connected to the Internet and thus has untrusted traffic.
<source lang="bash">
* Storage network used for keeping data between the nodes in sync.
/etc/init.d/iscsi stop && rm -rf /var/lib/iscsi/nodes/* && iscsiadm -m discovery -t sendtargets -p 192.168.2.100
* Back-channel network used for secure internode communication.
</source>


These are the networks and names that will be used in this tutorial. Please note that, inside [[VM]]s, device names will not match the list below. This table is valid for the operating systems running the [[hypervisor]]s, known as [[dom0]] in Xen or as the host in other virtualized environments.
== Setup the VM Cluster's Clustered LVM ==


{|
=== Partition the SAN disks ===
!class="cell_all"|Network Description
!class="cell_tbr"|Short Name
!class="cell_tbr"|Device Name
!class="cell_tbr"|Suggested Subnet
!class="cell_tbr"|NIC Properties
|-
|class="cell_blr"|Back-Channel Network
|class="cell_br"|<span class="code">BCN</span>
|class="cell_br"|<span class="code">eth0</span>
|class="cell_br"|<span class="code">192.168.1.0/24</span>
|class="cell_br"|NICs with [[IPMI]] piggy-back '''must''' be used here.<br />Second-fastest NIC should be used here.<br />If using a [[Setting Up a PXE Server in Fedora|PXE server]], this should be a bootable NIC.
|-
|class="cell_blr"|Storage Network
|class="cell_br"|<span class="code">SN</span>
|class="cell_br"|<span class="code">eth1</span>
|class="cell_br"|<span class="code">192.168.2.0/24</span>
|class="cell_br"|Fastest NIC should be used here.
|-
|class="cell_blr"|Internet-Facing Network
|class="cell_br"|<span class="code">IFN</span>
|class="cell_br"|<span class="code">eth2</span>
|class="cell_br"|<span class="code">192.168.3.0/24</span>
|class="cell_br"|Remaining NIC should be used here.
|}


Take note of these concerns when planning which NIC to use on each subnet. These issues are presented in the order that they must be addressed in:
'''<span class="code">an-node03</span>''':


# If your nodes have [[IPMI]] piggy-backing on a normal NIC, that NIC '''''must''''' be used on <span class="code">BCN</span> subnet. Having your fence device accessible on a subnet that can be remotely accessed can pose a ''major'' security risk.
<source lang="bash">
# The fastest NIC should be used for your <span class="code">SN</span> subnet. Be sure to know which NICs support the largest jumbo frames when considering this.
fdisk -l
# If you still have two NICs to choose from, use the fastest remaining NIC for your <span class="code">BCN</span> subnet. This will minimize the time it takes to perform tasks like hot-migration of live virtual machines.
</source>
# The final NIC should be used for the <span class="code">IFN</span> subnet.
<source lang="text">
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a


== Node IP Addresses ==
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          33      262144  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040  83  Linux
/dev/sda3            5255        5777    4194304  82  Linux swap / Solaris


Obviously, the IP addresses you give to your nodes should be ones that suit you best. In this example, the following IP addresses are used:
Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


{|
Disk /dev/sdc doesn't contain a valid partition table
|class="cell_br"|&nbsp;
|class="cell_tbr"|'''Internet-Facing Network''' (<span class="code">IFN</span>)
|class="cell_tbr"|'''Storage Network''' (<span class="code">SN</span>)
|class="cell_tbr"|'''Back-Channel Network''' (<span class="code">BCN</span>)
|-
|class="cell_blr"|'''an-node01'''
|class="cell_br"|<span class="code">192.168.1.71</span>
|class="cell_br"|<span class="code">192.168.2.71</span>
|class="cell_br"|<span class="code">192.168.3.71</span>
|-
|class="cell_blr"|'''an-node02'''
|class="cell_br"|<span class="code">192.168.1.72</span>
|class="cell_br"|<span class="code">192.168.2.72</span>
|class="cell_br"|<span class="code">192.168.3.72</span>
|}


== Disable The NetworkManager Daemon ==
Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Some cluster software '''will not''' start with <span class="code">NetworkManager</span> running! This is because <span class="code">NetworkManager</span> is designed to be a highly-adaptive, easy to use network configuration system that can adapt to frequent changes in a network. For workstations and laptops, this is wonderful. For clustering, this can be disastrous. We need to ensure that, once set, the network will not change.
Disk /dev/sdb doesn't contain a valid partition table
</source>


Disable <span class="code">NetworkManager</span> from starting with the system.
Create partitions.


<source lang="bash">
<source lang="bash">
chkconfig NetworkManager off
fdisk /dev/sdb
chkconfig --list NetworkManager
</source>
</source>
<source lang="text">
<source lang="text">
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x403f1fb8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
        switch off the mode (command 'c') and change display units to
        sectors (command 'u').
 
Command (m for help): c
DOS Compatibility flag is not set
 
Command (m for help): u
Changing display/entry units to sectors
 
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-55022, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-55022, default 55022):
Using default value 55022
 
Command (m for help): p
 
Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      55022  441964183+  83  Linux
 
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
 
Command (m for help): p
 
Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      55022  441964183+  8e  Linux LVM
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
</source>
 
<source lang="bash">
fdisk /dev/sdc
</source>
</source>
<source lang="text">
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xba7503eb.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
        switch off the mode (command 'c') and change display units to
        sectors (command 'u').
Command (m for help): c
DOS Compatibility flag is not set


The second command shows us that <span class="code">NetworkManager</span> is now disabled in all [[run-levels]].
Command (m for help): u
Changing display/entry units to sectors


== Enable the network Daemon ==
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-58613759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-58613759, default 58613759):
Using default value 58613759


The first step is to map your physical interfaces to the desired <span class="code">ethX</span> name. There is an existing tutorial that will show you how to do this.
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)


* [[Changing the ethX to Ethernet Device Mapping in RHEL6]]
Command (m for help): p


There are a few ways to configure <span class="code">network</span> in Fedora:
Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders, total 58613760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba7503eb


* <span class="code">system-config-network</span> (graphical)
  Device Boot      Start        End      Blocks  Id  System
* <span class="code">system-config-network-tui</span> (ncurses)
/dev/sdc1            2048    58613759    29305856  8e  Linux LVM
* Directly editing the <span class="code">/etc/sysconfig/network-scripts/ifcfg-eth*</span> files.


If you decide that you want to hand-craft your network interfaces, take a look at the tutorial above. In it are example configuration files that are compatible with this tutorial. There are also links to documentation on what options are available in the network configuration files.
Command (m for help): w
The partition table has been altered!


'''''WARNING''''': Do '''not''' proceed until your node's networking is fully configured! This may be a small sub-section, but it is critical that you have everything setup properly before going any further!
Calling ioctl() to re-read partition table.
Syncing disks.
</source>


== Update the Hosts File ==
<source lang="bash">
fdisk -l
</source>
<source lang="text">
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a


Some applications expect to be able to call nodes by their name. To accommodate this, and to ensure that inter-node communication takes place on the back-channel subnet, we remove any existing hostname entries and then add the following to the <span class="code">/etc/hosts</span> file:
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          33      262144  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040  83  Linux
/dev/sda3            5255        5777    4194304  82  Linux swap / Solaris


'''Note''': Any pre-existing entries matching the name returned by <span class="code">uname -n</span> must be removed from <span class="code">/etc/hosts</span>. There is a good chance there will be an entry that resolves to <span class="code">127.0.0.1</span> which would cause problems later.
Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba7503eb


Obviously, adapt the names and IPs to match your nodes and subnets. The only critical thing is to make sure that the name returned by <span class="code">uname -n</span> is resolvable to the back-channel subnet. I like to add a entries for all networks, but this is optional.
  Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              2      28620    29305856  8e  Linux LVM


The updated <span class="code">/etc/hosts</span> file should look something like this:
Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8
 
  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1      55022  441964183+  8e  Linux LVM
</source>
 
=== Setup LVM devices ===
 
Create PV.
 
'''<span class="code">an-node03</span>''':


<source lang="bash">
<source lang="bash">
vim /etc/hosts
pvcreate /dev/sd{b,c}1
</source>
</source>
<source lang="text">
<source lang="text">
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
   Physical volume "/dev/sdb1" successfully created
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
  Physical volume "/dev/sdc1" successfully created
</source>
 
'''<span class="code">an-node04</span> and <span class="code">an-node05</span>''':


# Internet Facing Network
<source lang="bash">
192.168.1.71    an-node01 an-node01.alteeve.com an-node01.ifn
pvscan
192.168.1.72    an-node02 an-node02.alteeve.com an-node02.ifn
</source>
<source lang="text">
  PV /dev/sdb1                      lvm2 [421.49 GiB]
  PV /dev/sdc1                      lvm2 [27.95 GiB]
  Total: 2 [449.44 GiB] / in use: 0 [0  ] / in no VG: 2 [449.44 GiB]
</source>


# Storage Network
Create the VGs.
192.168.2.71    an-node01.sn
192.168.2.72    an-node02.sn


# Back Channel Network
'''<span class="code">an-node03</span>''':
192.168.3.71    an-node01.bcn
192.168.3.72    an-node02.bcn


# Node Assassins
<source lang="bash">
192.168.3.61    batou batou.alteeve.com
vgcreate -c y san_vg01 /dev/sdb1
192.168.3.62    motoko motoko.alteeve.com
</source>
<source lang="text">
  Clustered volume group "san_vg01" successfully created
</source>
<source lang="bash">
vgcreate -c y san_vg02 /dev/sdc1
</source>
<source lang="text">
  Clustered volume group "san_vg02" successfully created
</source>
</source>


Now to test this, ping both nodes by their name, as returned by <span class="code">uname -n</span>, and make sure the ping packets are sent on the back channel network (<span class="code">192.168.1.0/24</span>).
'''<span class="code">an-node04</span> and <span class="code">an-node05</span>''':


<source lang="bash">
<source lang="bash">
ping -c 5 an-node01.alteeve.com
vgscan
</source>
</source>
<source lang="text">
<source lang="text">
PING an-node01 (192.168.1.71) 56(84) bytes of data.
  Reading all physical volumes. This may take a while...
64 bytes from an-node01 (192.168.1.71): icmp_seq=1 ttl=64 time=0.399 ms
  Found volume group "san_vg02" using metadata type lvm2
64 bytes from an-node01 (192.168.1.71): icmp_seq=2 ttl=64 time=0.403 ms
  Found volume group "san_vg01" using metadata type lvm2
64 bytes from an-node01 (192.168.1.71): icmp_seq=3 ttl=64 time=0.413 ms
</source>
64 bytes from an-node01 (192.168.1.71): icmp_seq=4 ttl=64 time=0.365 ms
 
64 bytes from an-node01 (192.168.1.71): icmp_seq=5 ttl=64 time=0.428 ms
Create the first VM's LVs.
 
'''<span class="code">an-node03</span>''':


--- an-node01 ping statistics ---
<source lang="bash">
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
lvcreate -L 10G -n shared01 /dev/san_vg01
rtt min/avg/max/mdev = 0.365/0.401/0.428/0.030 ms
</source>
<source lang="text">
  Logical volume "shared01" created
</source>
<source lang="bash">
lvcreate -L 50G -n vm0001_hdd1 /dev/san_vg01
</source>
<source lang="text">
  Logical volume "vm0001_hdd1" created
</source>
</source>
<source lang="bash">
<source lang="bash">
ping -c 5 an-node02.alteeve.com
lvcreate -L 10G -n vm0001_ssd1 /dev/san_vg02
</source>
</source>
<source lang="text">
<source lang="text">
PING an-node02 (192.168.1.72) 56(84) bytes of data.
  Logical volume "vm0001_ssd1" created
64 bytes from an-node02 (192.168.1.72): icmp_seq=1 ttl=64 time=0.419 ms
</source>
64 bytes from an-node02 (192.168.1.72): icmp_seq=2 ttl=64 time=0.405 ms
64 bytes from an-node02 (192.168.1.72): icmp_seq=3 ttl=64 time=0.416 ms
64 bytes from an-node02 (192.168.1.72): icmp_seq=4 ttl=64 time=0.373 ms
64 bytes from an-node02 (192.168.1.72): icmp_seq=5 ttl=64 time=0.396 ms


--- an-node02 ping statistics ---
'''<span class="code">an-node04</span> and <span class="code">an-node05</span>''':
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
 
rtt min/avg/max/mdev = 0.373/0.401/0.419/0.030 ms
<source lang="bash">
lvscan
</source>
<source lang="text">
  ACTIVE            '/dev/san_vg01/shared01' [10.00 GiB] inherit
  ACTIVE            '/dev/san_vg02/vm0001_ssd1' [10.00 GiB] inherit
  ACTIVE            '/dev/san_vg01/vm0001_hdd1' [50.00 GiB] inherit
</source>
</source>


If you did name your other nodes in <span class="code">/etc/hosts</span>, now is a good time to make sure that everything is working by pinging each interface by name and also pinging the fence devices.
== Create Shared GFS2 Partition ==


From <span class="code">an-node01</span>
'''<span class="code">an-node03</span>''':


<source lang="bash">
<source lang="bash">
ping -c 5 an-node02
mkfs.gfs2 -p lock_dlm -j 5 -t an-clusterB:shared01 /dev/san_vg01/shared01
ping -c 5 an-node02.ifn
</source>
ping -c 5 an-node02.sn
<source lang="text">
ping -c 5 an-node02.bcn
This will destroy any data on /dev/san_vg01/shared01.
ping -c 5 batou
It appears to contain: symbolic link to `../dm-2'
ping -c 5 batou.alteeve.com
 
ping -c 5 motoko
Are you sure you want to proceed? [y/n] y
ping -c 5 motoko.alteeve.com
 
Device:                    /dev/san_vg01/shared01
Blocksize:                4096
Device Size                10.00 GB (2621440 blocks)
Filesystem Size:          10.00 GB (2621438 blocks)
Journals:                  5
Resource Groups:          40
Locking Protocol:          "lock_dlm"
Lock Table:                "an-clusterB:shared01"
UUID:                      6C0D7D1D-A1D3-ED79-705D-28EE3D674E75
</source>
</source>


Then repeat the set of pings from <span class="code">an-node02</span> to the <span class="code">an-node01</span> networks and the fence devices.
Add it to <span class="code">/etc/fstab</span> (needed for the <span class="code">gfs2</span> init script to find and mount):
 
'''<span class="code">an-node03</span> - <span class="code">an-node07</span>''':
 
<source lang="bash">
echo `gfs2_edit -p sb /dev/san_vg01/shared01 | grep sb_uuid | sed -e "s/.*sb_uuid  *\(.*\)/UUID=\L\1\E \/shared01\t\tgfs2\trw,suid,dev,exec,nouser,async\t0 0/"` >> /etc/fstab
cat /etc/fstab
</source>
<source lang="bash">
#
# /etc/fstab
# Created by anaconda on Fri Jul  8 22:01:41 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2c1f4cb1-959f-4675-b9c7-5d753c303dd1 /                      ext3    defaults        1 1
UUID=9a0224dc-15b4-439e-8d7c-5f9dbcd05e3f /boot                  ext3    defaults        1 2
UUID=4f2a83e8-1769-40d8-ba2a-e1f535306848 swap                    swap    defaults        0 0
tmpfs                  /dev/shm                tmpfs  defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                  /sys                    sysfs  defaults        0 0
proc                    /proc                  proc    defaults        0 0
UUID=6c0d7d1d-a1d3-ed79-705d-28ee3d674e75 /shared01 gfs2 rw,suid,dev,exec,nouser,async 0 0
</source>


From <span class="code">an-node02</span>
Make the mount point and mount it.


<source lang="bash">
<source lang="bash">
ping -c 5 an-node01
mkdir /shared01
ping -c 5 an-node01.ifn
/etc/init.d/gfs2 start
ping -c 5 an-node01.sn
</source>
ping -c 5 an-node01.bcn
<source lang="text">
ping -c 5 batou
Mounting GFS2 filesystem (/shared01):                      [  OK  ]
ping -c 5 batou.alteeve.com
</source>
ping -c 5 motoko
<source lang="bash">
ping -c 5 motoko.alteeve.com
df -h
</source>
<source lang="text">
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G  35G  9% /
tmpfs                1.8G  32M  1.8G  2% /dev/shm
/dev/sda1            248M  85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                      10G  647M  9.4G  7% /shared01
</source>
</source>
Be sure that, if your [[fence]] device uses a name, that you include entries to resolve it as well. You can see how I've done this with the two [[Node Assassin]] devices I use. The same applies to [[IPMI]] or other devices, if you plan to reference them by name.


Fencing will be discussed in more detail later on in this HowTo.
Stop GFS2 on all five nodes and update the cluster.conf config.


== Disable Firewalls ==
<source lang="bash">
/etc/init.d/gfs2 stop
</source>
<source lang="text">
Unmounting GFS2 filesystem (/shared01):                    [  OK  ]
</source>
<source lang="bash">
df -h
</source>
<source lang="text">
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G  35G  9% /
tmpfs                1.8G  32M  1.8G  2% /dev/shm
/dev/sda1            248M  85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                      10G  647M  9.4G  7% /shared01
</source>


In the spirit of keeping things simple, and understanding that this is a test cluster, we will flush netfilter tables and disable <span class="code">iptables</span> and <span class="code">ip6tables</span> from starting on our nodes.
'''<span class="code">an-node03</span>''':


<source lang="xml">
<?xml version="1.0"?>
<cluster config_version="9" name="an-clusterB">
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node03.alteeve.ca" nodeid="3">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="3"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node04.alteeve.ca" nodeid="4">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="4"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node05.alteeve.ca" nodeid="5">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="5"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node06.alteeve.ca" nodeid="6">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="6"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node07.alteeve.ca" nodeid="7">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="7"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <script file="/etc/init.d/iscsi" name="iscsi"/>
                        <script file="/etc/init.d/clvmd" name="clvmd"/>
                        <script file="/etc/init.d/gfs2" name="gfs2"/>
                </resources>
                <failoverdomains>
                        <failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node03.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node04.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node05.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node06.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node07.alteeve.ca"/>
                        </failoverdomain>
                </failoverdomains>
                <service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
        </rm>
</cluster>
</source>
<source lang="bash">
<source lang="bash">
chkconfig --level 2345 iptables off
cman_tool version -r
</source>
 
Check that <span class="code">rgmanager</span> picked up the updated config and remounted the GFS2 partition.
 
<source lang="bash">
df -h
</source>
<source lang="text">
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G  35G  9% /
tmpfs                1.8G  32M  1.8G  2% /dev/shm
/dev/sda1            248M  85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                      10G  647M  9.4G  7% /shared01
</source>
 
= Configure KVM =
 
Host network and VM hypervisor config.
 
== Disable the 'qemu' Bridge ==
 
By default, <span class="code">[[libvirtd]]</span> creates a bridge called <span class="code">virbr0</span> designed to connect virtual machines to the first <span class="code">eth0</span> interface. Our system will not need this, so we will remove it. This bridge is configured in the <span class="code">/etc/libvirt/qemu/networks/default.xml</span> file.
 
So to remove this bridge, simply delete the contents of the file, stop the bridge, delete the bridge and then stop <span class="code">iptables</span> to make sure any rules created for the bridge are flushed.
 
<source lang="bash">
cat /dev/null >/etc/libvirt/qemu/networks/default.xml
ifconfig virbr0 down
brctl delbr virbr0
/etc/init.d/iptables stop
/etc/init.d/iptables stop
chkconfig --level 2345 ip6tables off
/etc/init.d/ip6tables stop
</source>
</source>


What I like to do in production clusters is disable the IP address on the internet-facing interfaces on the [[dom0]] machines. The only real connection to the interface is inside a [[VM]] designed to be a firewall running Shorewall. That VM will have two virtual interfaces connected to <span class="code">eth0</span> and <span class="code">eth2</span>. With that VM in place, and with all other VMs only having a virtual interface connected to <span class="code">eth0</span>, all Internet traffic is forced through the one firewall VM.
== Configure Bridges ==
 
On '''<span class="code">an-node03</span>''' through '''<span class="code">an-node07</span>''':
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-{eth,vbr}0
</source>
 
''<span class="code">ifcfg-eth0</span>'':
<source lang="bash">
# Internet facing
HWADDR="bc:ae:c5:44:8a:de"
DEVICE="eth0"
BRIDGE="vbr0"
BOOTPROTO="static"
IPV6INIT="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
</source>
 
Note that you can use what ever bridge names makes sense to you. However, the file name for the bridge configuration must sort after the <span class="code">ifcfg-ethX</span> file. If the bridge file is read before the ethernet interface, it will fail to come up. Also, the bridge name as defined in the file does not need to match the one used it the actual file name. Personally, I like <span class="code">vbrX</span> for "''v''m ''br''idge".
 
''<span class="code">ifcfg-vbr0</span>'':
<source lang="bash">
# Bridge - IFN
DEVICE="vbr0"
TYPE="Bridge"
IPADDR=192.168.1.73
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
DNS1=192.139.81.117
DNS2=192.139.81.1
</source>
 
You may wish to not make the Back-Channel Network accessible to the virtual machines, then there is no need to setup this second bridge.
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-{eth,vbr}2
</source>
 
''<span class="code">ifcfg-eth2</span>'':
<source lang="bash">
# Back-channel
HWADDR="00:1B:21:72:9B:56"
DEVICE="eth2"
BRIDGE="vbr2"
BOOTPROTO="static"
IPV6INIT="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
</source>
 
''<span class="code">ifcfg-vbr2</span>'':
<source lang="bash">
# Bridge - BCN
DEVICE="vbr2"
TYPE="Bridge"
IPADDR=192.168.3.73
NETMASK=255.255.255.0
</source>
 
Leave the cluster, lest we be fenced.
 
<source lang="bash">
/etc/init.d/rgmanager stop && /etc/init.d/cman stop
</source>
 
Restart networking and then check that the new bridges are up and that the proper ethernet devices are slaved to them.
 
<source lang="bash">
/etc/init.d/network restart
</source>
<source lang="text">
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down interface eth2:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface eth1:                                [  OK  ]
Bringing up interface eth2:                                [  OK  ]
Bringing up interface vbr0:                                [  OK  ]
Bringing up interface vbr2:                                [  OK  ]
</source>
 
<source lang="bash">
brctl show
</source>
<source lang="text">
bridge name bridge id STP enabled interfaces
vbr0 8000.bcaec5448ade no eth0
vbr2 8000.001b21729b56 no eth2
</source>
 
<source lang="bash">
ifconfig
</source>
<source lang="text">
eth0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE 
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:4439 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2752 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:508352 (496.4 KiB)  TX bytes:494345 (482.7 KiB)
          Interrupt:31 Base address:0x8000
 
eth1      Link encap:Ethernet  HWaddr 00:1B:21:72:96:E8 
          inet addr:192.168.2.73  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:96e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:617100 errors:0 dropped:0 overruns:0 frame:0
          TX packets:847718 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:772489353 (736.7 MiB)  TX bytes:740536232 (706.2 MiB)
          Interrupt:18 Memory:fe9e0000-fea00000
 
eth2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56 
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:86586 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80934 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11366700 (10.8 MiB)  TX bytes:10091579 (9.6 MiB)
          Interrupt:17 Memory:feae0000-feb00000
 
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11507 (11.2 KiB)  TX bytes:11507 (11.2 KiB)
 
vbr0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE 
          inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:165 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:25875 (25.2 KiB)  TX bytes:17081 (16.6 KiB)


When you are finished building your cluster, you may want to check out the Shorewall tutorial below. It was written on Fedora 13, but it will work nearly perfectly on Red Hat Enterprise Linux 6.
vbr2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56 
          inet addr:192.168.3.73  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:74 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:19021 (18.5 KiB)  TX bytes:4137 (4.0 KiB)
</source>


* [[Shorewall on Fedora 13]]
Rejoin the cluster.


== Setup SSH Shared Keys ==
<source lang="bash">
/etc/init.d/cman start && /etc/init.d/rgmanager start
</source>


'''This is an optional step'''. Setting up shared keys will allow your nodes to pass files between one another and execute commands remotely without needing to enter a password. This is obviously somewhat risky from a security point of view. As such, it is up to you whether you do this or not. Keep in mind, this tutorial assumes that you are building a test cluster, so there is a focus on ease of use.


If you're a little new to [[SSH]], it can be a bit confusing keeping connections straight in you head. When you connect to a remote machine, you start the connection on your machine as the user you are logged in as. This is the source user. When you call the remote machine, you tell the machine what user you want to log in as. This is the remote user.
Repeat these configurations, altering for [[MAC]] and [[IP]] addresses as appropriate, for the other four VM cluster nodes.


You will need to create an SSH key for each source user, and then you will need to copy it's newly generated public key to each remote user's home directory that you want to connect to. In this example, we want to connect to either node, from either node, as the <span class="code">root</span> user. So we will create a key for each node's <span class="code">root</span> user and then copy the generated public key to the ''other'' node's <span class="code">root</span> user's directory.
<span class="code"></span>
<source lang="bash">
</source>
<source lang="text">
</source>


Here, simply, is what we will do.
== Benchmarks ==


* Log in to <span class="code">an-node01</span> as <span class="code">root</span>
GFS2 partition on <span class="code">an-node07</span>'s <span class="code">/shared01</span> partition. Test #1, no optimization:
** Generate an ssh key
** Copy the contents from <span class="code">/root/.ssh/id_rsa.pub</span>
* Log in to <span class="code">an-node02</span> as <span class="code">root</span>
** Edit the file <span class="code">/root/.ssh/authorized_keys</span>
** Paste in the content's of <span class="code">root@an-node01</span>'s public key.
** Generate an ssh key
** Copy the contents from <span class="code">/root/.ssh/id_rsa.pub</span>
* Log back in to <span class="code">an-node01</span> as <span class="code">root</span>
** Edit the file <span class="code">/root/.ssh/authorized_keys</span>
** Paste in the content's of <span class="code">root@an-node02</span>'s public key.


Here are the detailed steps.
<source lang="bash">
bonnie++ -d /shared01/ -s 8g -u root:root
</source>
<source lang="text">
Version  1.96      ------Sequential Output------ --Sequential Input- --Random-
Concurrency  1    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
an-node07.alteev 8G  388  95 22203  6 14875  8  2978  95 48406  10 107.3  5
Latency              312ms  44400ms  31355ms  41505us    540ms  11926ms
Version  1.96      ------Sequential Create------ --------Random Create--------
an-node07.alteeve.c -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                16  1144  18 +++++ +++  8643  56  939  19 +++++ +++  8262  55
Latency              291ms    586us    2085us    3511ms      51us    3669us
1.96,1.96,an-node07.alteeve.ca,1,1312497509,8G,,388,95,22203,6,14875,8,2978,95,48406,10,107.3,5,16,,,,,1144,18,+++++,+++,8643,56,939,19,+++++,+++,8262,55,312ms,44400ms,31355ms,41505us,540ms,11926ms,291ms,586us,2085us,3511ms,51us,3669us
</source>


For each user, on each machine you want to connect '''from''', run:
CentOS 5.6 x86_64 VM <span class="code">vm0001_labzilla</span>'s <span class="code">/root</span> directory. Test #1, no optimization. VM provisioned using command in below section.


<source lang="bash">
<source lang="bash">
# The '2047' is just to screw with brute-forces a bit.
bonnie++ -d /root/ -s 8g -u root:root
ssh-keygen -t rsa -N "" -b 2047 -f ~/.ssh/id_rsa
</source>
</source>
<source lang="text">
<source lang="text">
Generating public/private rsa key pair.
Version  1.96      ------Sequential Output------ --Sequential Input- --Random-
Your identification has been saved in /root/.ssh/id_rsa.
Concurrency  1    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Your public key has been saved in /root/.ssh/id_rsa.pub.
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
The key fingerprint is:
labzilla-new.can 8G  674  98 15708  5 14875   7  1570  65 47806 10 119.1   7
08:d8:ed:72:38:61:c5:0e:cf:bf:dc:28:e5:3c:a7:88 root@an-node01.alteeve.com
Latency            66766us    7680ms   1588ms     187ms     269ms    1292ms
The key's randomart image is:
Version  1.96       ------Sequential Create------ --------Random Create--------
+--[ RSA 2047]----+
labzilla-new.candco -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
|    ..          |
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
|   o.o.          |
                16 27666  39 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
| . ==.          |
Latency            11360us    1904us    799us    290us      44us      41us
|   . =+.        |
1.96,1.96,labzilla-new.candcoptical.com,1,1312522208,8G,,674,98,15708,5,14875,7,1570,65,47806,10,119.1,7,16,,,,,27666,39,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,66766us,7680ms,1588ms,187ms,269ms,1292ms,11360us,1904us,799us,290us,44us,41us
|   + +.S        |
|     +  o        |
|      = +      |
|     ...B o      |
|    E ...+       |
+-----------------+
</source>
</source>


This will create two files: the private key called <span class="code">~/.ssh/id_dsa</span> and the public key called <span class="code">~/.ssh/id_dsa.pub</span>. The private '''''must never''''' be group or world readable! That is, it should be set to mode <span class="code">0600</span>.
== Provision vm0001 ==


The two files should look like:
Created LV already, so:


'''Private key''':
<source lang="bash">
<source lang="bash">
cat ~/.ssh/id_rsa
virt-install --connect qemu:///system \
  --name vm0001_labzilla \
  --ram 1024 \
  --arch x86_64 \
  --vcpus 2 \
  --cpuset 1-3 \
  --location http://192.168.1.254/c5/x86_64/img/ \
  --extra-args "ks=http://192.168.1.254/c5/x86_64/ks/labzilla_c5.ks" \
  --os-type linux \
  --os-variant rhel5.4 \
  --disk path=/dev/san_vg01/vm0001_hdd1 \
  --network bridge=vbr0 \
  --vnc
</source>
 
== Provision vm0002 ==
 
Created LV already, so:
 
<source lang="bash">
virt-install --connect qemu:///system \
  --name vm0002_innovations \
  --ram 1024 \
  --arch x86_64 \
  --vcpus 2 \
  --cpuset 1-3 \
  --cdrom /shared01/media/Win_Server_2008_Bis_x86_64.iso \
  --os-type windows \
  --os-variant win2k8 \
  --disk path=/dev/san_vg01/vm0002_hdd2 \
  --network bridge=vbr0 \
  --hvm \
  --vnc
</source>
 
Update the <span class="code">cluster.conf</span> to add the VMs to the cluster.
 
<source lang="xml">
<?xml version="1.0"?>
<cluster config_version="12" name="an-clusterB">
<totem rrp_mode="none" secauth="off"/>
<clusternodes>
<clusternode name="an-node03.alteeve.ca" nodeid="3">
<fence>
<method name="apc_pdu">
<device action="reboot" name="pdu2" port="3"/>
</method>
</fence>
</clusternode>
<clusternode name="an-node04.alteeve.ca" nodeid="4">
<fence>
<method name="apc_pdu">
<device action="reboot" name="pdu2" port="4"/>
</method>
</fence>
</clusternode>
<clusternode name="an-node05.alteeve.ca" nodeid="5">
<fence>
<method name="apc_pdu">
<device action="reboot" name="pdu2" port="5"/>
</method>
</fence>
</clusternode>
<clusternode name="an-node06.alteeve.ca" nodeid="6">
<fence>
<method name="apc_pdu">
<device action="reboot" name="pdu2" port="6"/>
</method>
</fence>
</clusternode>
<clusternode name="an-node07.alteeve.ca" nodeid="7">
<fence>
<method name="apc_pdu">
<device action="reboot" name="pdu2" port="7"/>
</method>
</fence>
</clusternode>
</clusternodes>
<fencedevices>
<fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
</fencedevices>
<fence_daemon post_join_delay="30"/>
<rm log_level="5">
<resources>
<script file="/etc/init.d/iscsi" name="iscsi"/>
<script file="/etc/init.d/clvmd" name="clvmd"/>
<script file="/etc/init.d/gfs2" name="gfs2"/>
</resources>
<failoverdomains>
<failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca"/>
</failoverdomain>
<failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node04.alteeve.ca"/>
</failoverdomain>
<failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node05.alteeve.ca"/>
</failoverdomain>
<failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node06.alteeve.ca"/>
</failoverdomain>
<failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
<failoverdomainnode name="an-node07.alteeve.ca"/>
</failoverdomain>
<failoverdomain name="an3_primary" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="1"/>
<failoverdomainnode name="an-node04.alteeve.ca" priority="2"/>
<failoverdomainnode name="an-node05.alteeve.ca" priority="3"/>
<failoverdomainnode name="an-node06.alteeve.ca" priority="4"/>
<failoverdomainnode name="an-node07.alteeve.ca" priority="5"/>
</failoverdomain>
<failoverdomain name="an4_primary" nofailback="1" ordered="1" restricted="1">
<failoverdomainnode name="an-node03.alteeve.ca" priority="5"/>
<failoverdomainnode name="an-node04.alteeve.ca" priority="1"/>
<failoverdomainnode name="an-node05.alteeve.ca" priority="2"/>
<failoverdomainnode name="an-node06.alteeve.ca" priority="3"/>
<failoverdomainnode name="an-node07.alteeve.ca" priority="4"/>
</failoverdomain>
</failoverdomains>
<service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart">
<script ref="iscsi">
<script ref="clvmd">
<script ref="gfs2"/>
</script>
</script>
</service>
<service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart">
<script ref="iscsi">
<script ref="clvmd">
<script ref="gfs2"/>
</script>
</script>
</service>
<service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart">
<script ref="iscsi">
<script ref="clvmd">
<script ref="gfs2"/>
</script>
</script>
</service>
<service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart">
<script ref="iscsi">
<script ref="clvmd">
<script ref="gfs2"/>
</script>
</script>
</service>
<service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart">
<script ref="iscsi">
<script ref="clvmd">
<script ref="gfs2"/>
</script>
</script>
</service>
<vm autostart="0" domain="an3_primary" exclusive="0" max_restarts="2" name="vm0001_labzilla" path="/shared01/definitions/" recovery="restart" restart_expire_time="600"/>
<vm autostart="0" domain="an4_primary" exclusive="0" max_restarts="2" name="vm0002_innovations" path="/shared01/definitions/" recovery="restart" restart_expire_time="600"/>
</rm>
</cluster>
</source>
 
 
<span class="code"></span>
<source lang="bash">
</source>
</source>
<source lang="text">
<source lang="text">
-----BEGIN RSA PRIVATE KEY-----
MIIEoQIBAAKCAQBlL42DC+NJVpJ0rdrWQ1rxGEbPrDoe8j8+RQx3QYiB014R7jY5
EaTenThxG/cudgbLluFxq6Merfl9Tq2It3k9Koq9nV9ZC/vXBcl4MC7pGSQaUw2h
DVwI7OCSWtnS+awR/1d93tANXRwy7K5ic1pcviJeN66dPuuPqJEF/SKE7yEBapMq
sN28G4IiLdimsV+UYXPQLOiMy5stmyGhFhQGH3kxYzJPOgiwZEFPZyXinGVoV+qa
9ERSjSKAL+g21zbYB/XFK9jLNSJqDIPa//wz0T+73agZ0zNlxygmXcJvapEsFGDG
O6tcy/3XlatSxjEZvvfdOnC310gJVp0bcyWDAgMBAAECggEAMZd0y91vr+n2Laln
r8ujLravPekzMyeXR3Wf/nLn7HkjibYubRnwrApyNz11kBfYjL+ODqAIemjZ9kgx
VOhXS1smVHhk2se8zk3PyFAVLblcsGo0K9LYYKd4CULtrzEe3FNBFje10FbqEytc
7HOMvheR0IuJ0Reda/M54K2H1Y6VemtMbT+aTcgxOSOgflkjCTAeeOajqP5r0TRg
1tY6/k46hLiBka9Oaj+QHHoWp+aQkb+ReHUBcUihnz3jcw2u8HYrQIO4+v4Ud2kr
C9QHPW907ykQTMAzhMvZ3DIOcqTzA0r857ps6FANTM87tqpse5h2KfdIjc0Ok/AY
eKgYAQKBgQDm/P0RygIJl6szVhOb5EsQU0sBUoMT3oZKmPcjHSsyVFPuEDoq1FG7
uZYMESkVVSYKvv5hTkRuVOqNE/EKtk5bwu4mM0S3qJo99cLREKB6zNdBp9z2ACDn
0XIIFIalXAPwYpoFYi1YfG8tFfSDvinLI6JLDT003N47qW1cC5rmgQKBgHAkbfX9
8u3LiT8JqCf1I+xoBTwH64grq/7HQ+PmwRqId+HyyDCm9Y/mkAW1hYQB+cL4y3OO
kGL60CZJ4eFiTYrSfmVa0lTbAlEfcORK/HXZkLRRW03iuwdAbZ7DIMzTvY2HgFlU
L1CfemtmzEC4E6t5/nA4Ytk9kPSlzbzxfXIDAoGAY/WtaqpZ0V7iRpgEal0UIt94
wPy9HrcYtGWX5Yk07VXS8F3zXh99s1hv148BkWrEyLe4i9F8CacTzbOIh1M3e7xS
pRNgtH3xKckV4rVoTVwh9xa2p3qMwuU/jMGdNygnyDpTXusKppVK417x7qU3nuIv
1HzJNPwz6+u5GLEo+oECgYAs++AEKj81dkzytXv3s1UasstOvlqTv/j5dZNdKyZQ
72cvgsUdBwxAEhu5vov1XRmERWrPSuPOYI/4m/B5CYbTZgZ/v8PZeBTg17zgRtgo
qgJq4qu+fXHKweR3KAzTPSivSiiJLMTiEWb5CD5sw6pYQdJ3z5aPUCwChzQVU8Wf
YwKBgQCvoYG7gwx/KGn5zm5tDpeWb3GBJdCeZDaj1ulcnHR0wcuBlxkw/TcIadZ3
kqIHlkjll5qk5EiNGNlnpHjEU9X67OKk211QDiNkg3KAIDMKBltE2AHe8DhFsV8a
Mc/t6vHYZ632hZ7b0WNuudB4GHJShOumXD+NfJgzxqKJyfGkpQ==
-----END RSA PRIVATE KEY-----
</source>
</source>


'''Public key''':
= Stuff =
 
Multi-VM after primary SAN (violent) ejection from cluster. Both VMs remained up!
 
[[Image:two_vms_on_two_by_seven_cluster_build_01.png|thumb|center|800px|Two VMs (windows and Linux) running on the SAN. Initial testing of survivability of primary SAN failure completed successfully!]]
 
First build of the 2x7 Cluster.
 
[[Image:first_ever_build.png|thumb|center|700px|First-ever successful build/install of the "Cluster Set" cluster configuration. Fully HA, fully home-brew on all open source software using only commodity hardware. Much tuning/testing to come!]]
 
== Bonding and Trunking ==
 
The goal here is to take the network out as a single point of failure.
 
The design is to use two stacked switches, bonded connections in the nodes with each leg of the bond cabled through either switch. While both are up, the aggregate bandwidth will be achieved using trunking in the switch and the appropriate bond driver configuration. The recovery from failure will need to be configured in such a way that it will be faster than the cluster's token loss timeouts multiplied by the token retransmit loss count.
 
This tutorial uses 2x [http://dlink.ca/products/?pid=DGS-3100-24&tab=3 D-Link DGS-3100-24] switches. This is not to endorse these switches, per-se, but it does provide a relatively affordable, decent quality switches for those who'd like to replicate this setup.
 
=== Configure The Stack ===
 
First, stack the switches using a ring topology (both HDMI connectors/cables used). If both switches are brand new, simple cable them together and the switches will auto-negotiate the stack configuration. If you are adding a new switch, then power on the existing switch, cable up the second switch and then power on the second switch. After a short time, it's stack ID should increment and you should see the new switch appear in the existing switch's interface.
 
=== Configuring the Bonding Drivers ===
 
This tutorial uses four interfaces joined into two bonds of two NICs like so:
 
<source lang="text">
# Internet Facing Network:
eth0 + eth1 == bond0
</source>
 
<source lang="text">
# Storage and Cluster Communications:
eth2 + eth3 == bond1
</source>
 
This requires a few steps.
 
* Create <span class="code">/etc/modprobe.d/bonding.conf</span> and add an entry for the two bonding channels we will create.
 
''Note'': My <span class="code">eth0</span> device is an onboard controller with a maximum [[MTU]] of 7200 [[bytes]]. This means that the whole bond is restricted to this MTU.
 
<source lang="bash">
<source lang="bash">
cat ~/.ssh/id_rsa.pub
vim /etc/modprobe.d/bonding.conf
</source>
</source>
<source lang="text">
<source lang="text">
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAGUvjYML40lWknSt2tZDWvEYRs+sOh7yPz5FDHdBiIHTXhHuNjkRpN6dOHEb9y52BsuW4XGrox6t+X1OrYi3eT0qir2dX1kL+9cFyXgwLukZJBpTDaENXAjs4JJa2dL5rBH/V33e0A1dHDLsrmJzWly+Il43rp0+64+okQX9IoTvIQFqkyqw3bwbgiIt2KaxX5Rhc9As6IzLmy2bIaEWFAYfeTFjMk86CLBkQU9nJeKcZWhX6pr0RFKNIoAv6DbXNtgH9cUr2Ms1ImoMg9r//DPRP7vdqBnTM2XHKCZdwm9qkSwUYMY7q1zL/deVq1LGMRm+9906cLfXSAlWnRtzJYM= root@an-node01.alteeve.com
alias bond0 bonding
alias bond1 bonding
</source>
 
* Create the <span class="code">ifcfg-bondX</span> configuration files.
 
Internet Facing configuration
 
<source lang="bash">
touch /etc/sysconfig/network-scripts/ifcfg-bond{0,1}
vim /etc/sysconfig/network-scripts/ifcfg-eth{0,1} /etc/sysconfig/network-scripts/ifcfg-bond0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
</source>
<source lang="bash">
# Internet Facing Network - Link 1
HWADDR="BC:AE:C5:44:8A:DE"
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
MTU="7200"
</source>
 
<source lang="bash">
cat /etc/sysconfig/network-scripts/ifcfg-eth1
</source>
<source lang="bash">
# Internet Facing Network - Link 2
HWADDR="00:1B:21:72:96:E8"
DEVICE="eth1"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
MTU="7200"
</source>
 
<source lang="bash">
cat /etc/sysconfig/network-scripts/ifcfg-bond0
</source>
<source lang="bash">
# Internet Facing Network - Bonded Interface
DEVICE="bond0"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.1.73"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.254"
DNS1="192.139.81.117"
DNS2="192.139.81.1"
BONDING_OPTS="miimon=1000 mode=0"
MTU="7200"
</source>
</source>


Copy the public key and then <span class="code">ssh</span> normally into the remote machine as the <span class="code">root</span> user. Create a file called <span class="code">~/.ssh/authorized_keys</span> and paste in the key.
Merged Storage Network and Back Channel Network configuration.
 
''Note'': The interfaces in this bond all support maximum [[MTU]] of 9000 [[bytes]].
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-eth{2,3} /etc/sysconfig/network-scripts/ifcfg-bond1
cat /etc/sysconfig/network-scripts/ifcfg-eth2
</source>
<source lang="bash">
# Storage and Back Channel Networks - Link 1
HWADDR="00:1B:21:72:9B:56"
DEVICE="eth2"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
MTU="9000"
</source>


From '''an-node01''', type:
<source lang="bash">
cat /etc/sysconfig/network-scripts/ifcfg-eth3
</source>
<source lang="bash">
# Storage and Back Channel Networks - Link 2
HWADDR="00:0E:0C:59:46:E4"
DEVICE="eth3"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
MTU="9000"
</source>


<source lang="bash">
<source lang="bash">
ssh root@an-node02
cat /etc/sysconfig/network-scripts/ifcfg-bond1
</source>
<source lang="bash">
# Storage and Back Channel Networks - Bonded Interface
DEVICE="bond1"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.3.73"
NETMASK="255.255.255.0"
BONDING_OPTS="miimon=1000 mode=0"
MTU="9000"
</source>
 
Restart networking.
 
{{note|1=I've noticed that this can error out and fail to start slaved devices at times when using <span class="code">/etc/init.d/network restart</span>. If you have any trouble, you may need to completely stop all networking, then start it back up. This, of course, requires network-less access to the node's console (direct access, [[iKVM]], console redirection, etc).}}
 
Some of the errors we will see below are because the network interface configuration changed while the interfaces were still up. To avoid this, if you have networkless access to the nodes, would be to stop the network interfaces prior to beginning editing.
 
<source lang="bash">
/etc/init.d/network restart
</source>
<source lang="text">
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down interface eth2:  /etc/sysconfig/network-scripts/ifdown-eth: line 99: /sys/class/net/bond1/bonding/slaves: No such file or directory
                                                          [  OK  ]
Shutting down interface eth3:  /etc/sysconfig/network-scripts/ifdown-eth: line 99: /sys/class/net/bond1/bonding/slaves: No such file or directory
                                                          [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:  RTNETLINK answers: File exists
Error adding address 192.168.1.73 for bond0.
RTNETLINK answers: File exists
                                                          [  OK  ]
Bringing up interface bond1:                              [  OK  ]
</source>
 
Confirm that we've got our new bonded interfaces
 
<source lang="bash">
ifconfig
</source>
</source>
<source lang="text">
<source lang="text">
The authenticity of host 'an-node02 (192.168.1.72)' can't be established.
bond0    Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE 
RSA key fingerprint is d4:1b:68:5f:fa:ef:0f:0c:16:e7:f9:0a:8d:69:3e:c5.
          inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0
Are you sure you want to continue connecting (yes/no)? yes
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
Warning: Permanently added 'an-node02,192.168.1.72' (RSA) to the list of known hosts.
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:7200  Metric:1
root@an-node02's password:  
          RX packets:1021 errors:0 dropped:0 overruns:0 frame:0
Last login: Fri Oct 1 20:07:01 2010 from 192.168.1.102
          TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:128516 (125.5 KiB)  TX bytes:95092 (92.8 KiB)
 
bond1    Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56 
          inet addr:192.168.3.73  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:9000  Metric:1
          RX packets:787028 errors:0 dropped:0 overruns:0 frame:0
          TX packets:788651 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:65753950 (62.7 MiB)  TX bytes:1194295932 (1.1 GiB)
 
eth0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:7200  Metric:1
          RX packets:535 errors:0 dropped:0 overruns:0 frame:0
          TX packets:261 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:66786 (65.2 KiB)  TX bytes:47749 (46.6 KiB)
          Interrupt:31 Base address:0x8000
 
eth1      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:7200  Metric:1
          RX packets:486 errors:0 dropped:0 overruns:0 frame:0
          TX packets:241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:61730 (60.2 KiB)  TX bytes:47343 (46.2 KiB)
          Interrupt:18 Memory:fe8e0000-fe900000
 
eth2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:9000  Metric:1
          RX packets:360190 errors:0 dropped:0 overruns:0 frame:0
          TX packets:394844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:28756400 (27.4 MiB) TX bytes:598159146 (570.4 MiB)
          Interrupt:17 Memory:fe9e0000-fea00000
 
eth3      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:9000 Metric:1
          RX packets:426838 errors:0 dropped:0 overruns:0 frame:0
          TX packets:393807 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:36997550 (35.2 MiB)  TX bytes:596136786 (568.5 MiB)
 
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
</source>
</source>


You will now be logged into <span class="code">an-node02</span> as the <span class="code">root</span> user. Create the <span class="code">~/.ssh/authorized_keys</span> file and paste into it the public key from <span class="code">an-node01</span>. If the remote machine's user hasn't used <span class="code">ssh</span> yet, their <span class="code">~/.ssh</span> directory will not exist.
== Configuring High-Availability Networking ==
 
There are [http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Using_Channel_Bonding.html seven bonding] modes, which you can read about in [http://www.kernel.org/doc/Documentation/networking/bonding.txt detail here]. However, the [[RHCS]] stack only supports one of the modes, called [[Active/Passive Bonding]], also known as <span class="code">mode=1</span>.  
 
=== Configuring Your Switches ===
 
This method provides for no performance gains, but instead treats the slaved interfaces as independent paths. One of which acts as the primary while the other sits dormant. On failure, the bond switches to the backup interface, promoting it to the primary interface. Which is normally primary, and under what conditions a restored link might return to the primary role, are configurable should you wish to do so.
 
Your managed switch will no doubt have one or more bonding, also known as [[trunking]] configuration options. Likewise, your switches may be stackable. It is strongly advised that you do *not* stack your switches. Being unstacked, it is obviously not possible to configure trunking. Should you decide to disregard this, be very sure to extensive test failure and recovery of both switches under real-world work loads.
 
Still on the topic of switches; Do not configure [[STP]] (spanning tree protocol) on any port connected to your cluster nodes! When a switch is added to the network, as is the case after restoring a lost switch, STP-enabled switches and port on those switches may block traffic for a period of time while STP renegotiates and reconfigures. This takes more than enough time to cause a cluster to partition. You may still enable and configure STP if you need to do so, simply ensure that you only do in on the appropriate ports.
 
=== Preparing The Bonding Driver ===
 
Before we modify the network, we will need to create the following file:
 
You will need to create a file called
 
With the switches unstacked and STP disabled, we can now configure your bonding interface.


<source lang="bash">
<source lang="bash">
cat ~/.ssh/authorized_keys
vim /etc/modprobe.d/bonding.conf
</source>
</source>
<source lang="text">
<source lang="text">
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAGUvjYML40lWknSt2tZDWvEYRs+sOh7yPz5FDHdBiIHTXhHuNjkRpN6dOHEb9y52BsuW4XGrox6t+X1OrYi3eT0qir2dX1kL+9cFyXgwLukZJBpTDaENXAjs4JJa2dL5rBH/V33e0A1dHDLsrmJzWly+Il43rp0+64+okQX9IoTvIQFqkyqw3bwbgiIt2KaxX5Rhc9As6IzLmy2bIaEWFAYfeTFjMk86CLBkQU9nJeKcZWhX6pr0RFKNIoAv6DbXNtgH9cUr2Ms1ImoMg9r//DPRP7vdqBnTM2XHKCZdwm9qkSwUYMY7q1zL/deVq1LGMRm+9906cLfXSAlWnRtzJYM= root@an-node01.alteeve.com
alias bond0 bonding
alias bond1 bonding
alias bond2 bonding
</source>
 
If you only have four interfaces and plan to merge the [[SN]] and [[BCN]] networks, you can omit the <span class="code">bond2</span> entry.
 
You can then copy and paste the <span class="code">alias ...</span> entries from the file above into the terminal to avoid the need to reboot.
 
=== Deciding Which NICs to Bond ===
 
If all of the interfaces in your server are identical, you can probably skip this step. Before you jump though, consider that not all of the [[PCIe]] interfaces may have all of their lanes connected, resulting in differing speeds. If you are unsure, I strongly recommend you run these tests.
 
TODO: Upload <span class="code">network_profiler.pl</span> here and explain it's use.
* Before we do that though, let's look at how we will verify the current link speed using <span class="code">[http://rpm.pbone.net/index.php3?stat=3&search=iperf&Search.x=33&Search.y=6&simple=2&dist%5B%5D=74&dist%5B%5D=0&dl=40&sr=1&field%5B%5D=1&field%5B%5D=2&srodzaj=1 ipperf]</span> (local copy of [https://alteeve.ca/files/iperf-2.0.5-1.el6.x86_64.rpm iperf-2.0.5-1.el6.x86_64.rpm]).
 
 
Once you've determined the various capabilities on your interfaces, pair them off with their closest-performing partners.
 
Keep in mind:
 
* Any interface piggy-backing on an IPMI interface *must* be part of the [[BCN]] bond!
* The fasted interfaces should be paired for the [[SN]] bond.
* The lowest latency interfaces should be used the [[BCN]] bond.
* The lowest remaining two interfaces should be used in the [[IFN]] bond.
 
=== Creating the Bonds ===
 
{{warning|1=This step will almost certainly leave you without a network access to your servers. It is *strongly* advised that you do the next steps when you have physical access to your servers. If that is simply not possible, then proceed with extreme caution.}}
 
In my case, I found that bonding the following optimal configuration:
 
* <span class="code">eth0</span> and <span class="code">eth3</span> bonded as <span class="code">bond0</span>.
* <span class="code">eth1</span> and <span class="code">eth2</span> bonded as <span class="code">bond1</span>.
 
I did not have enough interfaces for three bonds, so I will configure the following:
 
* <span class="code">bond0</span> will be the [[IFN]] interface on the <span class="code">192.168.1.0/24</span> subnet.
* <span class="code">bond1</span> will be the merged [[BCN]] and [[SN]] interfaces on the <span class="code">192.168.3.0/24</span> subnet.
 
TODO: Create/show the <span class="code">diff</span>s for the following <span class="code">ifcfg-ethX</span> files.
 
* Create <span class="code">bond0</span> our of <span class="code">eth0</span> and <span class="code">eth3</span>:
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-eth0
</source>
<source lang="bash">
# Internet Facing Network - Link 1
HWADDR="BC:AE:C5:44:8A:DE"
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="no"
MASTER="bond0"
SLAVE="yes"
</source>
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-eth3
</source>
<source lang="bash">
# Storage and Back Channel Networks - Link 2
HWADDR="00:0E:0C:59:46:E4"
DEVICE="eth3"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="no"
MASTER="bond0"
SLAVE="yes"
</source>
 
<source lang="bash">
vim /etc/sysconfig/network-scripts/ifcfg-bond0
</source>
<source lang="bash">
# Internet Facing Network - Bonded Interface
DEVICE="bond0"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.1.73"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.254"
DNS1="192.139.81.117"
DNS2="192.139.81.1"
# Clustering *only* supports mode=1 (active-passive)
BONDING_OPTS="mode=1 miimon=100 use_carrier=0 updelay=0 downdelay=0"
</source>
</source>


Now log out and then log back into the remote machine. This time, the connection should succeed without having entered a password!
== GFS2 ==
 
Try adding <span class="code">noatime</span> to the <span class="code">/etc/fstab</span> options. h/t to Dak1n1; "it avoids cluster reads from turning into unnecessary writes, and can improve performance".


<span class="code"></span>
<source lang="bash">
</source>
<source lang="text">
</source>


{{footer}}
{{footer}}

Latest revision as of 21:43, 20 June 2016

 AN!Wiki :: How To :: 2x5 Scalable Cluster Tutorial


Warning: This document is old, abandoned and very out of date. DON'T USE ANYTHING HERE! Consider it only as historical note taking.

The Design

Storage

Storage, high-level:

[ Storage Cluster ]                                                       
    _____________________________             _____________________________ 
   | [ an-node01 ]               |           | [ an-node02 ]               |
   |  _____    _____             |           |             _____    _____  |
   | ( HDD )  ( SSD )            |           |            ( SSD )  ( HDD ) |
   | (_____)  (_____)  __________|           |__________  (_____)  (_____) |
   |    |        |    | Storage  =--\     /--=  Storage |    |        |    |
   |    |        \----| Network ||  |     |  || Network |----/        |    |
   |    \-------------|_________||  |     |  ||_________|-------------/    |
   |_____________________________|  |     |  |_____________________________|
                                  __|_____|__                               
                                 |  HDD LUN  |                              
                                 |  SDD LUN  |                              
                                 |___________|                              
                                       |                                    
                                  _____|_____                             
                                 | Floating  |                            
                                 |   SAN IP  |                                
[ VM Cluster ]                   |___________|                                
  ______________________________   | | | | |   ______________________________ 
 | [ an-node03 ]                |  | | | | |  |                [ an-node06 ] |
 |  _________                   |  | | | | |  |                   _________  |
 | | [ vmA ] |                  |  | | | | |  |                  | [ vmJ ] | |
 | |  _____  |                  |  | | | | |  |                  |  _____  | |
 | | (_hdd_)-=----\             |  | | | | |  |             /----=-(_hdd_) | |
 | |_________|    |             |  | | | | |  |             |    |_________| |
 |  _________     |             |  | | | | |  |             |     _________  |
 | | [ vmB ] |    |             |  | | | | |  |             |    | [ vmK ] | |
 | |  _____  |    |             |  | | | | |  |             |    |  _____  | |
 | | (_hdd_)-=--\ |   __________|  | | | | |  |__________   | /--=-(_hdd_) | |
 | |_________|  | \--| Storage  =--/ | | | \--=  Storage |--/ |  |_________| |
 |  _________   \----| Network ||    | | |    || Network |----/   _________  |
 | | [ vmC ] |  /----|_________||    | | |    ||_________|----\  | [ vmL ] | |
 | |  _____  |  |               |    | | |    |               |  |  _____  | |
 | | (_hdd_)-=--/               |    | | |    |               \--=-(_hdd_) | |
 | |_________|                  |    | | |    |                  |_________| |
 |______________________________|    | | |    |______________________________|            
  ______________________________     | | |     ______________________________ 
 | [ an-node04 ]                |    | | |    |                [ an-node07 ] |
 |  _________                   |    | | |    |                   _________  |
 | | [ vmD ] |                  |    | | |    |                  | [ vmM ] | |
 | |  _____  |                  |    | | |    |                  |  _____  | |
 | | (_hdd_)-=----\             |    | | |    |             /----=-(_hdd_) | |
 | |_________|    |             |    | | |    |             |    |_________| |
 |  _________     |             |    | | |    |             |     _________  |
 | | [ vmE ] |    |             |    | | |    |             |    | [ vmN ] | |
 | |  _____  |    |             |    | | |    |             |    |  _____  | |
 | | (_hdd_)-=--\ |   __________|    | | |    |__________   | /--=-(_hdd_) | |
 | |_________|  | \--| Storage  =----/ | \----=  Storage |--/ |  |_________| |
 |  _________   \----| Network ||      |      || Network |----/   _________  |
 | | [ vmF ] |  /----|_________||      |      ||_________|----\  | [ vmO ] | |
 | |  _____  |  |               |      |      |               |  |  _____  | |
 | | (_hdd_)-=--+               |      |      |               \--=-(_hdd_) | |
 | | (_ssd_)-=--/               |      |      |                  |_________| |
 | |_________|                  |      |      |                              |
 |______________________________|      |      |______________________________|            
  ______________________________       |                                      
 | [ an-node05 ]                |      |                                      
 |  _________                   |      |                                      
 | | [ vmG ] |                  |      |                                      
 | |  _____  |                  |      |                                      
 | | (_hdd_)-=----\             |      |                                      
 | |_________|    |             |      |                                      
 |  _________     |             |      |                                      
 | | [ vmH ] |    |             |      |                                      
 | |  _____  |    |             |      |                                      
 | | (_hdd_)-=--\ |             |      |                                      
 | | (_sdd_)-=--+ |   __________|      |                                      
 | |_________|  | \--| Storage  =------/                                      
 |  _________   \----| Network ||                                             
 | | [ vmI ] |  /----|_________||                                             
 | |  _____  |  |               |                                             
 | | (_hdd_)-=--/               |                                             
 | |_________|                  |                                             
 |______________________________|

Long View

Note: Yes, this is a big graphic, but this is also a big project. I am no artist though, and any help making this clearer is greatly appreciated!
The planned network. This shows separate IPMI and full redundancy through-out the cluster. This is the way a production cluster should be built, but is not expected for dev/test clusters.

Failure Mapping

VM Cluster; Guest VM failure migration planning;

  • Each node can host 5 VMs @ 2GB/VM.
  • This is an N-1 cluster with five nodes; 20 VMs total.
          |    All    | an-node03 | an-node04 | an-node05 | an-node06 | an-node07 |
          | on-line   |   down    |   down    |   down    |   down    |   down    |
----------+-----------+-----------+-----------+-----------+-----------+-----------+
an-node03 |   vm01    |    --     |   vm01    |   vm01    |   vm01    |   vm01    |
          |   vm02    |    --     |   vm02    |   vm02    |   vm02    |   vm02    |
          |   vm03    |    --     |   vm03    |   vm03    |   vm03    |   vm03    |
          |   vm04    |    --     |   vm04    |   vm04    |   vm04    |   vm04    |
          |    --     |    --     |   vm05    |   vm09    |   vm13    |   vm17    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node04 |   vm05    |   vm05    |    --     |   vm05    |   vm05    |   vm05    |
          |   vm06    |   vm06    |    --     |   vm06    |   vm06    |   vm06    |
          |   vm07    |   vm07    |    --     |   vm07    |   vm07    |   vm07    |
          |   vm08    |   vm08    |    --     |   vm08    |   vm08    |   vm08    |
          |    --     |   vm01    |    --     |   vm10    |   vm14    |   vm18    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node05 |   vm09    |   vm09    |   vm09    |    --     |   vm09    |   vm09    |
          |   vm10    |   vm10    |   vm10    |    --     |   vm10    |   vm10    |
          |   vm11    |   vm11    |   vm11    |    --     |   vm11    |   vm11    |
          |   vm12    |   vm12    |   vm12    |    --     |   vm12    |   vm12    |
          |    --     |   vm02    |   vm06    |    --     |   vm15    |   vm19    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node06 |   vm13    |   vm13    |   vm13    |   vm13    |    --     |   vm13    |
          |   vm14    |   vm14    |   vm14    |   vm14    |    --     |   vm14    |
          |   vm15    |   vm15    |   vm15    |   vm15    |    --     |   vm15    |
          |   vm16    |   vm16    |   vm16    |   vm16    |    --     |   vm16    |
          |    --     |   vm03    |   vm07    |   vm11    |    --     |   vm20    |
----------|-----------|-----------|-----------|-----------|-----------|-----------|
an-node07 |   vm17    |   vm17    |   vm17    |   vm17    |   vm17    |    --     |
          |   vm18    |   vm18    |   vm18    |   vm18    |   vm18    |    --     |
          |   vm19    |   vm19    |   vm19    |   vm19    |   vm19    |    --     |
          |   vm20    |   vm20    |   vm20    |   vm20    |   vm20    |    --     |
          |    --     |   vm04    |   vm08    |   vm12    |   vm16    |    --     |
----------+-----------+-----------+-----------+-----------+-----------+-----------+

Cluster Overview

Note: This is not programatically accurate!

This is meant to show, at a logical level, how the parts of a cluster work together. It is the first draft and is likely defective in terrible ways.

[ Resource Managment ]                                                                                                           
  ___________     ___________                                                                                                
 |           |   |           |                                                                                               
 | Service A |   | Service B |                                                                                               
 |___________|   |___________|                                                                                               
            |     |         |                                                                                                    
          __|_____|__    ___|_______________                                                                                     
         |           |  |                   |                                                                                    
         | RGManager |  | Clustered Storage |================================================.                                   
         |___________|  |___________________|                                                |                                   
               |                  |                                                          |                                   
               |__________________|______________                                            |                                 
                            |                    \                                           |                                 
         _________      ____|____                 |                                          |                                 
        |         |    |         |                |                                          |                                 
 /------| Fencing |----| Locking |                |                                          |                                 
 |      |_________|    |_________|                |                                          |                                 
_|___________|_____________|______________________|__________________________________________|_____
 |           |             |                      |                                          |                                  
 |     ______|_____    ____|___                   |                                          |                                  
 |    |            |  |        |                  |                                          |                                  
 |    | Membership |  | Quorum |                  |                                          |                                  
 |    |____________|  |________|                  |                                          |                                  
 |           |____________|                       |                                          |                                  
 |                      __|__                     |                                          |                                  
 |                     /     \                    |                                          |                                  
 |                    { Totem }                   |                                          |                                  
 |                     \_____/                    |                                          |                                  
 |      __________________|_______________________|_______________ ______________            |                                    
 |     |-----------|-----------|----------------|-----------------|--------------|           |                                    
 |  ___|____    ___|____    ___|____         ___|____        _____|_____    _____|_____    __|___                                 
 | |        |  |        |  |        |       |        |      |           |  |           |  |      |                                
 | | Node 1 |  | Node 2 |  | Node 3 |  ...  | Node N |      | Storage 1 |==| Storage 2 |==| DRBD |                                
 | |________|  |________|  |________|       |________|      |___________|  |___________|  |______|                                
 \_____|___________|___________|________________|_________________|______________|                                                
                                                                                                                                 
[ Cluster Communication ]

Network IPs

SAN: 10.10.1.1

Node:
          | IFN         | SN         | BCN       | IPMI      |
----------+-------------+------------+-----------+-----------+
an-node01 | 10.255.0.1  | 10.10.0.1  | 10.20.0.1 | 10.20.1.1 |                                                 
an-node02 | 10.255.0.2  | 10.10.0.2  | 10.20.0.2 | 10.20.1.2 |                                                 
an-node03 | 10.255.0.3  | 10.10.0.3  | 10.20.0.3 | 10.20.1.3 |                                                 
an-node04 | 10.255.0.4  | 10.10.0.4  | 10.20.0.4 | 10.20.1.4 |                                                 
an-node05 | 10.255.0.5  | 10.10.0.5  | 10.20.0.5 | 10.20.1.5 |                                                 
an-node06 | 10.255.0.6  | 10.10.0.6  | 10.20.0.6 | 10.20.1.6 |                                                 
an-node07 | 10.255.0.7  | 10.10.0.7  | 10.20.0.7 | 10.20.1.7 |                                                 
----------+-------------+------------+-----------+-----------+

Aux Equipment:
          | BCN         |
----------+-------------+
pdu1      | 10.20.2.1   |                                                                                                  
pdu2      | 10.20.2.2   |                                                                                                  
switch1   | 10.20.2.3   |                                                                                                  
switch2   | 10.20.2.4   |                                                                                                  
ups1      | 10.20.2.5   |                                                                                         
ups2      | 10.20.2.6   |                                                                                         
----------+-------------+
                                                                                                                  
VMs:                                                                                                              
          | VMN         |                                                                                         
----------+-------------+
vm01      | 10.254.0.1  |                                                                                         
vm02      | 10.254.0.2  |                                                                                         
vm03      | 10.254.0.3  |                                                                                         
vm04      | 10.254.0.4  |                                                                                         
vm05      | 10.254.0.5  |                                                                                         
vm06      | 10.254.0.6  |                                                                                         
vm07      | 10.254.0.7  |                                                                                         
vm08      | 10.254.0.8  |                                                                                         
vm09      | 10.254.0.9  |                                                                                         
vm10      | 10.254.0.10 |                                                                                         
vm11      | 10.254.0.11 |                                                                                         
vm12      | 10.254.0.12 |                                                                                         
vm13      | 10.254.0.13 |                                                                                         
vm14      | 10.254.0.14 |                                                                                         
vm15      | 10.254.0.15 |                                                                                         
vm16      | 10.254.0.16 |                                                                                         
vm17      | 10.254.0.17 |                                                                                         
vm18      | 10.254.0.18 |                                                                                         
vm19      | 10.254.0.19 |                                                                                         
vm20      | 10.254.0.20 |                                                                                         
----------+-------------+

Install The Cluster Software

If you are using Red Hat Enterprise Linux, you will need to add the RHEL Server Optional (v. 6 64-bit x86_64) channel for each node in your cluster. You can do this in RHN by going the your subscription management page, clicking on each server, clicking on "Alter Channel Subscriptions", click to enable the RHEL Server Optional (v. 6 64-bit x86_64) channel and then by clicking on "Change Subscription".

This actual installation is simple, just use yum to install cman.

yum install cman fence-agents rgmanager resource-agents lvm2-cluster gfs2-utils python-virtinst libvirt qemu-kvm-tools qemu-kvm virt-manager virt-viewer virtio-win

Initial Config

Everything uses ricci, which itself needs to have a password set. I set this to match root.

Both:

passwd ricci
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

With these decisions and the information gathered, here is what our first /etc/cluster/cluster.conf file will look like.

touch /etc/cluster/cluster.conf
vim /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="1" name="an-cluster">
	<cman expected_votes="1" two_node="1" />
	<clusternodes>
		<clusternode name="an-node01.alteeve.ca" nodeid="1">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an01" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="1" />
					<device action="reboot" name="pdu2" port="1" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node02.alteeve.ca" nodeid="2">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an02" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="2" />
					<device action="reboot" name="pdu2" port="2" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node03.alteeve.ca" nodeid="3">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an03" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="3" />
					<device action="reboot" name="pdu2" port="3" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node04.alteeve.ca" nodeid="4">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an04" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="4" />
					<device action="reboot" name="pdu2" port="4" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node05.alteeve.ca" nodeid="5">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an05" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="5" />
					<device action="reboot" name="pdu2" port="5" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node06.alteeve.ca" nodeid="6">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an06" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="6" />
					<device action="reboot" name="pdu2" port="6" />
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node07.alteeve.ca" nodeid="7">
			<fence>
				<method name="ipmi">
					<device action="reboot" name="ipmi_an07" />
				</method>
				<method name="pdu">
					<device action="reboot" name="pdu1" port="7" />
					<device action="reboot" name="pdu2" port="7" />
				</method>
			</fence>
		</clusternode>
	</clusternodes>
	<fencedevices>
		<fencedevice agent="fence_ipmilan" ipaddr="an-node01.ipmi" login="root" name="ipmi_an01" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node02.ipmi" login="root" name="ipmi_an02" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node03.ipmi" login="root" name="ipmi_an03" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node04.ipmi" login="root" name="ipmi_an04" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node05.ipmi" login="root" name="ipmi_an05" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node06.ipmi" login="root" name="ipmi_an06" passwd="secret" />
		<fencedevice agent="fence_ipmilan" ipaddr="an-node07.ipmi" login="root" name="ipmi_an07" passwd="secret" />
		<fencedevice agent="fence_apc_snmp" ipaddr="pdu1.alteeve.ca" name="pdu1" />
		<fencedevice agent="fence_apc_snmp" ipaddr="pdu2.alteeve.ca" name="pdu2" />
	</fencedevices>
	<fence_daemon post_join_delay="30" />
	<totem rrp_mode="none" secauth="off" />
	<rm>
		<resources>
			<ip address="10.10.1.1" monitor_link="on" />
			<script file="/etc/init.d/tgtd" name="tgtd" />
			<script file="/etc/init.d/drbd" name="drbd" />
			<script file="/etc/init.d/clvmd" name="clvmd" />
			<script file="/etc/init.d/gfs2" name="gfs2" />
			<script file="/etc/init.d/libvirtd" name="libvirtd" />
		</resources>
		<failoverdomains>
			<!-- Used for storage -->
			<!-- SAN Nodes -->
			<failoverdomain name="an1_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node01.alteeve.ca" />
			</failoverdomain>
			<failoverdomain name="an2_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node02.alteeve.ca" />
			</failoverdomain>
			
			<!-- VM Nodes -->
			<failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" />
			</failoverdomain>
			<failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca" />
			</failoverdomain>
			<failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca" />
			</failoverdomain>
			<failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca" />
			</failoverdomain>
			<failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca" />
			</failoverdomain>
			
			<!-- Domain for the SAN -->
			<failoverdomain name="an1_primary" nofailback="1" ordered="1" restricted="0">
				<failoverdomainnode name="an-node01.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node02.alteeve.ca" priority="2" />
			</failoverdomain>
			
			<!-- Domains for VMs running primarily on an-node03 -->
			<failoverdomain name="an3_an4" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an3_an5" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an3_an6" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an3_an7" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
			</failoverdomain>
			
			<!-- Domains for VMs running primarily on an-node04 -->
			<failoverdomain name="an4_an3" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an4_an5" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an4_an6" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an4_an7" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
			</failoverdomain>
			
			<!-- Domains for VMs running primarily on an-node05 -->
			<failoverdomain name="an5_an3" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an5_an4" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an5_an6" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an5_an7" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
			</failoverdomain>
			
			<!-- Domains for VMs running primarily on an-node06 -->
			<failoverdomain name="an6_an3" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an6_an4" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an6_an5" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an6_an7" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node07.alteeve.ca" priority="2" />
			</failoverdomain>
			
			<!-- Domains for VMs running primarily on an-node07 -->
			<failoverdomain name="an7_an3" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node03.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an7_an4" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node04.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an7_an5" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node05.alteeve.ca" priority="2" />
			</failoverdomain>
			<failoverdomain name="an7_an6" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca" priority="1" />
				<failoverdomainnode name="an-node06.alteeve.ca" priority="2" />
			</failoverdomain>
		</failoverdomains>
		
		<!-- SAN Services -->
		<service autostart="1" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="tgtd" />
				</script>
			</script>
		</service>
		<service autostart="1" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="tgtd" />
				</script>
			</script>
		</service>
		<service autostart="1" domain="an1_primary" name="san_ip" recovery="relocate">
			<ip ref="10.10.1.1" />
		</service>
		
		<!-- VM Storage services. -->
		<service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="gfs2">
						<script ref="libvirtd" />
					</script>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="gfs2">
						<script ref="libvirtd" />
					</script>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="gfs2">
						<script ref="libvirtd" />
					</script>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="gfs2">
						<script ref="libvirtd" />
					</script>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart" restart_expire_time="0">
			<script ref="drbd">
				<script ref="clvmd">
					<script ref="gfs2">
						<script ref="libvirtd" />
					</script>
				</script>
			</script>
		</service>
		
		<!-- VM Services -->
		<!-- VMs running primarily on an-node03 -->
		<vm name="vm01" domain="an03_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm02" domain="an03_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm03" domain="an03_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm04" domain="an03_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		
		<!-- VMs running primarily on an-node04 -->
		<vm name="vm05" domain="an04_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm06" domain="an04_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm07" domain="an04_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm08" domain="an04_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		
		<!-- VMs running primarily on an-node05 -->
		<vm name="vm09" domain="an05_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm10" domain="an05_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm11" domain="an05_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm12" domain="an05_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		
		<!-- VMs running primarily on an-node06 -->
		<vm name="vm13" domain="an06_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm14" domain="an06_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm15" domain="an06_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm16" domain="an06_an07" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		
		<!-- VMs running primarily on an-node07 -->
		<vm name="vm17" domain="an07_an03" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm18" domain="an07_an04" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm19" domain="an07_an05" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
		<vm name="vm20" domain="an07_an06" path="/shared/definitions/" autostart="0" exclusive="0" recovery="restart" max_restarts="2" restart_expire_time="600"/>
	</rm>
</cluster>

Save the file, then validate it. If it fails, address the errors and try again.

ip addr list | grep <ip>
rg_test test /etc/cluster/cluster.conf
ccs_config_validate
Configuration validates

Push it to the other node:

rsync -av /etc/cluster/cluster.conf root@an-node02:/etc/cluster/
sending incremental file list
cluster.conf

sent 781 bytes  received 31 bytes  541.33 bytes/sec
total size is 701  speedup is 0.86

Start:


DO NOT PROCEED UNTIL YOUR cluster.conf FILE VALIDATES!

Unless you have it perfect, your cluster will fail.

Once it validates, proceed.

Starting The Cluster For The First Time

By default, if you start one node only and you've enabled the <cman two_node="1" expected_votes="1"/> option as we have done, the lone server will effectively gain quorum. It will try to connect to the cluster, but there won't be a cluster to connect to, so it will fence the other node after a timeout period. This timeout is 6 seconds by default.

For now, we will leave the default as it is. If you're interested in changing it though, the argument you are looking for is post_join_delay.

This behaviour means that we'll want to start both nodes well within six seconds of one another, least the slower one get needlessly fenced.

Left off here

Note to help minimize dual-fences:

  • you could add FENCED_OPTS="-f 5" to /etc/sysconfig/cman on *one* node (ilo fence devices may need this)

DRBD Config

Install from source:

Both:

# Obliterate peer - fence via cman
wget -c https://alteeve.ca/files/an-cluster/sbin/obliterate-peer.sh -O /sbin/obliterate-peer.sh
chmod a+x /sbin/obliterate-peer.sh
ls -lah /sbin/obliterate-peer.sh

# Download, compile and install DRBD
wget -c http://oss.linbit.com/drbd/8.3/drbd-8.3.11.tar.gz
tar -xvzf drbd-8.3.11.tar.gz
cd drbd-8.3.11
./configure \
   --prefix=/usr \
   --localstatedir=/var \
   --sysconfdir=/etc \
   --with-utils \
   --with-km \
   --with-udev \
   --with-pacemaker \
   --with-rgmanager \
   --with-bashcompletion
make
make install
chkconfig --add drbd
chkconfig drbd off

Configure

an-node01:

# Configure DRBD's global value.
cp /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.orig
vim /etc/drbd.d/global_common.conf
diff -u /etc/drbd.d/global_common.conf
--- /etc/drbd.d/global_common.conf.orig	2011-08-01 21:58:46.000000000 -0400
+++ /etc/drbd.d/global_common.conf	2011-08-01 23:18:27.000000000 -0400
@@ -15,24 +15,35 @@
 		# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";
 		# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";
 		# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
+		fence-peer		"/sbin/obliterate-peer.sh";
 	}
 
 	startup {
 		# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb
+		become-primary-on	both;
+		wfc-timeout		300;
+		degr-wfc-timeout	120;
 	}
 
 	disk {
 		# on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes
 		# no-disk-drain no-md-flushes max-bio-bvecs
+		fencing			resource-and-stonith;
 	}
 
 	net {
 		# sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers
 		# max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret
 		# after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork
+		allow-two-primaries;
+		after-sb-0pri		discard-zero-changes;
+		after-sb-1pri		discard-secondary;
+		after-sb-2pri		disconnect;
 	}
 
 	syncer {
 		# rate after al-extents use-rle cpu-mask verify-alg csums-alg
+		# This should be no more than 30% of the maximum sustainable write speed.
+		rate			20M;
 	}
 }
vim /etc/drbd.d/r0.res
resource r0 {
        device          /dev/drbd0;
        meta-disk       internal;
        on an-node01.alteeve.ca {
                address         192.168.2.71:7789;
                disk            /dev/sda5;
        }
        on an-node02.alteeve.ca {
                address         192.168.2.72:7789;
                disk            /dev/sda5;
        }
}
cp /etc/drbd.d/r0.res /etc/drbd.d/r1.res 
vim /etc/drbd.d/r1.res
resource r1 {
        device          /dev/drbd1;
        meta-disk       internal;
        on an-node01.alteeve.ca {
                address         192.168.2.71:7790;
                disk            /dev/sdb1;
        }
        on an-node02.alteeve.ca {
                address         192.168.2.72:7790;
                disk            /dev/sdb1;
        }
}
Note: If you have multiple DRBD resources on on (set of) backing disks, consider adding syncer { after <minor-1>; }. For example, tell /dev/drbd1 to wait for /dev/drbd0 by adding syncer { after 0; }. This will prevent simultaneous resync's which could seriously impact performance. Resources will wait in state until the defined resource has completed sync'ing.

Validate:

drbdadm dump
  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 369th user to install this version
# /usr/etc/drbd.conf
common {
    protocol               C;
    net {
        allow-two-primaries;
        after-sb-0pri    discard-zero-changes;
        after-sb-1pri    discard-secondary;
        after-sb-2pri    disconnect;
    }
    disk {
        fencing          resource-and-stonith;
    }
    syncer {
        rate             20M;
    }
    startup {
        wfc-timeout      300;
        degr-wfc-timeout 120;
        become-primary-on both;
    }
    handlers {
        pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
        local-io-error   "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
        fence-peer       /sbin/obliterate-peer.sh;
    }
}

# resource r0 on an-node01.alteeve.ca: not ignored, not stacked
resource r0 {
    on an-node01.alteeve.ca {
        device           /dev/drbd0 minor 0;
        disk             /dev/sda5;
        address          ipv4 192.168.2.71:7789;
        meta-disk        internal;
    }
    on an-node02.alteeve.ca {
        device           /dev/drbd0 minor 0;
        disk             /dev/sda5;
        address          ipv4 192.168.2.72:7789;
        meta-disk        internal;
    }
}

# resource r1 on an-node01.alteeve.ca: not ignored, not stacked
resource r1 {
    on an-node01.alteeve.ca {
        device           /dev/drbd1 minor 1;
        disk             /dev/sdb1;
        address          ipv4 192.168.2.71:7790;
        meta-disk        internal;
    }
    on an-node02.alteeve.ca {
        device           /dev/drbd1 minor 1;
        disk             /dev/sdb1;
        address          ipv4 192.168.2.72:7790;
        meta-disk        internal;
    }
}
rsync -av /etc/drbd.d root@an-node02:/etc/
drbd.d/
drbd.d/global_common.conf
drbd.d/global_common.conf.orig
drbd.d/r0.res
drbd.d/r1.res

sent 3523 bytes  received 110 bytes  7266.00 bytes/sec
total size is 3926  speedup is 1.08

Initialize and First start

Both:

Create the meta-data.

modprobe
drbdadm create-md r{0,1}
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success

Attach, connect and confirm (after both have attached and connected):

drbdadm attach r{0,1}
drbdadm connect r{0,1}
cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
 0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:441969960
 1: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:29309628

There is no data, so force both devices to be instantly UpToDate:

drbdadm -- --clear-bitmap new-current-uuid r{0,1}
cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
 0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
 1: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

Set both to primary and run a final check.

drbdadm primary r{0,1}
cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
 0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:672 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
 1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:672 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

Update the cluster

vim /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="17" name="an-clusterA">
        <cman expected_votes="1" two_node="1"/>
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node01.alteeve.ca" nodeid="1">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="1"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node02.alteeve.ca" nodeid="2">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="2"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <ip address="192.168.2.100" monitor_link="on"/>
                        <script file="/etc/init.d/drbd" name="drbd"/>
                        <script file="/etc/init.d/clvmd" name="clvmd"/>
                        <script file="/etc/init.d/tgtd" name="tgtd"/>
                </resources>
                <failoverdomains>
                        <failoverdomain name="an1_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node01.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an2_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node02.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an1_primary" nofailback="1" ordered="1" restricted="0">
                                <failoverdomainnode name="an-node01.alteeve.ca" priority="1"/>
                                <failoverdomainnode name="an-node02.alteeve.ca" priority="2"/>
                        </failoverdomain>
                </failoverdomains>
                <service autostart="0" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="0" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd"/>
                        </script>
                </service>
        </rm>
</cluster>
rg_test test /etc/cluster/cluster.conf
Running in test mode.
Loading resource rule from /usr/share/cluster/oralistener.sh
Loading resource rule from /usr/share/cluster/apache.sh
Loading resource rule from /usr/share/cluster/SAPDatabase
Loading resource rule from /usr/share/cluster/postgres-8.sh
Loading resource rule from /usr/share/cluster/lvm.sh
Loading resource rule from /usr/share/cluster/mysql.sh
Loading resource rule from /usr/share/cluster/lvm_by_vg.sh
Loading resource rule from /usr/share/cluster/service.sh
Loading resource rule from /usr/share/cluster/samba.sh
Loading resource rule from /usr/share/cluster/SAPInstance
Loading resource rule from /usr/share/cluster/checkquorum
Loading resource rule from /usr/share/cluster/ocf-shellfuncs
Loading resource rule from /usr/share/cluster/svclib_nfslock
Loading resource rule from /usr/share/cluster/script.sh
Loading resource rule from /usr/share/cluster/clusterfs.sh
Loading resource rule from /usr/share/cluster/fs.sh
Loading resource rule from /usr/share/cluster/oracledb.sh
Loading resource rule from /usr/share/cluster/nfsserver.sh
Loading resource rule from /usr/share/cluster/netfs.sh
Loading resource rule from /usr/share/cluster/orainstance.sh
Loading resource rule from /usr/share/cluster/vm.sh
Loading resource rule from /usr/share/cluster/lvm_by_lv.sh
Loading resource rule from /usr/share/cluster/tomcat-6.sh
Loading resource rule from /usr/share/cluster/ip.sh
Loading resource rule from /usr/share/cluster/nfsexport.sh
Loading resource rule from /usr/share/cluster/openldap.sh
Loading resource rule from /usr/share/cluster/ASEHAagent.sh
Loading resource rule from /usr/share/cluster/nfsclient.sh
Loading resource rule from /usr/share/cluster/named.sh
Loaded 24 resource rules
=== Resources List ===
Resource type: ip
Instances: 1/1
Agent: ip.sh
Attributes:
  address = 192.168.2.100 [ primary unique ]
  monitor_link = on
  nfslock [ inherit("service%nfslock") ]

Resource type: script
Agent: script.sh
Attributes:
  name = drbd [ primary unique ]
  file = /etc/init.d/drbd [ unique required ]
  service_name [ inherit("service%name") ]

Resource type: script
Agent: script.sh
Attributes:
  name = clvmd [ primary unique ]
  file = /etc/init.d/clvmd [ unique required ]
  service_name [ inherit("service%name") ]

Resource type: script
Agent: script.sh
Attributes:
  name = tgtd [ primary unique ]
  file = /etc/init.d/tgtd [ unique required ]
  service_name [ inherit("service%name") ]

Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = an1_storage [ primary unique required ]
  domain = an1_only [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = restart [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0

Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = an2_storage [ primary unique required ]
  domain = an2_only [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = restart [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0

Resource type: service [INLINE]
Instances: 1/1
Agent: service.sh
Attributes:
  name = san_ip [ primary unique required ]
  domain = an1_primary [ reconfig ]
  autostart = 0 [ reconfig ]
  exclusive = 0 [ reconfig ]
  nfslock = 0
  nfs_client_cache = 0
  recovery = relocate [ reconfig ]
  depend_mode = hard
  max_restarts = 0
  restart_expire_time = 0
  priority = 0

=== Resource Tree ===
service (S0) {
  name = "an1_storage";
  domain = "an1_only";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "restart";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  script (S0) {
    name = "drbd";
    file = "/etc/init.d/drbd";
    service_name = "an1_storage";
    script (S0) {
      name = "clvmd";
      file = "/etc/init.d/clvmd";
      service_name = "an1_storage";
    }
  }
}
service (S0) {
  name = "an2_storage";
  domain = "an2_only";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "restart";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  script (S0) {
    name = "drbd";
    file = "/etc/init.d/drbd";
    service_name = "an2_storage";
    script (S0) {
      name = "clvmd";
      file = "/etc/init.d/clvmd";
      service_name = "an2_storage";
    }
  }
}
service (S0) {
  name = "san_ip";
  domain = "an1_primary";
  autostart = "0";
  exclusive = "0";
  nfslock = "0";
  nfs_client_cache = "0";
  recovery = "relocate";
  depend_mode = "hard";
  max_restarts = "0";
  restart_expire_time = "0";
  priority = "0";
  ip (S0) {
    address = "192.168.2.100";
    monitor_link = "on";
    nfslock = "0";
  }
}
=== Failover Domains ===
Failover domain: an1_only
Flags: Restricted No Failback
  Node an-node01.alteeve.ca (id 1, priority 0)
Failover domain: an2_only
Flags: Restricted No Failback
  Node an-node02.alteeve.ca (id 2, priority 0)
Failover domain: an1_primary
Flags: Ordered No Failback
  Node an-node01.alteeve.ca (id 1, priority 1)
  Node an-node02.alteeve.ca (id 2, priority 2)
=== Event Triggers ===
Event Priority Level 100:
  Name: Default
    (Any event)
    File: /usr/share/cluster/default_event_script.sl
[root@an-node01 ~]# cman_tool version -r
You have not authenticated to the ricci daemon on an-node01.alteeve.ca
Password: 
[root@an-node01 ~]# clusvcadm -e service:an1_storage
Local machine trying to enable service:an1_storage...Success
service:an1_storage is now running on an-node01.alteeve.ca
[root@an-node01 ~]# cat /proc/drbd 
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
 0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:924 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
 1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:916 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
cman_tool version -r
You have not authenticated to the ricci daemon on an-node01.alteeve.ca
Password:

an-node01:

clusvcadm -e service:an1_storage
service:an1_storage is now running on an-node01.alteeve.ca

an-node02:

clusvcadm -e service:an2_storage
service:an2_storage is now running on an-node02.alteeve.ca

Either

cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
GIT-hash: 0de839cee13a4160eed6037c4bddd066645e23c5 build by root@an-node01.alteeve.ca, 2011-08-01 22:04:32
 0: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:924 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0
 1: cs:Connected ro:Primary/Primary ds:UpToDate/UpToDate C r-----
    ns:0 nr:0 dw:0 dr:916 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0

Configure Clustered LVM

an-node01:

cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig
vim /etc/lvm/lvm.conf
diff -u /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf
--- /etc/lvm/lvm.conf.orig	2011-08-02 21:59:01.000000000 -0400
+++ /etc/lvm/lvm.conf	2011-08-02 22:00:17.000000000 -0400
@@ -50,7 +50,8 @@
 
 
     # By default we accept every block device:
-    filter = [ "a/.*/" ]
+    #filter = [ "a/.*/" ]
+    filter = [ "a|/dev/drbd*|", "r/.*/" ]
 
     # Exclude the cdrom drive
     # filter = [ "r|/dev/cdrom|" ]
@@ -308,7 +309,8 @@
     # Type 3 uses built-in clustered locking.
     # Type 4 uses read-only locking which forbids any operations that might 
     # change metadata.
-    locking_type = 1
+    #locking_type = 1
+    locking_type = 3
 
     # Set to 0 to fail when a lock request cannot be satisfied immediately.
     wait_for_locks = 1
@@ -324,7 +326,8 @@
     # to 1 an attempt will be made to use local file-based locking (type 1).
     # If this succeeds, only commands against local volume groups will proceed.
     # Volume Groups marked as clustered will be ignored.
-    fallback_to_local_locking = 1
+    #fallback_to_local_locking = 1
+    fallback_to_local_locking = 0
 
     # Local non-LV directory that holds file-based locks while commands are
     # in progress.  A directory like /tmp that may get wiped on reboot is OK.
rsync -av /etc/lvm/lvm.conf root@an-node02:/etc/lvm/
sending incremental file list
lvm.conf

sent 2412 bytes  received 247 bytes  5318.00 bytes/sec
total size is 24668  speedup is 9.28

Create the LVM PVs, VGs and LVs.

an-node01:

pvcreate /dev/drbd{0,1}
  Physical volume "/dev/drbd0" successfully created
  Physical volume "/dev/drbd1" successfully created

an-node02:

pvscan
  PV /dev/drbd0                      lvm2 [421.50 GiB]
  PV /dev/drbd1                      lvm2 [27.95 GiB]
  Total: 2 [449.45 GiB] / in use: 0 [0   ] / in no VG: 2 [449.45 GiB]

an-node01:

vgcreate -c y hdd_vg0 /dev/drbd0 && vgcreate -c y sdd_vg0 /dev/drbd1
  Clustered volume group "hdd_vg0" successfully created
  Clustered volume group "ssd_vg0" successfully created

an-node02:

vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "ssd_vg0" using metadata type lvm2
  Found volume group "hdd_vg0" using metadata type lvm2

an-node01:

lvcreate -l 100%FREE -n lun0 /dev/hdd_vg0 && lvcreate -l 100%FREE -n lun1 /dev/ssd_vg0
  Logical volume "lun0" created
  Logical volume "lun1" created

an-node02:

lvscan
  ACTIVE            '/dev/ssd_vg0/lun1' [27.95 GiB] inherit
  ACTIVE            '/dev/hdd_vg0/lun0' [421.49 GiB] inherit

iSCSI notes

IET vs tgt pros and cons needed.

default iscsi port is 3260

initiator: This is the client. target: This is the server side. sid: Session ID; Found with iscsiadm -m session -P 1. SID and sysfs path are not persistent, partially start-order based. iQN: iSCSI Qualified Name; This is a string that uniquely identifies targets and initiators.

Both:

yum install iscsi-initiator-utils scsi-target-utils

an-node01:

cp /etc/tgt/targets.conf /etc/tgt/targets.conf.orig
vim /etc/tgt/targets.conf
diff -u /etc/tgt/targets.conf.orig /etc/tgt/targets.conf
--- /etc/tgt/targets.conf.orig	2011-07-31 12:38:35.000000000 -0400
+++ /etc/tgt/targets.conf	2011-08-02 22:19:06.000000000 -0400
@@ -251,3 +251,9 @@
 #        vendor_id VENDOR1
 #    </direct-store>
 #</target>
+
+<target iqn.2011-08.com.alteeve:an-clusterA.target01>
+	direct-store /dev/drbd0
+	direct-store /dev/drbd1
+	vendor_id Alteeve
rsync -av /etc/tgt/targets.conf root@an-node02:/etc/tgt/
sending incremental file list
targets.conf

sent 909 bytes  received 97 bytes  670.67 bytes/sec
total size is 7093  speedup is 7.05

Update the cluster

               <service autostart="0" domain="an1_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd">
                                        <script ref="tgtd"/>
                                </script>
                        </script>
                </service>
                <service autostart="0" domain="an2_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart" restart_expire_time="0">
                        <script ref="drbd">
                                <script ref="clvmd">
                                        <script ref="tgtd"/>
                                </script>
                        </script>
                </service>

Connect to the SAN from a VM node

an-node03+:

iscsiadm -m discovery -t sendtargets -p 192.168.2.100
192.168.2.100:3260,1 iqn.2011-08.com.alteeve:an-clusterA.target01
iscsiadm --mode node --portal 192.168.2.100 --target iqn.2011-08.com.alteeve:an-clusterA.target01 --login
Logging in to [iface: default, target: iqn.2011-08.com.alteeve:an-clusterA.target01, portal: 192.168.2.100,3260]
Login to [iface: default, target: iqn.2011-08.com.alteeve:an-clusterA.target01, portal: 192.168.2.100,3260] successful.
fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          33      262144   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040   83  Linux
/dev/sda3            5255        5777     4194304   82  Linux swap / Solaris

Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

Setup the VM Cluster

Install RPMs.

yum -y install lvm2-cluster cman fence-agents

Configure lvm.conf.

cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig
vim /etc/lvm/lvm.conf
diff -u /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf
--- /etc/lvm/lvm.conf.orig	2011-08-02 21:59:01.000000000 -0400
+++ /etc/lvm/lvm.conf	2011-08-03 00:35:45.000000000 -0400
@@ -308,7 +308,8 @@
     # Type 3 uses built-in clustered locking.
     # Type 4 uses read-only locking which forbids any operations that might 
     # change metadata.
-    locking_type = 1
+    #locking_type = 1
+    locking_type = 3
 
     # Set to 0 to fail when a lock request cannot be satisfied immediately.
     wait_for_locks = 1
@@ -324,7 +325,8 @@
     # to 1 an attempt will be made to use local file-based locking (type 1).
     # If this succeeds, only commands against local volume groups will proceed.
     # Volume Groups marked as clustered will be ignored.
-    fallback_to_local_locking = 1
+    #fallback_to_local_locking = 1
+    fallback_to_local_locking = 0
 
     # Local non-LV directory that holds file-based locks while commands are
     # in progress.  A directory like /tmp that may get wiped on reboot is OK.
rsync -av /etc/lvm/lvm.conf root@an-node04:/etc/lvm/
sending incremental file list
lvm.conf

sent 873 bytes  received 247 bytes  2240.00 bytes/sec
total size is 24625  speedup is 21.99
rsync -av /etc/lvm/lvm.conf root@an-node05:/etc/lvm/
sending incremental file list
lvm.conf

sent 873 bytes  received 247 bytes  2240.00 bytes/sec
total size is 24625  speedup is 21.99

Config the cluster.

vim /etc/cluster/cluster.conf
<?xml version="1.0"?>
<cluster config_version="5" name="an-clusterB">
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node03.alteeve.ca" nodeid="1">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="3"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node04.alteeve.ca" nodeid="2">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="4"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node05.alteeve.ca" nodeid="3">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="5"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <script file="/etc/init.d/iscsi" name="iscsi" />
                        <script file="/etc/init.d/clvmd" name="clvmd" />
                </resources>
                <failoverdomains>
                        <failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node03.alteeve.ca" />
                        </failoverdomain>
                        <failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node04.alteeve.ca" />
                        </failoverdomain>
                        <failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node05.alteeve.ca" />
                        </failoverdomain>
                </failoverdomains>
                <service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an1_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
                <service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an2_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd"/>
                        </script>
                </service>
        </rm>   
</cluster>
ccs_config_validate
Configuration validates

Make sure iscsi and clvmd do not start on boot, stop both, then make sure they start and stop cleanly.

chkconfig clvmd off; chkconfig iscsi off; /etc/init.d/iscsi stop && /etc/init.d/clvmd stop
Stopping iscsi:                                            [  OK  ]
/etc/init.d/clvmd start && /etc/init.d/iscsi start && /etc/init.d/iscsi stop && /etc/init.d/clvmd stop
Starting clvmd: 
Activating VG(s):   No volume groups found
                                                           [  OK  ]
Starting iscsi:                                            [  OK  ]
Stopping iscsi:                                            [  OK  ]
Signaling clvmd to exit                                    [  OK  ]
clvmd terminated                                           [  OK  ]

Use the cluster to stop (in case it autostarted before now) and then start the services.

# Disable (stop)
clusvcadm -d service:an3_storage
clusvcadm -d service:an4_storage
clusvcadm -d service:an5_storage
# Enable (start)
clusvcadm -e service:an3_storage -m an-node03.alteeve.ca
clusvcadm -e service:an4_storage -m an-node04.alteeve.ca
clusvcadm -e service:an5_storage -m an-node05.alteeve.ca
# Check
clustat
Cluster Status for an-clusterB @ Wed Aug  3 00:25:10 2011
Member Status: Quorate

 Member Name                             ID   Status
 ------ ----                             ---- ------
 an-node03.alteeve.ca                        1 Online, Local, rgmanager
 an-node04.alteeve.ca                        2 Online, rgmanager
 an-node05.alteeve.ca                        3 Online, rgmanager

 Service Name                   Owner (Last)                   State         
 ------- ----                   ----- ------                   -----         
 service:an3_storage            an-node03.alteeve.ca           started       
 service:an4_storage            an-node04.alteeve.ca           started       
 service:an5_storage            an-node05.alteeve.ca           started

Flush iSCSI's Cache

If you remove an iQN (or change the name of one), the /etc/init.d/iscsi script will return errors. To flush it and re-scan:

I am sure there is a more elegant way.

/etc/init.d/iscsi stop && rm -rf /var/lib/iscsi/nodes/* && iscsiadm -m discovery -t sendtargets -p 192.168.2.100

Setup the VM Cluster's Clustered LVM

Partition the SAN disks

an-node03:

fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          33      262144   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040   83  Linux
/dev/sda3            5255        5777     4194304   82  Linux swap / Solaris

Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Create partitions.

fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x403f1fb8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-55022, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-55022, default 55022): 
Using default value 55022

Command (m for help): p

Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       55022   441964183+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       55022   441964183+  8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xba7503eb.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-58613759, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-58613759, default 58613759): 
Using default value 58613759

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders, total 58613760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba7503eb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    58613759    29305856   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f4a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          33      262144   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              33        5255    41943040   83  Linux
/dev/sda3            5255        5777     4194304   82  Linux swap / Solaris

Disk /dev/sdc: 30.0 GB, 30010245120 bytes
64 heads, 32 sectors/track, 28620 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba7503eb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               2       28620    29305856   8e  Linux LVM

Disk /dev/sdb: 452.6 GB, 452573790208 bytes
255 heads, 63 sectors/track, 55022 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x403f1fb8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       55022   441964183+  8e  Linux LVM

Setup LVM devices

Create PV.

an-node03:

pvcreate /dev/sd{b,c}1
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdc1" successfully created

an-node04 and an-node05:

pvscan
  PV /dev/sdb1                      lvm2 [421.49 GiB]
  PV /dev/sdc1                      lvm2 [27.95 GiB]
  Total: 2 [449.44 GiB] / in use: 0 [0   ] / in no VG: 2 [449.44 GiB]

Create the VGs.

an-node03:

vgcreate -c y san_vg01 /dev/sdb1
  Clustered volume group "san_vg01" successfully created
vgcreate -c y san_vg02 /dev/sdc1
  Clustered volume group "san_vg02" successfully created

an-node04 and an-node05:

vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "san_vg02" using metadata type lvm2
  Found volume group "san_vg01" using metadata type lvm2

Create the first VM's LVs.

an-node03:

lvcreate -L 10G -n shared01 /dev/san_vg01
  Logical volume "shared01" created
lvcreate -L 50G -n vm0001_hdd1 /dev/san_vg01
  Logical volume "vm0001_hdd1" created
lvcreate -L 10G -n vm0001_ssd1 /dev/san_vg02
  Logical volume "vm0001_ssd1" created

an-node04 and an-node05:

lvscan
  ACTIVE            '/dev/san_vg01/shared01' [10.00 GiB] inherit
  ACTIVE            '/dev/san_vg02/vm0001_ssd1' [10.00 GiB] inherit
  ACTIVE            '/dev/san_vg01/vm0001_hdd1' [50.00 GiB] inherit

Create Shared GFS2 Partition

an-node03:

mkfs.gfs2 -p lock_dlm -j 5 -t an-clusterB:shared01 /dev/san_vg01/shared01
This will destroy any data on /dev/san_vg01/shared01.
It appears to contain: symbolic link to `../dm-2'

Are you sure you want to proceed? [y/n] y

Device:                    /dev/san_vg01/shared01
Blocksize:                 4096
Device Size                10.00 GB (2621440 blocks)
Filesystem Size:           10.00 GB (2621438 blocks)
Journals:                  5
Resource Groups:           40
Locking Protocol:          "lock_dlm"
Lock Table:                "an-clusterB:shared01"
UUID:                      6C0D7D1D-A1D3-ED79-705D-28EE3D674E75

Add it to /etc/fstab (needed for the gfs2 init script to find and mount):

an-node03 - an-node07:

echo `gfs2_edit -p sb /dev/san_vg01/shared01 | grep sb_uuid | sed -e "s/.*sb_uuid  *\(.*\)/UUID=\L\1\E \/shared01\t\tgfs2\trw,suid,dev,exec,nouser,async\t0 0/"` >> /etc/fstab 
cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Jul  8 22:01:41 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2c1f4cb1-959f-4675-b9c7-5d753c303dd1 /                       ext3    defaults        1 1
UUID=9a0224dc-15b4-439e-8d7c-5f9dbcd05e3f /boot                   ext3    defaults        1 2
UUID=4f2a83e8-1769-40d8-ba2a-e1f535306848 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=6c0d7d1d-a1d3-ed79-705d-28ee3d674e75 /shared01 gfs2 rw,suid,dev,exec,nouser,async 0 0

Make the mount point and mount it.

mkdir /shared01
/etc/init.d/gfs2 start
Mounting GFS2 filesystem (/shared01):                      [  OK  ]
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G   35G   9% /
tmpfs                 1.8G   32M  1.8G   2% /dev/shm
/dev/sda1             248M   85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                       10G  647M  9.4G   7% /shared01

Stop GFS2 on all five nodes and update the cluster.conf config.

/etc/init.d/gfs2 stop
Unmounting GFS2 filesystem (/shared01):                    [  OK  ]
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G   35G   9% /
tmpfs                 1.8G   32M  1.8G   2% /dev/shm
/dev/sda1             248M   85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                       10G  647M  9.4G   7% /shared01

an-node03:

<?xml version="1.0"?>
<cluster config_version="9" name="an-clusterB">
        <totem rrp_mode="none" secauth="off"/>
        <clusternodes>
                <clusternode name="an-node03.alteeve.ca" nodeid="3">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="3"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node04.alteeve.ca" nodeid="4">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="4"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node05.alteeve.ca" nodeid="5">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="5"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node06.alteeve.ca" nodeid="6">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="6"/>
                                </method>
                        </fence>
                </clusternode>
                <clusternode name="an-node07.alteeve.ca" nodeid="7">
                        <fence>
                                <method name="apc_pdu">
                                        <device action="reboot" name="pdu2" port="7"/>
                                </method>
                        </fence>
                </clusternode>
        </clusternodes>
        <fencedevices>
                <fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
        </fencedevices>
        <fence_daemon post_join_delay="30"/>
        <rm>
                <resources>
                        <script file="/etc/init.d/iscsi" name="iscsi"/>
                        <script file="/etc/init.d/clvmd" name="clvmd"/>
                        <script file="/etc/init.d/gfs2" name="gfs2"/>
                </resources>
                <failoverdomains>
                        <failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node03.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node04.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node05.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node06.alteeve.ca"/>
                        </failoverdomain>
                        <failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
                                <failoverdomainnode name="an-node07.alteeve.ca"/>
                        </failoverdomain>
                </failoverdomains>
                <service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
                <service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart">
                        <script ref="iscsi">
                                <script ref="clvmd">
                                        <script ref="gfs2"/>
                                </script>
                        </script>
                </service>
        </rm>
</cluster>
cman_tool version -r

Check that rgmanager picked up the updated config and remounted the GFS2 partition.

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              40G  3.3G   35G   9% /
tmpfs                 1.8G   32M  1.8G   2% /dev/shm
/dev/sda1             248M   85M  151M  36% /boot
/dev/mapper/san_vg01-shared01
                       10G  647M  9.4G   7% /shared01

Configure KVM

Host network and VM hypervisor config.

Disable the 'qemu' Bridge

By default, libvirtd creates a bridge called virbr0 designed to connect virtual machines to the first eth0 interface. Our system will not need this, so we will remove it. This bridge is configured in the /etc/libvirt/qemu/networks/default.xml file.

So to remove this bridge, simply delete the contents of the file, stop the bridge, delete the bridge and then stop iptables to make sure any rules created for the bridge are flushed.

cat /dev/null >/etc/libvirt/qemu/networks/default.xml
ifconfig virbr0 down
brctl delbr virbr0
/etc/init.d/iptables stop

Configure Bridges

On an-node03 through an-node07:

vim /etc/sysconfig/network-scripts/ifcfg-{eth,vbr}0

ifcfg-eth0:

# Internet facing
HWADDR="bc:ae:c5:44:8a:de"
DEVICE="eth0"
BRIDGE="vbr0"
BOOTPROTO="static"
IPV6INIT="yes"
NM_CONTROLLED="no"
ONBOOT="yes"

Note that you can use what ever bridge names makes sense to you. However, the file name for the bridge configuration must sort after the ifcfg-ethX file. If the bridge file is read before the ethernet interface, it will fail to come up. Also, the bridge name as defined in the file does not need to match the one used it the actual file name. Personally, I like vbrX for "vm bridge".

ifcfg-vbr0:

# Bridge - IFN
DEVICE="vbr0"
TYPE="Bridge"
IPADDR=192.168.1.73
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
DNS1=192.139.81.117
DNS2=192.139.81.1

You may wish to not make the Back-Channel Network accessible to the virtual machines, then there is no need to setup this second bridge.

vim /etc/sysconfig/network-scripts/ifcfg-{eth,vbr}2

ifcfg-eth2:

# Back-channel
HWADDR="00:1B:21:72:9B:56"
DEVICE="eth2"
BRIDGE="vbr2"
BOOTPROTO="static"
IPV6INIT="yes"
NM_CONTROLLED="no"
ONBOOT="yes"

ifcfg-vbr2:

# Bridge - BCN
DEVICE="vbr2"
TYPE="Bridge"
IPADDR=192.168.3.73
NETMASK=255.255.255.0

Leave the cluster, lest we be fenced.

/etc/init.d/rgmanager stop && /etc/init.d/cman stop

Restart networking and then check that the new bridges are up and that the proper ethernet devices are slaved to them.

/etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down interface eth2:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface eth1:                                [  OK  ]
Bringing up interface eth2:                                [  OK  ]
Bringing up interface vbr0:                                [  OK  ]
Bringing up interface vbr2:                                [  OK  ]
brctl show
bridge name	bridge id		STP enabled	interfaces
vbr0		8000.bcaec5448ade	no		eth0
vbr2		8000.001b21729b56	no		eth2
ifconfig
eth0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE  
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:4439 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2752 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:508352 (496.4 KiB)  TX bytes:494345 (482.7 KiB)
          Interrupt:31 Base address:0x8000 

eth1      Link encap:Ethernet  HWaddr 00:1B:21:72:96:E8  
          inet addr:192.168.2.73  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:96e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:617100 errors:0 dropped:0 overruns:0 frame:0
          TX packets:847718 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:772489353 (736.7 MiB)  TX bytes:740536232 (706.2 MiB)
          Interrupt:18 Memory:fe9e0000-fea00000 

eth2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56  
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:86586 errors:0 dropped:0 overruns:0 frame:0
          TX packets:80934 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11366700 (10.8 MiB)  TX bytes:10091579 (9.6 MiB)
          Interrupt:17 Memory:feae0000-feb00000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:11507 (11.2 KiB)  TX bytes:11507 (11.2 KiB)

vbr0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE  
          inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:165 errors:0 dropped:0 overruns:0 frame:0
          TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:25875 (25.2 KiB)  TX bytes:17081 (16.6 KiB)

vbr2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56  
          inet addr:192.168.3.73  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:74 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:19021 (18.5 KiB)  TX bytes:4137 (4.0 KiB)

Rejoin the cluster.

/etc/init.d/cman start && /etc/init.d/rgmanager start


Repeat these configurations, altering for MAC and IP addresses as appropriate, for the other four VM cluster nodes.

Benchmarks

GFS2 partition on an-node07's /shared01 partition. Test #1, no optimization:

bonnie++ -d /shared01/ -s 8g -u root:root
Version  1.96       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
an-node07.alteev 8G   388  95 22203   6 14875   8  2978  95 48406  10 107.3   5
Latency               312ms   44400ms   31355ms   41505us     540ms   11926ms
Version  1.96       ------Sequential Create------ --------Random Create--------
an-node07.alteeve.c -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16  1144  18 +++++ +++  8643  56   939  19 +++++ +++  8262  55
Latency               291ms     586us    2085us    3511ms      51us    3669us
1.96,1.96,an-node07.alteeve.ca,1,1312497509,8G,,388,95,22203,6,14875,8,2978,95,48406,10,107.3,5,16,,,,,1144,18,+++++,+++,8643,56,939,19,+++++,+++,8262,55,312ms,44400ms,31355ms,41505us,540ms,11926ms,291ms,586us,2085us,3511ms,51us,3669us

CentOS 5.6 x86_64 VM vm0001_labzilla's /root directory. Test #1, no optimization. VM provisioned using command in below section.

bonnie++ -d /root/ -s 8g -u root:root
Version  1.96       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
labzilla-new.can 8G   674  98 15708   5 14875   7  1570  65 47806  10 119.1   7
Latency             66766us    7680ms    1588ms     187ms     269ms    1292ms
Version  1.96       ------Sequential Create------ --------Random Create--------
labzilla-new.candco -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 27666  39 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
Latency             11360us    1904us     799us     290us      44us      41us
1.96,1.96,labzilla-new.candcoptical.com,1,1312522208,8G,,674,98,15708,5,14875,7,1570,65,47806,10,119.1,7,16,,,,,27666,39,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,66766us,7680ms,1588ms,187ms,269ms,1292ms,11360us,1904us,799us,290us,44us,41us

Provision vm0001

Created LV already, so:

virt-install --connect qemu:///system \
  --name vm0001_labzilla \
  --ram 1024 \
  --arch x86_64 \
  --vcpus 2 \
  --cpuset 1-3 \
  --location http://192.168.1.254/c5/x86_64/img/ \
  --extra-args "ks=http://192.168.1.254/c5/x86_64/ks/labzilla_c5.ks" \
  --os-type linux \
  --os-variant rhel5.4 \
  --disk path=/dev/san_vg01/vm0001_hdd1 \
  --network bridge=vbr0 \
  --vnc

Provision vm0002

Created LV already, so:

virt-install --connect qemu:///system \
  --name vm0002_innovations \
  --ram 1024 \
  --arch x86_64 \
  --vcpus 2 \
  --cpuset 1-3 \
  --cdrom /shared01/media/Win_Server_2008_Bis_x86_64.iso \
  --os-type windows \
  --os-variant win2k8 \
  --disk path=/dev/san_vg01/vm0002_hdd2 \
  --network bridge=vbr0 \
  --hvm \
  --vnc

Update the cluster.conf to add the VMs to the cluster.

<?xml version="1.0"?>
<cluster config_version="12" name="an-clusterB">
	<totem rrp_mode="none" secauth="off"/>
	<clusternodes>
		<clusternode name="an-node03.alteeve.ca" nodeid="3">
			<fence>
				<method name="apc_pdu">
					<device action="reboot" name="pdu2" port="3"/>
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node04.alteeve.ca" nodeid="4">
			<fence>
				<method name="apc_pdu">
					<device action="reboot" name="pdu2" port="4"/>
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node05.alteeve.ca" nodeid="5">
			<fence>
				<method name="apc_pdu">
					<device action="reboot" name="pdu2" port="5"/>
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node06.alteeve.ca" nodeid="6">
			<fence>
				<method name="apc_pdu">
					<device action="reboot" name="pdu2" port="6"/>
				</method>
			</fence>
		</clusternode>
		<clusternode name="an-node07.alteeve.ca" nodeid="7">
			<fence>
				<method name="apc_pdu">
					<device action="reboot" name="pdu2" port="7"/>
				</method>
			</fence>
		</clusternode>
	</clusternodes>
	<fencedevices>
		<fencedevice agent="fence_apc" ipaddr="192.168.1.6" login="apc" name="pdu2" passwd="secret"/>
	</fencedevices>
	<fence_daemon post_join_delay="30"/>
	<rm log_level="5">
		<resources>
			<script file="/etc/init.d/iscsi" name="iscsi"/>
			<script file="/etc/init.d/clvmd" name="clvmd"/>
			<script file="/etc/init.d/gfs2" name="gfs2"/>
		</resources>
		<failoverdomains>
			<failoverdomain name="an3_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca"/>
			</failoverdomain>
			<failoverdomain name="an4_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node04.alteeve.ca"/>
			</failoverdomain>
			<failoverdomain name="an5_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node05.alteeve.ca"/>
			</failoverdomain>
			<failoverdomain name="an6_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node06.alteeve.ca"/>
			</failoverdomain>
			<failoverdomain name="an7_only" nofailback="1" ordered="0" restricted="1">
				<failoverdomainnode name="an-node07.alteeve.ca"/>
			</failoverdomain>
			<failoverdomain name="an3_primary" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="1"/>
				<failoverdomainnode name="an-node04.alteeve.ca" priority="2"/>
				<failoverdomainnode name="an-node05.alteeve.ca" priority="3"/>
				<failoverdomainnode name="an-node06.alteeve.ca" priority="4"/>
				<failoverdomainnode name="an-node07.alteeve.ca" priority="5"/>
			</failoverdomain>
			<failoverdomain name="an4_primary" nofailback="1" ordered="1" restricted="1">
				<failoverdomainnode name="an-node03.alteeve.ca" priority="5"/>
				<failoverdomainnode name="an-node04.alteeve.ca" priority="1"/>
				<failoverdomainnode name="an-node05.alteeve.ca" priority="2"/>
				<failoverdomainnode name="an-node06.alteeve.ca" priority="3"/>
				<failoverdomainnode name="an-node07.alteeve.ca" priority="4"/>
			</failoverdomain>
		</failoverdomains>
		<service autostart="1" domain="an3_only" exclusive="0" max_restarts="0" name="an3_storage" recovery="restart">
			<script ref="iscsi">
				<script ref="clvmd">
					<script ref="gfs2"/>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an4_only" exclusive="0" max_restarts="0" name="an4_storage" recovery="restart">
			<script ref="iscsi">
				<script ref="clvmd">
					<script ref="gfs2"/>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an5_only" exclusive="0" max_restarts="0" name="an5_storage" recovery="restart">
			<script ref="iscsi">
				<script ref="clvmd">
					<script ref="gfs2"/>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an6_only" exclusive="0" max_restarts="0" name="an6_storage" recovery="restart">
			<script ref="iscsi">
				<script ref="clvmd">
					<script ref="gfs2"/>
				</script>
			</script>
		</service>
		<service autostart="1" domain="an7_only" exclusive="0" max_restarts="0" name="an7_storage" recovery="restart">
			<script ref="iscsi">
				<script ref="clvmd">
					<script ref="gfs2"/>
				</script>
			</script>
		</service>
		<vm autostart="0" domain="an3_primary" exclusive="0" max_restarts="2" name="vm0001_labzilla" path="/shared01/definitions/" recovery="restart" restart_expire_time="600"/>
		<vm autostart="0" domain="an4_primary" exclusive="0" max_restarts="2" name="vm0002_innovations" path="/shared01/definitions/" recovery="restart" restart_expire_time="600"/>
	</rm>
</cluster>


Stuff

Multi-VM after primary SAN (violent) ejection from cluster. Both VMs remained up!

Two VMs (windows and Linux) running on the SAN. Initial testing of survivability of primary SAN failure completed successfully!

First build of the 2x7 Cluster.

First-ever successful build/install of the "Cluster Set" cluster configuration. Fully HA, fully home-brew on all open source software using only commodity hardware. Much tuning/testing to come!

Bonding and Trunking

The goal here is to take the network out as a single point of failure.

The design is to use two stacked switches, bonded connections in the nodes with each leg of the bond cabled through either switch. While both are up, the aggregate bandwidth will be achieved using trunking in the switch and the appropriate bond driver configuration. The recovery from failure will need to be configured in such a way that it will be faster than the cluster's token loss timeouts multiplied by the token retransmit loss count.

This tutorial uses 2x D-Link DGS-3100-24 switches. This is not to endorse these switches, per-se, but it does provide a relatively affordable, decent quality switches for those who'd like to replicate this setup.

Configure The Stack

First, stack the switches using a ring topology (both HDMI connectors/cables used). If both switches are brand new, simple cable them together and the switches will auto-negotiate the stack configuration. If you are adding a new switch, then power on the existing switch, cable up the second switch and then power on the second switch. After a short time, it's stack ID should increment and you should see the new switch appear in the existing switch's interface.

Configuring the Bonding Drivers

This tutorial uses four interfaces joined into two bonds of two NICs like so:

# Internet Facing Network:
eth0 + eth1 == bond0
# Storage and Cluster Communications:
eth2 + eth3 == bond1

This requires a few steps.

  • Create /etc/modprobe.d/bonding.conf and add an entry for the two bonding channels we will create.

Note: My eth0 device is an onboard controller with a maximum MTU of 7200 bytes. This means that the whole bond is restricted to this MTU.

vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
alias bond1 bonding
  • Create the ifcfg-bondX configuration files.

Internet Facing configuration

touch /etc/sysconfig/network-scripts/ifcfg-bond{0,1}
vim /etc/sysconfig/network-scripts/ifcfg-eth{0,1} /etc/sysconfig/network-scripts/ifcfg-bond0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Internet Facing Network - Link 1
HWADDR="BC:AE:C5:44:8A:DE"
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
MTU="7200"
cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Internet Facing Network - Link 2
HWADDR="00:1B:21:72:96:E8"
DEVICE="eth1"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond0"
SLAVE="yes"
MTU="7200"
cat /etc/sysconfig/network-scripts/ifcfg-bond0
# Internet Facing Network - Bonded Interface
DEVICE="bond0"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.1.73"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.254"
DNS1="192.139.81.117"
DNS2="192.139.81.1"
BONDING_OPTS="miimon=1000 mode=0"
MTU="7200"

Merged Storage Network and Back Channel Network configuration.

Note: The interfaces in this bond all support maximum MTU of 9000 bytes.

vim /etc/sysconfig/network-scripts/ifcfg-eth{2,3} /etc/sysconfig/network-scripts/ifcfg-bond1
cat /etc/sysconfig/network-scripts/ifcfg-eth2
# Storage and Back Channel Networks - Link 1
HWADDR="00:1B:21:72:9B:56"
DEVICE="eth2"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
MTU="9000"
cat /etc/sysconfig/network-scripts/ifcfg-eth3
# Storage and Back Channel Networks - Link 2
HWADDR="00:0E:0C:59:46:E4"
DEVICE="eth3"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
MASTER="bond1"
SLAVE="yes"
MTU="9000"
cat /etc/sysconfig/network-scripts/ifcfg-bond1
# Storage and Back Channel Networks - Bonded Interface
DEVICE="bond1"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.3.73"
NETMASK="255.255.255.0"
BONDING_OPTS="miimon=1000 mode=0"
MTU="9000"

Restart networking.

Note: I've noticed that this can error out and fail to start slaved devices at times when using /etc/init.d/network restart. If you have any trouble, you may need to completely stop all networking, then start it back up. This, of course, requires network-less access to the node's console (direct access, iKVM, console redirection, etc).

Some of the errors we will see below are because the network interface configuration changed while the interfaces were still up. To avoid this, if you have networkless access to the nodes, would be to stop the network interfaces prior to beginning editing.

/etc/init.d/network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down interface eth2:  /etc/sysconfig/network-scripts/ifdown-eth: line 99: /sys/class/net/bond1/bonding/slaves: No such file or directory
                                                           [  OK  ]
Shutting down interface eth3:  /etc/sysconfig/network-scripts/ifdown-eth: line 99: /sys/class/net/bond1/bonding/slaves: No such file or directory
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:  RTNETLINK answers: File exists
Error adding address 192.168.1.73 for bond0.
RTNETLINK answers: File exists
                                                           [  OK  ]
Bringing up interface bond1:                               [  OK  ]

Confirm that we've got our new bonded interfaces

ifconfig
bond0     Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE  
          inet addr:192.168.1.73  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::beae:c5ff:fe44:8ade/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:7200  Metric:1
          RX packets:1021 errors:0 dropped:0 overruns:0 frame:0
          TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:128516 (125.5 KiB)  TX bytes:95092 (92.8 KiB)

bond1     Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56  
          inet addr:192.168.3.73  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe72:9b56/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:9000  Metric:1
          RX packets:787028 errors:0 dropped:0 overruns:0 frame:0
          TX packets:788651 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:65753950 (62.7 MiB)  TX bytes:1194295932 (1.1 GiB)

eth0      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:7200  Metric:1
          RX packets:535 errors:0 dropped:0 overruns:0 frame:0
          TX packets:261 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:66786 (65.2 KiB)  TX bytes:47749 (46.6 KiB)
          Interrupt:31 Base address:0x8000 

eth1      Link encap:Ethernet  HWaddr BC:AE:C5:44:8A:DE  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:7200  Metric:1
          RX packets:486 errors:0 dropped:0 overruns:0 frame:0
          TX packets:241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:61730 (60.2 KiB)  TX bytes:47343 (46.2 KiB)
          Interrupt:18 Memory:fe8e0000-fe900000 

eth2      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:9000  Metric:1
          RX packets:360190 errors:0 dropped:0 overruns:0 frame:0
          TX packets:394844 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:28756400 (27.4 MiB)  TX bytes:598159146 (570.4 MiB)
          Interrupt:17 Memory:fe9e0000-fea00000 

eth3      Link encap:Ethernet  HWaddr 00:1B:21:72:9B:56  
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:9000  Metric:1
          RX packets:426838 errors:0 dropped:0 overruns:0 frame:0
          TX packets:393807 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:36997550 (35.2 MiB)  TX bytes:596136786 (568.5 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Configuring High-Availability Networking

There are seven bonding modes, which you can read about in detail here. However, the RHCS stack only supports one of the modes, called Active/Passive Bonding, also known as mode=1.

Configuring Your Switches

This method provides for no performance gains, but instead treats the slaved interfaces as independent paths. One of which acts as the primary while the other sits dormant. On failure, the bond switches to the backup interface, promoting it to the primary interface. Which is normally primary, and under what conditions a restored link might return to the primary role, are configurable should you wish to do so.

Your managed switch will no doubt have one or more bonding, also known as trunking configuration options. Likewise, your switches may be stackable. It is strongly advised that you do *not* stack your switches. Being unstacked, it is obviously not possible to configure trunking. Should you decide to disregard this, be very sure to extensive test failure and recovery of both switches under real-world work loads.

Still on the topic of switches; Do not configure STP (spanning tree protocol) on any port connected to your cluster nodes! When a switch is added to the network, as is the case after restoring a lost switch, STP-enabled switches and port on those switches may block traffic for a period of time while STP renegotiates and reconfigures. This takes more than enough time to cause a cluster to partition. You may still enable and configure STP if you need to do so, simply ensure that you only do in on the appropriate ports.

Preparing The Bonding Driver

Before we modify the network, we will need to create the following file:

You will need to create a file called

With the switches unstacked and STP disabled, we can now configure your bonding interface.

vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
alias bond1 bonding
alias bond2 bonding

If you only have four interfaces and plan to merge the SN and BCN networks, you can omit the bond2 entry.

You can then copy and paste the alias ... entries from the file above into the terminal to avoid the need to reboot.

Deciding Which NICs to Bond

If all of the interfaces in your server are identical, you can probably skip this step. Before you jump though, consider that not all of the PCIe interfaces may have all of their lanes connected, resulting in differing speeds. If you are unsure, I strongly recommend you run these tests.

TODO: Upload network_profiler.pl here and explain it's use.


Once you've determined the various capabilities on your interfaces, pair them off with their closest-performing partners.

Keep in mind:

  • Any interface piggy-backing on an IPMI interface *must* be part of the BCN bond!
  • The fasted interfaces should be paired for the SN bond.
  • The lowest latency interfaces should be used the BCN bond.
  • The lowest remaining two interfaces should be used in the IFN bond.

Creating the Bonds

Warning: This step will almost certainly leave you without a network access to your servers. It is *strongly* advised that you do the next steps when you have physical access to your servers. If that is simply not possible, then proceed with extreme caution.

In my case, I found that bonding the following optimal configuration:

  • eth0 and eth3 bonded as bond0.
  • eth1 and eth2 bonded as bond1.

I did not have enough interfaces for three bonds, so I will configure the following:

  • bond0 will be the IFN interface on the 192.168.1.0/24 subnet.
  • bond1 will be the merged BCN and SN interfaces on the 192.168.3.0/24 subnet.

TODO: Create/show the diffs for the following ifcfg-ethX files.

  • Create bond0 our of eth0 and eth3:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Internet Facing Network - Link 1
HWADDR="BC:AE:C5:44:8A:DE"
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="no"
MASTER="bond0"
SLAVE="yes"
vim /etc/sysconfig/network-scripts/ifcfg-eth3
# Storage and Back Channel Networks - Link 2
HWADDR="00:0E:0C:59:46:E4"
DEVICE="eth3"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="no"
MASTER="bond0"
SLAVE="yes"
vim /etc/sysconfig/network-scripts/ifcfg-bond0
# Internet Facing Network - Bonded Interface
DEVICE="bond0"
BOOTPROTO="static"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="192.168.1.73"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.254"
DNS1="192.139.81.117"
DNS2="192.139.81.1"
# Clustering *only* supports mode=1 (active-passive)
BONDING_OPTS="mode=1 miimon=100 use_carrier=0 updelay=0 downdelay=0"

GFS2

Try adding noatime to the /etc/fstab options. h/t to Dak1n1; "it avoids cluster reads from turning into unnecessary writes, and can improve performance".

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.