Pular para o conteúdo

Fóruns Banco de dados Oracle Restore com RMAN Restore com RMAN

#90045
vieri
Participante

    BACKUP/RESTORE COM RMAN

    1) Realizar um backup full on-line com [DATABASE+ARCHIVE+CONTROLFILE} com RMAN.

    Backup simples avulso:

    run {
    sql ‘alter system archive log current’;
    backup full database include current contolfile plus archivelog;
    }

    Backup para utilizar como rotina em database de produção
    com versão Standart(sem features de compress)

    ===============DATABASE================

    rman target /

    run {
    allocate channel t1 type disk maxpiecesize = 20G;
    allocate channel t2 type disk maxpiecesize = 20G;
    allocate channel t3 type disk maxpiecesize = 20G;
    backup database include current controlfile tag ‘BKP_WIS_FULL_HOT’
    format ‘/u02/backup/bkp_full_%d_%U_%s.rman’;
    backup current controlfile tag ‘BKP_CTL’
    format ‘/u02/backup/bkp_ctl_%d_%U_%s.rman’;
    backup spfile tag ‘BKP_SPFILE’
    format ‘/u02/backup/bkp_spfile_%d_%U_%s.rman’;
    release channel t1;
    release channel t2;
    release channel t3;
    }

    =========ARCHIVE=============

    run {
    allocate channel ch1 type Disk maxpiecesize = 1000M;
    sql “alter system archive log current”;
    backup archivelog all filesperset 10
    format ‘/u02/backup/arch%p_%t_%U.rman’
    tag ‘BKP_WIS_FULL_ARCHIVE’
    delete all input;
    release channel ch1;

    2) Passe os Backup’s Set’s para o servidor destino – FTP ou SCP.

    2.1) Verifique as permissões dos Backup’s Set’s e diretórios, se estão OK.

    3) Crie o PFILE na base origem ( create pfile from spfile ) transfira para o servidor destino

    No caminho $ORACLE_HOME/dbs com o mesmo nome e altere os parâmetros necessários referente ao novo servidor .

    4) Inicie a instância em nodo nomount para validar apenas o arquivo de parâmetros.

    #> sqlplus “/ as sysdba”

    SQL> startup nomount pfile=/;

    Ou

    #> Rman target /

    RMAN> startup nomount pfile=/;

    5) Cadastre o DBID no servidor antigo, neste novo servidor e Restaure o CONTROL FILE pelo RMAN.

    Com o controlfile restaurado valide o mesmo subindo a instância em modo mount.

    RMAN>SET DBID=428367008;
    RMAN>RESTORE CONTROLFILE FROM ‘/u03/wis/full_wis_692811273_2’;
    RMAN>ALTER DATABASE MOUNT;

    6) Faça um CROSSCHECK do backup , para alinhas as informações de backup com o arquivo de controle.

    RMAN> CROSSCHECK backup;
    RMAN> CROSSCHECK copy;
    RMAN> CROSSCHECK backup of database;
    RMAN> CROSSCHECK backup of controlfile;
    RMAN> CROSSCHECK archivelog all;

    7) Catalogue os seus arquivos de backup, que foram transferidos para o servidor 2.

    RMAN> CATALOG backuppiece ‘′;

    Ex:

    catalog backuppiece ‘/u03/wis/full_wis_692811273_2’;
    catalog backuppiece ‘/u03/wis/full_wis_692814747_3’;
    catalog backuppiece ‘/u03/wis/full_wis_692824194_4’;

    7.1) Verifique com comando LIST BACKUP se está tudo certo com o bkp no destino.

    RMAN> list backup;

    Obter o SCN(system change number) no output do comando

    7.2) RESTAURAR A BASE EM PATCH’s DIFERENTE.

    RUN {
    ALLOCATE CHANNEL C1 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C2 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C3 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C4 DEVICE TYPE DISK;
    SET UNTIL SCN — obtido no list backup ;
    set newname for datafile 1 to ‘/u03/wis/system01.dbf’;
    set newname for datafile 2 to ‘/u03/wis/undotbs1.dbf’;
    set newname for datafile 3 to ‘/u03/wis/sysauy01.dbf’;
    set newname for datafile 4 to ‘/u03/wis/data_entrega.dbf’;
    set newname for datafile 5 to ‘/u03/wis/data_entrega_small.dbf’;
    set newname for datafile 6 to ‘/u03/wis/gkoscf_dtau.dbf’;
    set newname for datafile 7 to ‘/u03/wis/gkoscf_inau.dbf’;
    set newname for datafile 8 to ‘/u03/wis/gkoscf_indy.dbf’;
    set newname for datafile 9 to ‘/u03/wis/indy_entrega.dbf’;
    set newname for datafile 10 to ‘/u03/wis/tbs_data_asstec.dbf’;
    set newname for datafile 11 to ‘/u03/wis/tbs_data_cestqhist_32m.dbf’;
    set newname for datafile 12 to ‘/u03/wis/tbs_data_detprep_32m.dbf’;
    set newname for datafile 13 to ‘/u03/wis/tbs_data_hist_256k.dbf’;
    set newname for datafile 14 to ‘/u03/wis/tbs_data_hist_32m.dbf’;
    set newname for datafile 15 to ‘/u03/wis/tbs_data_hist_5m.dbf’;
    set newname for datafile 16 to ‘/u03/wis/tbs_data_hist_64m.dbf’;
    set newname for datafile 17 to ‘/u03/wis/tbs_data_inet.dbf’;
    set newname for datafile 18 to ‘/u03/wis/tbs_data_sge.dbf’;
    set newname for datafile 19 to ‘/u03/wis/tbs_data_trcmovestq_64m.dbf’;
    set newname for datafile 20 to ‘/u03/wis/tbs_data_wis_256k.dbf’;
    set newname for datafile 21 to ‘/u03/wis/tbs_data_wis_32m.dbf’;
    set newname for datafile 22 to ‘/u03/wis/tbs_data_wis_5m.dbf’;
    set newname for datafile 23 to ‘/u03/wis/tbs_indy_asstec.dbf’;
    set newname for datafile 24 to ‘/u03/wis/tbs_indy_cestqhist_32m.dbf’;
    set newname for datafile 25 to ‘/u03/wis/tbs_indy_detprep__32m.dbf’;
    set newname for datafile 26 to ‘/u03/wis/tbs_indy_hist_256k.dbf’;
    set newname for datafile 27 to ‘/u03/wis/tbs_indy_inet.dbf’;
    set newname for datafile 28 to ‘/u03/wis/tbs_indy_sge.dbf’;
    set newname for datafile 29 to ‘/u03/wis/tbs_indy_trcmovestq_64m.dbf’;
    set newname for datafile 30 to ‘/u03/wis/tbs_indy_wis_256k.dbf’;
    set newname for datafile 31 to ‘/u03/wis/tbs_indy_wis_32m.dbf’;
    set newname for datafile 32 to ‘/u03/wis/tbs_indy_wis_5m.dbf’;
    set newname for datafile 33 to ‘/u03/wis/tools.dbf’;
    set newname for datafile 34 to ‘/u03/wis/undotbs2.dbf’;
    set newname for datafile 35 to ‘/u03/wis/users.dbf’;
    set newname for datafile 36 to ‘/u03/wis/gkoscf_data.dbf’;
    SQL “ALTER DATABASE RENAME FILE ”/u02/oracle/oradata/wis/redo01.log”
    TO ”/u03/wis/redo01.log” “;
    SQL “ALTER DATABASE RENAME FILE ”/u02/oracle/oradata/wis/redo02.log”
    TO ”/u03/wis/redo02.log” “;
    SQL “ALTER DATABASE RENAME FILE ”/u02/oracle/oradata/wis/redo03.log”
    TO ”/u03/wis/redo03.log” “;
    SQL “ALTER DATABASE RENAME FILE ”/u02/oracle/oradata/wis/redo04.log”
    TO ”/u03/wis/redo04.log” “;
    RESTORE DATABASE;
    switch datafile all;
    RECOVER DATABASE ;
    ALTER DATABASE OPEN RESETLOGS;
    }

    8.1) Restaurar a base no mesmo path da origem.

    RUN {
    ALLOCATE CHANNEL C1 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C2 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C3 DEVICE TYPE DISK;
    ALLOCATE CHANNEL C4 DEVICE TYPE DISK;
    SET UNTIL SEQUENCE 1190 THREAD 1; — obtidos na V$LOG
    RESTORE DATABASE;
    switch datafile all;
    RECOVER DATABASE ;
    ALTER DATABASE OPEN RESETLOGS;
    }

    As queryes abaixo pode ser extremamente úteis na origem e destino.
    Assim como comandos do RMAN como o list backup.

    SELECT first_change#, next_change#, sequence#, archived
    FROM v$archived_log;
    select file#,checkpoint_change#,status from v$datafile;
    select * from v$recover_file;
    select * from v$recovery_log;
    select * from v$LOG;
    select * from v$database;

    Você pode utilizar tanto until time , until scn , until log seq
    until cancel somente no sql plus.

    Como é base de homologação pode usar oque se sentir mais confiante!

    caso não consiga poste e erro pra gente!

    []s