SXXcluster

Synopsys


#
# Enabling cluster services and GFS
#

Script


for service in ccsd clvmd cman fenced gfs ; do
	echo "%Post: Enabling ${service} service for GFS"
	/sbin/chkconfig ${service} on
done

echo "%Post: Adding lock configuration to lvm.conf for GFS"

mv /etc/lvm/lvm.conf /etc/lvm/lvm.conf-$VERSION

# Standarad LVM uses locking_type 1.  Since we need a cluster-aware lvm,
# we use the provided locking library.  This backs onto the cman / lock_dlm 
# infrastructure provided by the RH cluster tools.
# It is apparently possible to use GFS on an LVM without any locking as 
# long as you're careful not to make changes to the volume configuration 
# whilst multiple machines can see the block device.
# Not really worth risking.

sed -e 's/\(locking_type\) = 1/# v2 locking for GFS\n    \1 = 2\n    HERE/' \
    -e 's@HERE@locking_library = "/usr/lib/liblvm2clusterlock.so"@' \
	/etc/lvm/lvm.conf-$VERSION > /etc/lvm/lvm.conf

#  found http://forums.oracle.com/forums/thread.jspa?threadID=305220&tstart=1
echo "%Post: Forcing sbp2 to allow concurrent logins from two firewire devices"
echo "options sbp2 serialize_io=1 exclusive_login=0" >> /etc/modprobe.conf


# Configuration here created using system-config-cluster package.
# This isn't a good tool, and isn't worth putting on a server since it 
# requires X.  (There may be a console mode,  but I haven't looked).
echo "%Post: Writing GFS cluster config"
mkdir /etc/cluster

CLUSTER1=cluster1.$DOMAINNAME
CLUSTER2=cluster2.$DOMAINNAME

CLUSTER1IP=`host CLUSTER1 | grep address | cut -d " " -f 4`
CLUSTER2IP=`host CLUSTER2 | grep address | cut -d " " -f 4`

cat >/etc/cluster/cluster.conf <<EOF
<?xml version="1.0"?>
<cluster config_version="11" name="test_cluster">
    <fence_daemon clean_start="1" post_fail_delay="0" post_join_delay="3"/>
    <clusternodes>
        <clusternode name="$CLUSTER1" votes="1">
            <fence/>
        </clusternode>
        <clusternode name="$CLUSTER2" votes="1"/>
    </clusternodes>
    <cman expected_votes="1" two_node="1"/>
    <fencedevices>
        <fencedevice agent="fence_manual" name="manual_fence"/>
    </fencedevices>
    <rm>
        <failoverdomains>
            <failoverdomain name="nfs_failover_domain" ordered="1" restricted="1">
                <failoverdomainnode name="$CLUSTER1" priority="2"/>
                <failoverdomainnode name="$CLUSTER2" priority="1"/>
            </failoverdomain>
            <failoverdomain name="smb_failover_domain" ordered="1" restricted="1">
                <failoverdomainnode name="$CLUSTER2" priority="2"/>
                <failoverdomainnode name="$CLUSTER1" priority="1"/>
            </failoverdomain>
        </failoverdomains>
        <resources>
            <ip address="$CLUSTER1IP" monitor_link="1"/>
            <ip address="$CLUSTER2IP" monitor_link="1"/>
            <script file="/etc/init.d/nfs" name="start_nfs"/>
            <script file="/etc/init.d/smb" name="start_smb"/>
        </resources>
        <service autostart="1" domain="nfs_failover_domain" name="nfs_service">
            <ip ref="$CLUSTER1IP"/>
            <script ref="start_nfs"/>
        </service>
        <service autostart="1" domain="smb_failover_domain" name="smb_service">
            <ip ref="$CLUSTER2IP"/>
            <script ref="start_smb"/>
        </service>
    </rm>
</cluster>
EOF


# Two helper scripts to start and stop things in the right order.
# Came from a RedHat document, though I forget where.
cat > /usr/local/bin/cluster-start.sh <<EOF
#!/bin/bash

service ccsd start
service cman start 
service fenced start 
service clvmd start 
service gfs start 
service rgmanager start 
EOF

cat > /usr/local/bin/cluster-stop.sh <<EOF
#!/bin/bash

service rgmanager stop
service gfs stop
service clvmd stop
service fenced stop
service cman stop
service ccsd stop
EOF

chmod +x /usr/local/bin/cluster-st{art,op}.sh

Examples and Testing





Marked up in XHTML - ©2005 Thoughtful Solutions Ltd.