tuto:sauvegardes:externalisation_raid1

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
tuto:sauvegardes:externalisation_raid1 [25/10/2012 13:54]
dani [COS 4 (SME7)]
tuto:sauvegardes:externalisation_raid1 [13/09/2016 11:11] (Version actuelle)
dani
Ligne 13: Ligne 13:
  
 <code> <code>
-fdisk /dev/sdc +gdisk /dev/sdc 
-[...](création d'une partition primaire /dev/sdc1 type fd)+[...](création d'une partition primaire /dev/sdc1 type fd00)
 </code> </code>
  
 Maintenant, nous allons créer le volume RAID /dev/md0 Maintenant, nous allons créer le volume RAID /dev/md0
 <code> <code>
-mdadm --create /dev/md0 --level=1 --force --raid-devices=1 /dev/sdc1+mdadm --create /dev/md0 --bitmap=internal --level=1 --force --raid-devices=1 /dev/sdc1
 </code> </code>
  
Ligne 25: Ligne 25:
  
 <code> <code>
-mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1+mdadm --create /dev/md0 --bitmap=internal --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
 </code> </code>
  
-La suite est classique, on crée un pv sur /dev/md0, puis un vg, et enfin un lv (en laissant toujours un peu d'espace non alloué au cas où), puis on formate ce lv en ext3, et on le configure pour se monter sur /var/lib/BackupPC.+La suite est classique, on crée un pv sur /dev/md0, puis un vg, et enfin un lv (en laissant toujours un peu d'espace non alloué au cas où), puis on formate ce lv en xfs, et on le configure pour se monter sur /var/lib/BackupPC.
  
 ===== Repérer les informations des disques d'externalisations ===== ===== Repérer les informations des disques d'externalisations =====
Ligne 107: Ligne 107:
 <code bash> <code bash>
 #!/bin/bash #!/bin/bash
 + 
 # Read configuration # Read configuration
 if [ -e /etc/BackupPC/raidsync.conf ]; then if [ -e /etc/BackupPC/raidsync.conf ]; then
Ligne 115: Ligne 115:
     exit 1     exit 1
 fi fi
- +  
- +  
 + 
 # Find if one of the removable disk is present # Find if one of the removable disk is present
 # The first one will be used # The first one will be used
Ligne 127: Ligne 127:
     fi     fi
 done done
 + 
 # Check if a lock file exists # Check if a lock file exists
 # And that the removable device exists # And that the removable device exists
Ligne 145: Ligne 145:
 RAID_DEVICES=$(/sbin/mdadm --detail $RAID | /bin/grep 'Raid Devices' | /bin/awk '{print $4}') RAID_DEVICES=$(/sbin/mdadm --detail $RAID | /bin/grep 'Raid Devices' | /bin/awk '{print $4}')
 logger "The array $RAID has $RAID_DEVICES active member(s)" logger "The array $RAID has $RAID_DEVICES active member(s)"
 + 
 # Grow the RAID device to include one more drive (missing for now) # Grow the RAID device to include one more drive (missing for now)
 logger "Growing RAID array $RAID" logger "Growing RAID array $RAID"
-/sbin/mdadm --grow $RAID --raid-devices=$(($RAID_DEVICES+1))+/sbin/mdadm --grow $RAID --raid-devices=$(($RAID_DEVICES+1)) --force
  
 +if [ -e "/sys/block/$(basename $RAID)/queue/max_sectors_kb" ]; then
 +    # Check the max_sectors_kb before adding the new drive
 +    OLDSIZE=$(cat /sys/block/$(basename $RAID)/queue/max_sectors_kb)
 +
 +    # Freeze the FS
 +    /sbin/fsfreeze -f $TOPDIR
 +fi
 + 
 # Add the removable device to the raid array # Add the removable device to the raid array
 logger "Adding $REMOVABLE_DEVICE to RAID array $RAID" logger "Adding $REMOVABLE_DEVICE to RAID array $RAID"
-/sbin/mdadm --manage $RAID --add $REMOVABLE_DEVICE+/sbin/mdadm --manage $RAID --add --write-mostly $REMOVABLE_DEVICE
  
-SYNCING=1+if [ -e "/sys/block/$(basename $RAID)/queue/max_sectors_kb" ]; then 
 +    # Now check the new max_sectors_kb 
 +    NEWSIZE=$(cat /sys/block/$(basename $RAID)/queue/max_sectors_kb)
  
 +    REMOUNT="no"
 +    # max_sectors_kb has changed ?
 +    if [ "$OLDSIZE" != "$NEWSIZE" ]; then
 +        # We need to update the max_sectors_kb of the device backing the filesystem
 +        # to prevent bio too big errors
 +        FSDEV=$(basename $(readlink /dev/disk/by-uuid/$(/sbin/blkid $(df -P $TOPDIR | tail -1 | awk '{print $1}') | sed 's/.*UUID="\([a-z0-9-]*\)".*/\1/')))
 +        FSDEVSIZE=$(cat /sys/block/$FSDEV/queue/max_sectors_kb)
 +        if [ $FSDEVSIZE -gt $NEWSIZE ]; then
 +            cat /sys/block/$(basename $RAID)/queue/max_sectors_kb > /sys/block/$FSDEV/queue/max_sectors_kb
 +            REMOUNT="yes"
 +        fi
 +    fi
 +
 +    # Unfreez the FS
 +    /sbin/fsfreeze -u $TOPDIR
 +
 +    # Remount the FS if needed (not sure if it's really needed)
 +    if [ "$REMOUNT" == "yes" ]; then
 +        mount -o remount $TOPDIR
 +    fi
 +fi
 + 
 +SYNCING=1
 + 
 # Check if the sync is still running # Check if the sync is still running
 while [ $SYNCING -ne 0 ]; do while [ $SYNCING -ne 0 ]; do
Ligne 161: Ligne 195:
     SYNCING=$(/sbin/mdadm --detail $RAID | /bin/grep State | /bin/grep -c recovering)     SYNCING=$(/sbin/mdadm --detail $RAID | /bin/grep State | /bin/grep -c recovering)
 done done
 + 
 logger "RAID array $RAID is now fully synced" logger "RAID array $RAID is now fully synced"
 + 
 if [ "$CLEAN_REMOVE" == "yes" ]; then if [ "$CLEAN_REMOVE" == "yes" ]; then
     # Stop backuppc and wait a few seconds to be sure the fs is clean     # Stop backuppc and wait a few seconds to be sure the fs is clean
     logger "Stopping BackupPC server in order to have a consistent state"     logger "Stopping BackupPC server in order to have a consistent state"
-    /etc/init.d/backuppc stop+    /sbin/service backuppc stop
     /bin/sync     /bin/sync
     /bin/sleep 10     /bin/sleep 10
 + 
     # Now we can umount the volume     # Now we can umount the volume
     logger "Unmounting $TOPDIR in order to have a consistent state"     logger "Unmounting $TOPDIR in order to have a consistent state"
Ligne 177: Ligne 211:
     sync; sync     sync; sync
 fi fi
 + 
 # Mark the disk as faulty # Mark the disk as faulty
 logger "Removing $REMOVABLE_DEVICE from the RAID array $RAID" logger "Removing $REMOVABLE_DEVICE from the RAID array $RAID"
 /sbin/mdadm --manage $RAID --fail $REMOVABLE_DEVICE /sbin/mdadm --manage $RAID --fail $REMOVABLE_DEVICE
 sleep 1 sleep 1
 + 
 # Remove it # Remove it
 /sbin/mdadm --manage $RAID --remove $REMOVABLE_DEVICE /sbin/mdadm --manage $RAID --remove $REMOVABLE_DEVICE
 + 
 # And shrink the raid array so it doesn't report degraded state # And shrink the raid array so it doesn't report degraded state
 # Only use the force flag if $RAID_DEVICES is one # Only use the force flag if $RAID_DEVICES is one
Ligne 194: Ligne 228:
 fi fi
 /sbin/mdadm --grow $RAID $FORCE --raid-devices=$RAID_DEVICES /sbin/mdadm --grow $RAID $FORCE --raid-devices=$RAID_DEVICES
 + 
 if [ "$CLEAN_REMOVE" == "yes" ]; then if [ "$CLEAN_REMOVE" == "yes" ]; then
     # We can remount the volume     # We can remount the volume
     logger "$TOPDIR can be re-mounted"     logger "$TOPDIR can be re-mounted"
     mount $TOPDIR     mount $TOPDIR
 + 
     # and restart BackupPC     # and restart BackupPC
     logger "And BackupPC server can be restarted"     logger "And BackupPC server can be restarted"
-    /etc/init.d/backuppc start+    /sbin/service backuppc start
 fi fi
 + 
 # Send a mail # Send a mail
 if [ ! -z "$MAIL_TO" ]; then if [ ! -z "$MAIL_TO" ]; then
Ligne 212: Ligne 246:
     done     done
 fi fi
 + 
 # Now loop until the link to $REMOVABLE_DEVICE is no longer here (ie. the drive is disconnected) # Now loop until the link to $REMOVABLE_DEVICE is no longer here (ie. the drive is disconnected)
 # This is to prevent the sync to start over and over # This is to prevent the sync to start over and over
Ligne 219: Ligne 253:
     /bin/sleep 10     /bin/sleep 10
 done done
 + 
 # And remove the lock # And remove the lock
 logger "Remouving the lock file $LOCK" logger "Remouving the lock file $LOCK"
 /bin/rm -f $LOCK /bin/rm -f $LOCK
- 
  
 </code> </code>
Ligne 266: Ligne 299:
 Et on place également le fichier text qui contient le corps du mail à envoyer, dans /etc/BackupPC/raidsync_mail.txt Et on place également le fichier text qui contient le corps du mail à envoyer, dans /etc/BackupPC/raidsync_mail.txt
 <code> <code>
-Les sauvegardes ont été copié sur le support externe. Vous devriez le déconnecter.+Les sauvegardes ont été copiées sur le support externe. Vous devriez le déconnecter.
 L'externalisation se lancera à nouveau dès qu'un support configuré sera connecté. L'externalisation se lancera à nouveau dès qu'un support configuré sera connecté.
 </code> </code>
  • tuto/sauvegardes/externalisation_raid1.1351166084.txt.gz
  • Dernière modification: 25/10/2012 13:54
  • de dani