jeudi 2 septembre 2010

Comment sauvegarder le catalogue RMAN lorsque la BD est sous ASM?

Note:
Cet article a été rédigé en me basant sur la version 11gR2

La méthode de sauvegarde de bd recommandée par Oracle est l'utilisation de RMAN.
Il ne faut cependant pas oublier de sauvegarder aussi la bd qui habrite le catalogue RMAN. La méthode standard lorsque ASM n'est pas utilisé pour cette bd est d'utiliser le «user-managed backup». Cela consiste à mettre la bd entière ou les tablespaces en mode «begin backup» et de copier les fichiers de données à l'aide des commandes de l'OS.

Mais qu'en est-il lorsqu'ASM est utilisé pour cette BD?

Lorsqu'on utilise ASM, on ne peut plus faire de copie de datafiles par les commandes de l'OS. Il faut donc trouver une autre manière de sauvegarder la bd du catalogue RMAN.

Pour répondre à cette préoccupation, Oracle propose d'utiliser RMAN pour sauvegarder la bd du catalogue RMAN. Mais cette sauvegarde RMAN se fera sans catalogue (c'est à dire que les control files de la bd qui seront utilisés pour sauvegarder les metadonnées de la sauvegarde).

Procéder comme suit pour sauvegarder la bd du catalogue RMAN:

1 - Configurer le paramètre AUTOBACKUP de rman de sorte à prendre en copie le control file et le spfile:

oracle@udl001:/ucl03a_u01/home/dba/oracle/backup/CAT11GR2> . oraenv
ORACLE_SID = [BD11201] ? CAT11GR2
The Oracle base for ORACLE_HOME=/ucl03a_u01/home/dba/oracle/product/11.2.0.1.0 is /udl001_u01/home/dba/oracle
oracle@udl001:/ucl03a_u01/home/dba/oracle/backup/CAT11GR2>
-- CAT11GR2 est la bd du catalogue RMAN


oracle@udl001:/ucl03a_u01/home/dba/oracle> rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Jeu. Sept. 2 14:34:50 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: CAT11GR2 (DBID=546181866)
RMAN>

a - Faire un «show all» pour voir les paramètres actuels:

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name CAT11GR2 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/ucl03a_u01/home/dba/oracle/product/11.2.0.1.0/dbs/snapcf_CAT11GR2.f'; # default

RMAN>

b - Mettre le paramètre AUTOBACKUP à ON:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN>

Si la sauvegarde doit se faire sur TAPE:

RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO 'ctl_%d_%F.back';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO 'ctl_%d_%F.back';
new RMAN configuration parameters are successfully stored
RMAN>

Si la sauvegarde doit se faire sur disque:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/CTL/ctl_%d_%F.back';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/CTL/ctl_%d_%F.back';
new RMAN configuration parameters are successfully stored
RMAN>

Note:

Pour remettre la valeur par défaut:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE CLEAR;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO 'ctl_%d_%F.back';
RMAN configuration parameters are successfully reset to default value

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/CTL/ctl_%d_%F.back';
RMAN configuration parameters are successfully reset to default value

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored

2 - Une fois les paramètres positionnés, l'on peut lancer la sauvegarde comme suit (ceci est juste un exemple):
-- La commande «tee» ajoutée permet de rediriger le log dans un fichier

rman target / nocatalog | tee /ucl03a_u01/home/dba/oracle/backup/CAT11GR2/LOG/backup_rman_cat11gr2.log
run{
allocate channel c1 type disk
format '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/DBF/df_%U.bak';
backup incremental level=0 cumulative
database;
sql 'alter system archive log current';
release channel c1;
allocate channel c2 type disk
format '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/ARCH/arch_%U.bak';
backup
filesperset 10
archivelog all;
release channel c2;
}

Exemple:

oracle@udl001:/ucl03a_u01/home/dba/oracle> rman target / nocatalog | tee /ucl03a_u01/home/dba/oracle/backup/CAT11GR2/LOG/backup_rman_cat11gr2.log

Recovery Manager: Release 11.2.0.1.0 - Production on Jeu. Sept. 2 14:56:14 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: CAT11GR2 (DBID=546181866)
using target database control file instead of recovery catalog

RMAN> run{
2> allocate channel c1 type disk
format '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/DBF/df_%U.bak';
backup incremental level=0 cumulative
database;
sql 'alter system archive log current';
release channel c1;
3> allocate channel c2 type disk
4> format '/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/ARCH/arch_%U.bak';
backup
filesperset 10
archivelog all;
5> 6> release channel c2;
}
7> 8> 9> 10> 11> 12> 13> 14>
allocated channel: c1
channel c1: SID=334 device type=DISK

Starting backup at 2010-09-02 14:57:08
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=+SYSGRP01/cat11gr2/datafile/sysaux.256.714929507
input datafile file number=00001 name=+SYSGRP01/cat11gr2/datafile/system.258.714929633
input datafile file number=00005 name=+DATAGRP01/cat11gr2/datafile/rman_di01.311.714929707
input datafile file number=00003 name=+SYSGRP01/cat11gr2/datafile/undotbs1.259.714929827
input datafile file number=00007 name=+DATAGRP01/cat11gr2/datafile/admtec_d01.259.714929827
input datafile file number=00006 name=+DATAGRP01/cat11gr2/datafile/admtec_i01.310.714929707
input datafile file number=00004 name=+SYSGRP01/cat11gr2/datafile/users.257.714929507
channel c1: starting piece 1 at 2010-09-02 14:57:10
channel c1: finished piece 1 at 2010-09-02 14:57:35
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/DBF/df_0elmt2u5_1_1.bak tag=TAG20100902T145708 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
Finished backup at 2010-09-02 14:57:35

Starting Control File and SPFILE Autobackup at 2010-09-02 14:57:35
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/CTL/ctl_CAT11GR2_c-546181866-20100902-00.back comment=NONE
Finished Control File and SPFILE Autobackup at 2010-09-02 14:57:36

sql statement: alter system archive log current

released channel: c1

allocated channel: c2
channel c2: SID=334 device type=DISK

Starting backup at 2010-09-02 14:57:39
current log archived
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=172 RECID=386 STAMP=725296879
input archived log thread=1 sequence=173 RECID=388 STAMP=725321525
input archived log thread=1 sequence=174 RECID=390 STAMP=725393479
input archived log thread=1 sequence=175 RECID=391 STAMP=725412997
input archived log thread=1 sequence=176 RECID=393 STAMP=725479953
input archived log thread=1 sequence=177 RECID=396 STAMP=725493717
input archived log thread=1 sequence=178 RECID=398 STAMP=725547663
input archived log thread=1 sequence=179 RECID=399 STAMP=725566441
input archived log thread=1 sequence=180 RECID=402 STAMP=728423395
input archived log thread=1 sequence=181 RECID=403 STAMP=728423395
channel c2: starting piece 1 at 2010-09-02 14:57:42
channel c2: finished piece 1 at 2010-09-02 14:57:57
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/ARCH/arch_0glmt2v5_1_1.bak tag=TAG20100902T145739 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:15
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=182 RECID=405 STAMP=728423398
input archived log thread=1 sequence=183 RECID=407 STAMP=728425223
input archived log thread=1 sequence=184 RECID=410 STAMP=728425249
input archived log thread=1 sequence=185 RECID=411 STAMP=728425279
input archived log thread=1 sequence=186 RECID=414 STAMP=728425306
input archived log thread=1 sequence=187 RECID=415 STAMP=728425337
input archived log thread=1 sequence=188 RECID=417 STAMP=728425364
input archived log thread=1 sequence=189 RECID=419 STAMP=728425391
input archived log thread=1 sequence=190 RECID=422 STAMP=728425419
channel c2: starting piece 1 at 2010-09-02 14:57:58
channel c2: finished piece 1 at 2010-09-02 14:58:13
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/ARCH/arch_0hlmt2vl_1_1.bak tag=TAG20100902T145739 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:15
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=191 RECID=424 STAMP=728425448
input archived log thread=1 sequence=192 RECID=425 STAMP=728425472
input archived log thread=1 sequence=193 RECID=427 STAMP=728425496
input archived log thread=1 sequence=194 RECID=430 STAMP=728431301
input archived log thread=1 sequence=195 RECID=431 STAMP=728488823
input archived log thread=1 sequence=196 RECID=433 STAMP=728531251
input archived log thread=1 sequence=197 RECID=436 STAMP=728604191
input archived log thread=1 sequence=198 RECID=438 STAMP=728665058
input archived log thread=1 sequence=199 RECID=439 STAMP=728665059
channel c2: starting piece 1 at 2010-09-02 14:58:14
channel c2: finished piece 1 at 2010-09-02 14:58:21
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/ARCH/arch_0ilmt305_1_1.bak tag=TAG20100902T145739 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:07
Finished backup at 2010-09-02 14:58:21

Starting Control File and SPFILE Autobackup at 2010-09-02 14:58:21
piece handle=/ucl03a_u01/home/dba/oracle/backup/CAT11GR2/CTL/ctl_CAT11GR2_c-546181866-20100902-01.back comment=NONE
Finished Control File and SPFILE Autobackup at 2010-09-02 14:58:22

released channel: c2

RMAN>

On voit bien qu'une copie du control file et du spfile a été prise à la fin du backup.

Dans un prochain article, l'on verra comment restaurer un tel backup.

Aucun commentaire:

Enregistrer un commentaire