Lustre-server

From In The Wings
Revision as of 13:52, 10 October 2007 by Jka (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a script that I wrote in order to start and stop a lustre server.

#!/bin/bash
#
# luster-server This shell script takes care of starting and stopping
#               a Lustre server.
#
# chkconfig: 345 27 73
#
# description:  Lustre is a parallel filesystem.

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

RETVAL=0
LUSTRE_HOME=/opt/lustre/1.6.2
MDT_TARGET=/lustre/mri/mdt0
LUSTRE_MDT=/dev/sda
E2_HOME=/opt/e2fsck
OST_LV="f2c0l0 f2c0l1 f2c1l0 f2c1l1 f3c0l0 f3c0l1 f3c1l0 f3c1l1"

start() {
    action $"Loading Lustre lnet module: " modprobe lnet
    action $"Starting nids: " ${LUSTRE_HOME}/sbin/lctl network up
    action $"Mounting MDT: " mount -t lustre $LUSTRE_MDT $MDT_TARGET
    for LV in $OST_LV
      do 
      if [ -d /lustre/`${E2_HOME}/sbin/e2label /dev/${LV}/lv-${LV}` ]; then
          mount -t lustre /dev/$LV/lv-$LV /lustre/`${E2_HOME}/sbin/e2label /dev/${LV}/lv-${LV}` 
      else
          mkdir /lustre/`${E2_HOME}/sbin/e2label /dev/${LV}/lv-${LV}`
          mount -t lustre /dev/$LV/lv-$LV /lustre/`${E2_HOME}/sbin/e2label /dev/${LV}/lv-${LV}` 
      fi
    done
}

stop() {
    for LV in $OST_LV
      do
      umount /lustre/`${E2_HOME}/sbin/e2label /dev/${LV}/lv-${LV}`
    done
    umount $MDT_TARGET
    action $"Unconfiguring LIDS: " ${LUSTRE_HOME}/sbin/lctl network unconfigure
    ${LUSTRE_HOME}/sbin/lctl modules | awk '{print $2}' | xargs rmmod
    action $"Removing lnet modules: " 
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $RETVAL