Restore database 10g em 11gR2 em mesma arquitetura

Caros amigos,

Precisei restaurar um backup de uma base de dados 10g, porém não achei mais a instalação do software Oracle versão 10g e por isso tive que instalar no 11g e efetuar o Upgrade. 
A restauração ocorreu normal. Preparei o ambiente (spfile, pastas, etc) e comecei a restauração:


export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=OLDDB
export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin:.:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/u01/app/oracle/product/11.2.0/dbhome_1/OPatch
RMAN> restore controlfile from '/u01/olddb/o1_mf_ncsn0_TAG20120309T190017_7onzdd6z_.bkp';
RMAN> alter database mount;
RMAN> catalog start with '/u01/olddb' noprompt;
RMAN> run{
set newname for datafile 1 to new;
set newname for datafile 2 to new;
set newname for datafile 3 to new;
set newname for datafile 4 to new;
restore database;
switch datafile all;
recover database;}
RMAN> exit

--#  Pronto, agora o open resetlogs no SQLPLUS e a tentativa de execução do script de Pre-Upgrade:

SQL> alter database open resetlogs upgrade; --# (ou STARTUP UPGRADE após um "alter database open resetlogs")
Database altered.
SQL> @$ORACLE_HOME/rdbms/admin/utlu112i.sql
ERROR:
ORA-04023: Object SYS.STANDARD could not be validated or authorized

DECLARE
*
ERROR at line 1:
ORA-04023: Object SYS.STANDARD could not be validated or authorized

ERROR:
ORA-04023: Object SYS.STANDARD could not be validated or authorized

--#  Pelo erro não ia dar muito certo, mas eu tentei executar o UPGRADE:

SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql
DOC>#######################################################################
DOC>#######################################################################
DOC>
DOC>   The first time this script is run, there should be no error messages
DOC>   generated; all normal upgrade error messages are suppressed.
DOC>
.. --#(para brevidade)
DOC>#######################################################################
DOC>#######################################################################
DOC>   The following error is generated if the pre-upgrade tool has not been
DOC>   run in the old ORACLE_HOME home prior to upgrading a pre-11.2 database:
DOC>
DOC>   SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
DOC>                       *
DOC>      ERROR at line 1:
DOC>      ORA-01722: invalid number
DOC>
DOC>     o Action:
DOC>       Shutdown database ("alter system checkpoint" and then "shutdown abort").
DOC>       Revert to the original oracle home and start the database.
DOC>       Run pre-upgrade tool against the database.
DOC>       Review and take appropriate actions based on the pre-upgrade
DOC>       output before opening the datatabase in the new software version.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
                 *
ERROR at line 1:
ORA-01722: invalid number

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

--# Em contato com o suporte Oracle eles pediram pra eu fazer isso e rodar o Upgrade de novo, mas não deu certo:

SQL> ALTER TABLE registry$database ADD TZ_VERSION number;
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql --# mesmo erro acima
...
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
                 *
ERROR at line 1:
ORA-01722: invalid number

--# Ele pediu então que eu verificasse as tabelas abaixo e comparasse o valor do TZ_VERSION da visão registry$database que deveria estar com o mesmo valor do campo VERSION na visão v$timezone_file:

SQL> select * from registry$database ;
PLATFORM_ID PLATFORM_NAME                                                                                         EDITION                        TZ_VERSION
----------- ----------------------------------------------------------------------------------------------------- ------------------------------ ----------
          6 AIX-Based Systems (64-bit)

SQL> Select version from v$timezone_file;

   VERSION
----------
        14

--# Pelo jeito não estava, então ele pediu pra inserir:

SQL> INSERT into registry$database
(platform_id, platform_name, edition, tz_version)
VALUES ((select platform_id from v$database),
(select platform_name from v$database),
NULL,
(select version from v$timezone_file));
--# Ficou assim:

SQL> select * from registry$database ;
PLATFORM_ID PLATFORM_NAME                                                                                         EDITION                        TZ_VERSION
----------- ----------------------------------------------------------------------------------------------------- ------------------------------ ----------
          6 AIX-Based Systems (64-bit)
          6 AIX-Based Systems (64-bit)                                                                                                                   14
--# Aparentemente não ia dar certo, mas executei e deu o erro confirmando o que deveria ser feito:

SQL> @catupgrd.sql
... --# (para brevidade)
DOC>       output before opening the datatabase in the new software version.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#
Session altered.

Table created.

Table altered.
        ((SELECT tz_version from registry$database) is null)
          *
ERROR at line 8:
ORA-01427: single-row subquery returns more than one row
SQL> delete from registry$database where tz_version is null;
1 row deleted.
SQL> commit;
Commit complete.
SQL> @catupgrd.sql --Sucesso!
SQL> @utlrp.sql --Sucesso!
SQL> @utlu112s.sql --Tudo VALID! (exceto para o Oracle Multimedia, mas não era necessário. Se precisar basta reconfigurar o recurso)

No final das contas deu tudo certo. Não consegui achar na internet uma solução que fosse satisfatória e só consegui com um direcionamento do suporte Oracle.
Até mais!




Comentários

  1. Respostas
    1. Que bom que deu certo. Já aconteceu comigo várias vezes.

      Excluir
  2. Você salvou minha vida.
    Peguei backup de um oracle 10g com asm e recuperei em outro servidor com oracle 11g sem asm.
    Valeu mesmo !!

    ResponderExcluir

Postar um comentário

Postagens mais visitadas deste blog

Evitando FULL TABLE SCANS quando usar IS NULL em cláusulas WHERE

ALTER USER IDENTIFIED BY VALUES

Restore no RMAN falha com "ORA-01180: can not create datafile 1"