Difference between revisions of "Setup corosync"

From PDP/Grid Wiki
Jump to navigationJump to search
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
Line 5: Line 6:
 
#
 
#
  
#IPNET=194.171.97.0
+
COROSYNCCONF=/etc/corosync/corosync.conf
  
if [ $# -ne 1 ]; then
+
if [ $# -ne 2 ]; then
         echo "usage: $0 ipnet"
+
         echo "usage: $0 ipnet clusternumber"
 
         exit 1
 
         exit 1
 
fi
 
fi
 
 
IPNET=$1
 
IPNET=$1
 
+
PORT=$((($2 << 1) + 5405))
heartbeat_bdii=/usr/lib/ocf/resource.d/heartbeat/bdii
 
heartbeat_bdii_source=heartbeat_bdii
 
COROSYNCCONF=/etc/corosync/corosync.conf
 
 
 
if [ ! -e $heartbeat_bdii ]; then
 
    if [ -e $heartbeat_bdii_source ]; then
 
        cp $heartbeat_bdii_source $heartbeat_bdii
 
    else
 
        echo "bdii heartbeat startup script not found. fix me."
 
        exit 1
 
    fi
 
fi
 
  
 
if [ ! -f $COROSYNCCONF ]; then
 
if [ ! -f $COROSYNCCONF ]; then
 
     cp ${COROSYNCCONF}.example $COROSYNCCONF
 
     cp ${COROSYNCCONF}.example $COROSYNCCONF
     perl -p -i -e 's|(bindnetaddr:).*|\1  '"$IPNET|" $COROSYNCCONF
+
     perl -p -i -e 's|(bindnetaddr:).*|\1  '"$IPNET|; s|(mcastport:).*|\1 $PORT|" $COROSYNCCONF
  
     cat >>/etc/corosync/corosync.conf <<UFO
+
     cat >>${COROSYNCCONF}  <<UFO
 
aisexec {
 
aisexec {
 
         user: root
 
         user: root
Line 47: Line 35:
 
     echo "corosync already configured, abort"
 
     echo "corosync already configured, abort"
 
fi
 
fi
 +
 +
</pre>

Latest revision as of 08:37, 9 June 2011

#!/bin/bash

#
#       run on all nodes in a cluster-to-be
#

COROSYNCCONF=/etc/corosync/corosync.conf

if [ $# -ne 2 ]; then
        echo "usage: $0 ipnet clusternumber"
        exit 1
fi
IPNET=$1
PORT=$((($2 << 1) + 5405))

if [ ! -f $COROSYNCCONF ]; then
    cp ${COROSYNCCONF}.example $COROSYNCCONF
    perl -p -i -e 's|(bindnetaddr:).*|\1  '"$IPNET|; s|(mcastport:).*|\1 $PORT|" $COROSYNCCONF

    cat >>${COROSYNCCONF}  <<UFO
aisexec {
        user: root
        group: root
}
service {
        name: pacemaker
        ver: 0
}
UFO

        /etc/init.d/corosync start

else
    echo "corosync already configured, abort"
fi