Cette commande très pratique permet notamment de couper une copie miroir en vue d'une sauvegarde 'à froid'.

En effet, il suffit de stopper les applications, utiliser cette commande pour couper le LV et remonter une des copies sous un autre nom, de sauvegarder ce nouveau FS et de raccrocher ensuite la copie.

Un arrêt court de la production est possible, juste durant le temps de la coupure du FS( pour que les fichiers soient correctement fermés).

 Exemple de script :

#!/bin/ksh
# Programme de gestion des FS à spliter pour les sauvegardes.
#
# Arguments : 1er : [ON/OFF]
# 2eme : Nom_du_FS
#Christian SONOLET
ACTION=$1
NOM_FS=$2

# Variable pour le nom du répertoire de départ des accrochages de FS
export REP_BACKUP=/split

if test $# -lt 2
then
echo "Usage : $0 ON/OFF NOM_FS ($*)"
sleep 4
exit 4
fi
case "$ACTION" in
"ON"|"OFF") echo "OK" > /dev/null
;;
*) echo "Usage : $0 ON OFF NOM_FS ($*)"
;;
esac
# ********************************************************************
####### # #
# # ## #
# # # # #
# # # # #
# # # # #
# # # ##
####### # #
# ********************************************************************
Prog_ON()
{
if test ! -d $1
then
echo "File system $1 unknowned!"
return 5
fi
# Vérification que le LV est bien en 2 exemplaires.
LV_ASSOCIE="`lsfs $1|grep -v Auto|awk '{ print $1 }' 2> /dev/null` "
LV_ASSOCIE="`basename $LV_ASSOCIE`"

NB_COPIES=` lslv $LV_ASSOCIE |grep 'COPIES:'|awk '{ print $2 }'|sed 's/://' 2> /dev/null`

if test $NB_COPIES -lt 2
then
echo "****WARNING***Pas de copie miroir pour $1 ***** "
return 0
fi
echo "Activation du FS $1"
# NEW_REP=`basename $1`
#
mkdir -p $REP_BACKUP/$1
#
# Vérification que le système de fichiers ORIGINE est bien monté.
#
IS_MOUNTED=`mount |grep -w $1 | awk '{ print $2 }'`
if test "$IS_MOUNTED" != "$1"
then
echo "Le système de fichiers n'est pas monté...Montage"
mount $1
fi

# Verification si le SPLIT existe déja
lsfs ${REP_BACKUP}$1 2>&1 >/dev/null
BACKUP_EXIST=$?

if test $BACKUP_EXIST -eq 0
then
echo " La copie de $1 existe déja"
# Verification si le FS est monté
IS_BACK_MOUNTED=`mount |grep -w ${REP_BACKUP}$1 | awk '{ print $2 }'`
if test "$IS_BACK_MOUNTED" != "${REP_BACKUP}$1"
then
echo " Le système de fichiers BACKUP n'est pas monté...Montage"
mount ${REP_BACKUP}$1
return $?
fi
return 0
fi

# Découpage d'une copie pour accrochage sous /split/...
chfs -asplitcopy=${REP_BACKUP}$1 -a copy=2 $1 >/dev/null
RETOUR=$?
if test $RETOUR -ne 0
then
echo "**** Error creating a Split Copy of $1 (Error code=$RETOUR)"
fi
}
# ****************************************************************************
####### ####### #######
# # # #
# # # #
# # ##### #####
# # # #
# # # #
####### # #

# ***************************************************************************
Prog_OFF()
{
if test ! -d $1
then
echo "File system $1 unknowned!"
return 5
fi
echo "Desactivation du FS $1"
echo "Recherche du Volume logique associé a $1"
lv_orig=`lsfs -c $1 |grep -v MountPoint| sed 's/:/ /g'| awk '{ print $2 }'`

echo "Recherche FS copie de $lv_orig ..."
for vg in `lsvg -o`
do
lsvg -l $vg
done >/tmp/lsvg.dat

nom_vl=`basename $lv_orig `
FS_COPIE=`cat /tmp/lsvg.dat|grep ${nom_vl}copy0 |awk '{ print $7 }'`

if test "$FS_COPIE" = ""
then
echo " Pas de copie de $1 trouvée..."
return 0
fi

NOM_LV=`df -k $FS_COPIE |grep -v Filesystem |grep $lv_orig |awk '{ print $1 }'`

# ARRET DES PROCESSUS EVENTUELLEMENT EN COURS
echo "....Arrêt forcé des processus lié au FS"
fuser -k $NOM_LV

# DEMONTAGE DU FS COPIE
echo "....Démontage du FS"
umount $FS_COPIE

echo "....Effacement du VL"
rmlv -f `basename $NOM_LV`

# DESTRUCTION POUR RESYNCHRONISATION et RETOUR A LA NORMALE
echo "....Effacement du FS copie $FS_COPIE"
rmfs $FS_COPIE 2>&1 > /dev/null

sync
echo "....Désactivation du mode Copie du VL $lv_orig"
chlvcopy -f -B `basename $lv_orig` 2>/dev/null >&2

echo "....Synchronisation de la Copie du VL"
syncvg -l `basename $lv_orig`

}
###############################################################################
# # # ### # #
## ## # # # ## #
# # # # # # # # # #
# # # # # # # # #
# # ####### # # # #
# # # # # # ##
# # # # ### # #
###############################################################################
# Decalage pour l'ACTION
shift 1

# Test de présence du répertoire
if test ! -d $REP_BACKUP
then
echo "Création du répertoire $REP_BACKUP"
mkdir -p $REP_BACKUP
fi

for FS in $*
do
Prog_$ACTION $FS
retour=$?
if test $retour -ne 0
then
echo "**** ERREUR de traitement ( $retour )****"
fi
echo "..........................................."
sync;sync
sleep 5
sync;sync
done

Exemple avec un VG ora2vg( ATTENTION/!\ les processus du FS SOURCE sont KILLED donc la base doit être arrêtée):

#!/bin/ksh
#/paf0302:
# dev = /dev/paf0302
# vfs = jfs2
# log = INLINE
# mount = false
# check = false
# type = appsvg
# ATTENTION? le script KILL tous les processus du FS source, donc la base doit ETRE STOPPEE
export DIR_LOGS=/tmp
# lancement du splitting
LISTEVG='ora2vg'
echo splitting of `date` >>$DIR_LOGS/split.log
#echo "**** /tina enlevé du traitement *******"
lsvg -l $LISTEVG |grep -v tina |grep -w jfs |grep split|while read nom type numlv numlp numpv state fs
do
# test de l'existence du file system splite
if lsfs |grep -w /split$fs
then
echo "le file systeme /split$fs existe deja" >>$DIR_LOGS/split.log
# test du montage du file system
if ! df -k|grep -w /split$fs
then
mount /split${fs}
fi
else
#splitting du file system
echo "splitting du file systeme /split$fs" >>$DIR_LOGS/split.log
fuser -k /dev/$nom
umount $fs
splitlvcopy -y N$nom $nom 1
ret=$?
if test $ret -eq 0
then
echo "Changement du point de montage du nouveau FS" >> $DIR_LOGS/split.log
chlv -L /split$fs N$nom

echo "Creation du paragraphe dans /etc/filesystems">> $DIR_LOGS/split.log
echo "
/split${fs}:
dev = /dev/N$nom
vfs = jfs2
log = INLINE
mount = false
check = false
" >> /etc/filesystems
echo "Insertion dans le groupe $LISTEVG"
chfs -p ro -a type=$LISTEVG /split$fs
else
echo "Erreur $ret lors du splitcopy." >>$DIR_LOGS/split.log
fi
if test ! -d /split$fs
then
echo "Creation du repertoire /split$fs...">>$DIR_LOGS/split.log
mkdir -p /split$fs
fi
mount $fs
mount /split${fs}
echo "montage de filesystems $fs et /split$fs ....">>$DIR_LOGS/split.log
echo "==============================" >>$DIR_LOGS/split.log
fi
done

Ci-dessous la description plus détaillée en anglais.

 

 

splitlvcopy Command

Purpose

Splits copies from one logical volume and creates a new logical volume from them.

Syntax

splitlvcopy-f ] [  -y NewLogicalVolumeName ] [  -Y Prefix ] LogicalVolume CopiesPhysicalVolume ... ]

Description

Notes:

  1. To use this command, you must either have root user authority or be a member of the system group.
  2. The splitlvcopy command is not allowed on a snapshot volume group or a volume group that has a snapshot volume group.

Attention: Although the splitlvcopy command can split logical volumes that are open, including logical volumes containing mounted filesystems, this is not recommended. You may lose consistency between LogicalVolume and NewLogicalVolume if the logical volume is accessed by multiple processes simultaneously. When splitting an open logical volume, you implicitly accept the risk of potential data loss and data corruption associated with this action. To avoid the potential corruption window, close logical volumes before splitting and unmount filesystems before splitting.

The splitlvcopy command removes copies from each logical partition in LogicalVolume and uses them to create NewLogicalVolume. The Copies parameter determines the maximum number of physical partitions that remain in LogicalVolume after the split. Therefore, if LogicalVolume has 3 copies before the split, and the Copies parameter is 2, LogicalVolume will have 2 copies after the split and NewLogicalVolume will have 1 copy. You can not split a logical volume so that the total number of copies in LogicalVolume and NewLogicalVolume after the split is greater than the number of copies in LogicalVolume before the split.

The NewLogicalVolume will have all the same logical volume characteristics as LogicalVolume. If LogicalVolume does not have a logical volume control block the command will succeed with a warning message and creates NewLogicalVolume without a logical volume control block.

There are additional considerations to take when splitting a logical volume containing a filesystem. After the split there will be two logical volumes but there will only be one entry in the /etc/filesystems file which refers to LogicalVolume. To access NewLogicalVolume as a filesystem you must create an additional entry in /etc/filesystems with a different mount point which refers to NewLogicalVolume. If the mount point does not already exist, you have to create it before the new filesystem can be mounted. In addition, if NewLogicalVolume was created while LogicalVolume was open, you have to run the command

fsck /dev/NewLogicalVolume

before the new filesystem can be mounted.

You can not use the System Management Interface Tool (SMIT) to run this command. Message catalogs are not supported for this command and therefore the error messages are provided in English only with no message catalog numbers. Documentation for splitlvcopy consists of this man page.

Flags

-f

Specifies to split open logical volumes without requesting confirmation. By default, splitlvcopy requests confirmation before splitting an open logical volume. This includes open raw logical volumes and logical volumes containing mounted filesystems.

-y NewLogicalVolumeName

Specifies the name of the new logical volume to move copies to from LogicalVolume.

-Y Prefix

Specifies the Prefix to use instead of the prefix in a system-generated name for the new logical volume. The prefix must be less than or equal to 13 characters. A name cannot begin with a prefix already defined in the PdDv class in the Device Configuration Database for other devices, nor be a name already used by another device.

Parameters

Copies

Specifies the maximum number of physical partitions that remain in LogicalVolume after the split.

LogicalVolume

Specifies the logical volume name or logical volume ID to split.

PhysicalVolume

Specifies the physical volume name or the physical volume ID to remove copies from.

Exit Status

This command returns the following exit values:

0

Successful completion.

>0

An error occurred.

Security

Access Control: You must have root authority to run this command or be a member of the system group.

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Auditing Events: N/A

Examples

To split one copy of each logical partition belonging to logical volume named oldlv which currently has 3 copies of each logical partition, and create the logical volume newlv, enter:

splitlvcopy -y newlv oldlv 2

Each logical partition in the logical volume oldlv now has two physical partitions. Each logical partition in the logical volume newlv now has one physical partition.

Files

/usr/sbin/splitlvcopy

Contains the splitlvcopy command.

/tmp

Contains the temporary files created while the splitlvcopy command is running.

Related Information

Commands: rmlvcopy and mklv.

 

icon phone
Téléphone/Whatsapp : +33 (0)6 83 84 85 74
icon phone