Restore database 10g em 11gR2 em mesma arquitetura
Autor: Eduardo Valentim | Publicado: 2012-06-28T16:54:00-03:00



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.&nbsp;
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_1export ORACLE_SID=OLDDBexport 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/OPatchRMAN&gt; restore controlfile from '/u01/olddb/o1_mf_ncsn0_TAG20120309T190017_7onzdd6z_.bkp';RMAN&gt; alter database mount;RMAN&gt; catalog start with '/u01/olddb' noprompt;RMAN&gt; 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&gt; exit

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


SQL&gt; alter database open resetlogs upgrade; --# (ou STARTUP UPGRADE após um "alter database open resetlogs")Database altered.SQL&gt; @$ORACLE_HOME/rdbms/admin/utlu112i.sqlERROR:ORA-04023: Object SYS.STANDARD could not be validated or authorizedDECLARE*ERROR at line 1:ORA-04023: Object SYS.STANDARD could not be validated or authorizedERROR:ORA-04023: Object SYS.STANDARD could not be validated or authorized

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


SQL&gt; @$ORACLE_HOME/rdbms/admin/catupgrd.sqlDOC&gt;#######################################################################DOC&gt;#######################################################################DOC&gt;DOC&gt; &nbsp; The first time this script is run, there should be no error messagesDOC&gt; &nbsp; generated; all normal upgrade error messages are suppressed.DOC&gt;.. --#(para brevidade)DOC&gt;#######################################################################DOC&gt;#######################################################################DOC&gt; &nbsp; The following error is generated if the pre-upgrade tool has not beenDOC&gt; &nbsp; run in the old ORACLE_HOME home prior to upgrading a pre-11.2 database:DOC&gt;DOC&gt; &nbsp; SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')DOC&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *DOC&gt; &nbsp; &nbsp; &nbsp;ERROR at line 1:DOC&gt; &nbsp; &nbsp; &nbsp;ORA-01722: invalid numberDOC&gt;DOC&gt; &nbsp; &nbsp; o Action:DOC&gt; &nbsp; &nbsp; &nbsp; Shutdown database ("alter system checkpoint" and then "shutdown abort").DOC&gt; &nbsp; &nbsp; &nbsp; Revert to the original oracle home and start the database.DOC&gt; &nbsp; &nbsp; &nbsp; Run pre-upgrade tool against the database.DOC&gt; &nbsp; &nbsp; &nbsp; Review and take appropriate actions based on the pre-upgradeDOC&gt; &nbsp; &nbsp; &nbsp; output before opening the datatabase in the new software version.DOC&gt;DOC&gt;#######################################################################DOC&gt;#######################################################################DOC&gt;#SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*ERROR at line 1:ORA-01722: invalid numberDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith 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&gt; ALTER TABLE registry$database ADD TZ_VERSION number;SQL&gt; @$ORACLE_HOME/rdbms/admin/catupgrd.sql --# mesmo erro acima...DOC&gt;#######################################################################DOC&gt;#######################################################################DOC&gt;#SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*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&gt; select * from registry$database ;PLATFORM_ID PLATFORM_NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EDITION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TZ_VERSION----------- ----------------------------------------------------------------------------------------------------- ------------------------------ ----------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6 AIX-Based Systems (64-bit)   SQL&gt; Select version from v$timezone_file;&nbsp; &nbsp;VERSION----------&nbsp; &nbsp; &nbsp; &nbsp; 14

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


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


SQL&gt; @catupgrd.sql... --# (para brevidade)DOC&gt; &nbsp; &nbsp; &nbsp; output before opening the datatabase in the new software version.DOC&gt;DOC&gt;#######################################################################DOC&gt;#######################################################################DOC&gt;#Session altered.Table created.Table altered.&nbsp; &nbsp; &nbsp; &nbsp; ((SELECT tz_version from registry$database) is null)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *ERROR at line 8:ORA-01427: single-row subquery returns more than one rowSQL&gt; delete from registry$database where tz_version is null;1 row deleted.SQL&gt; commit;Commit complete.SQL&gt; @catupgrd.sql --Sucesso!SQL&gt; @utlrp.sql --Sucesso!SQL&gt; @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!