Hi to all, I am mounting a simple cluster for use mail/virtualbox/samba in two servers, in active/active mode (not for virtualbox).
In my testings some times the drbd system needs wait some time for start (sync protocols), or because some times the node are down many days. I create a script for wait for a sync, and check that the "ip of interconect cluster" are up an running. and go up to ocfs2 for download: www.adantra.es/temp/check_drbd.gz I put the interesting code here because my goal is not for drbd (usefully too) but the real use is for ocfs2 you can put you ocfs2 at fstab with noauto option. I put in my init scripts (the init is for debian but you can use easy in many systems)... I hope that the people find userfully (my bash scripting is not very good..).. (sorry the coments are in spanish)... =============================================================== #!/bin/bash ### BEGIN INIT INFO # Provides: check_drbd # Required-Start: $local_fs $network o2cb drbd # Required-Stop: $local_fs # X-Start-Before: # Default-Start: 2 3 4 5 # Default-Stop: 0 6 # Short-Description: Check the syn of filesystem drbd before mount ocfs2 filesystems. # Description: Check the syn of filesystem drbd before mount ocfs2 filesystems. ### END INIT INFO # Version 1.0 IP_SYNC=192.168.2.1 # Resource number RES=0 NET_INTERFACE=eth3 SLEEP=10 TIMEOUT=30 SLEEP_TIME=0 MOUNTPOINT="/datos/datosadantra" #LOG="/bin/echo" LOG="/usr/bin/logger" if [ ! -f /proc/drbd ]; then $LOG "No esta arrancado DRBD..." exit 1 fi case "$1" in start) # Inciando las comprobaciones ESTADO_MIRROR=`/sbin/drbdadm dstate r$RES` until [ "$ESTADO_MIRROR" == "UpToDate/UpToDate" ]; do ESTADO_CONEXION=`/sbin/drbdadm cstate r$RES` IP_ASIGNADA=`ifconfig $NET_INTERFACE | sed -n '/^[A-Za-z0-9]/ {N;/dr:/{;s/.*dr://;s/ .*//;p;}}'` # if [ "$ESTADO_CONEXION" == "WFConnection" ] && [ "$IP_ASIGNADA" != "$IP_SYNC" ]; then if [ "$IP_ASIGNADA" != "$IP_SYNC" ]; then $LOG "IP no asignada a la red, reiniciando la red"; $LOG "Reiniciando la Network..." /sbin/ifconfig $NET_INTERFACE $IP_SYNC\/24 up /etc/init.d/drbd restart /etc/init.d/o2cb restart fi $LOG "Esperando a la sincronia del mirror $SLEEP_TIME seg de $TIMEOUT" sleep $SLEEP let "SLEEP_TIME=$SLEEP_TIME+$SLEEP" if (( $SLEEP_TIME > $TIMEOUT )) ; then $LOG "Demasiado tiempo esperando..." $LOG "Mandar mail..." exit 1 fi ESTADO_MIRROR=`/sbin/drbdadm dstate r$RES`doneESTADO_MIRROR=`/sbin/drbdadm role r$RES`if [ "$ESTADO_MIRROR" == "Secondary/Primary" ]; then #Check that the role are Primary/Primary /sbin/drbdadm primary r$RESfiESTADO_MIRROR=`/sbin/drbdadm role r$RES`if [ "$ESTADO_MIRROR" != "Primary/Primary" ]; then # Make sure that the rola are Primary/Primary $LOG "El mirror no esta correcto no podemos arrancar..." exit 1fi $LOG "El mirror esta Ok, podemos montar $MOUNTPOINT .."mount | grep "$MOUNTPOINT";copia_ok=$?if [ "$copia_ok" == 0 ]; then $LOG "No montamos $MOUNTPOINT por que ya esta montado" exit 1else mount $MOUNTPOINT copia_ok=$? if [ "$copia_ok" != 0 ]; then $LOG "No se ha podido montar $MOUNTPOINT" exit 1 else $LOG "Montado del directorio $MOUNTPOINT OK" fifi ;; stop|reload|restart|force-reload) # No hay nada que parar, solo asegurarse que antes de arrancar el drbd esta sincronizado ;; *) echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;;esac exit 0 _______________________________________________ Ocfs2-users mailing list Ocfs2-users@oss.oracle.com http://oss.oracle.com/mailman/listinfo/ocfs2-users