Movendo o Banco de Dados Windows 11gR2 (source) para Oracle Linux 12c (target).
Autor: Alessandro Cordeiro | Publicado: 2015-02-20T11:13:00-08:00

No Post anterior (http://alecordeirosilva.blogspot.com.br/2015/02/instalacao-do-software-do-banco-de.html), foi apresentado a instalação do software Oracle 12c no Linux, neste será apresentado a migração do banco 11g em Windows para o 12c.

No banco source logue e realize a consulta abaixa para confirmação que é possivel realizar o upgrade direto, pois dependendo do S.O a ser migrado é preciso realizar alguns passos a mais para conversão.






1 - Coloque no&nbsp;estado Mount o banco de dados source e faça um backup limpo.



C:\&gt;sqlplus
/nolog

SQL&gt; connect sys/senha@bdagnus as sysdba

Conectado.

SQL&gt; shutdown immediate;

SQL&gt; startup mount;

SQL&gt; alter database open read only;



SQL&gt; exit;



C:\&gt;rman target sys/senha@bdagnus nocatalog



rman&gt;&nbsp;run { allocate channel discozero type disk format
'C:\BCK_AGNUS\BCK/%d%T_%s.bkp';&nbsp;
backup incremental level = 0 (database include current controlfile);}



2-Criar um pfile para o banco de dados target.



rman&gt;exit;


C:\&gt;sqlplus /nolog

SQL&gt; connect sys/senha@bdagnus as sysdba

Conectado.

SQL&gt; create pfile='c:\BCK_AGNUS\initbdagnus.ora' from spfile;





3- Configure o pfile e as pastas linux para restaurar o ControlFile.



Edit o arquivo pfile para o padrão linux, como no exemplo abaixo:



*.audit_file_dest='/u01/app/oracle/admin/cdbagnus/adump'

*.control_files='/u01/app/oracle/oradata/cdbagnus/controlfile/control01.ctl'

*.db_name='BDAGNUS'



*.diagnostic_dest='/u01/app/oracle/'



Abra uma sessão no putty com usuario oracle e crie as pastas necessárias.



[oracle@LXAGNUS ~]&nbsp;cd&nbsp;/u01/app/oracle/

[oracle@LXAGNUS ~] mkdir -p&nbsp;admin/cdbagnus/adump

[oracle@LXAGNUS ~]&nbsp;mkdir -p&nbsp;oradata/cdbagnus/controlfile/



4-&nbsp;Mount o compartilhamento do Windows para ter acesso aos backups.



[root@LXAGNUS ~] mount -t cifs -o username=usuario,password=senha //192.168.56.1/bck_agnus /mnt

5- Inicie a Instância no modo nomount

[oracle@LXAGNUS ~] sqlplus / as sysdba
SQL&gt; startup nomount pfile='/mnt/initbdagnus.ora';



6- Restore o ControlFile.



Logue no Rman e restore o controlfile lendo o backup feito no Windows. O backup é composto por dois arquivos, o menor é o backup do controlfile.



[oracle@LXAGNUS ~] rman target /

RMAN&gt; restore controlfile from '/mnt/BCKBDAGNUS20150210_47.BKP';

RMAN&gt; alter database mount;



7-Catalogue o backup no servidor Linux.



Rman&gt; crosscheck backup;

Rman&gt; delete expired backup;

Rman&gt; Catalog start with '/mnt/bck_agnus/';



8-Restaurar o Banco de dados.



Rman &gt;&nbsp;sql 'ALTER SYSTEM SET DB_CREATE_FILE_DEST="/u01/app/oracle/oradata/cdbagnus"';

Rman &gt; run {set newname for database to NEW;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; restore database;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch datafile all;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recover database;&nbsp;}



9-Abrir o Banco de dados com resetlogs.



Rman &gt; exit;

[oracle@LXAGNUS ~]sqlplus / as sysdba

SQL&gt; Select member from v$logfile ;



MEMBER
---------------------------------
C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO01.LOG
C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO02.LOG
C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO03.LOG



SQL&gt; alter database rename file 'C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO01.LOG' TO '/u01/app/oracle/oradata/cdbagnus/onlinelog/redo01.log';



SQL&gt; alter database rename file&nbsp;'C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO02.LOG' TO '/u01/app/oracle/oradata/cdbagnus/onlinelog/redo02.log';




SQL&gt; alter database rename file&nbsp;'C:\APP\ALESSANDRO\ORADATA\BDAGNUS\ONLINELOG\REDO03.LOG' TO '/u01/app/oracle/oradata/cdbagnus/onlinelog/redo03.log';



SQL&gt; alter database open resetlogs upgrade;



10- Criar a tablespace Temp.



SQL&gt;create temporary tablespace temp2 tempfile '/u01/app/oracle/oradata/cdbagnus/oradata/TEMP.dbf' size 1G;

SQL&gt;ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;

SQL&gt;drop tablespace temp;

SQL&gt;ALTER TABLESPACE temp2 RENAME TO temp;



11-Chamar o catupgrd para realizar o upgrade do Banco 11g para 12c.&nbsp;



SQL&gt; exit;

[oracle@LXAGNUS ~]$ORACLE_HOME/perl/bin/perl catctl.pl -n 4 catupgrd.sql



12 - Aguardar a execução, a saida será algo do tipo:



Analyzing&nbsp;file&nbsp;catupgrd.sql &nbsp;

Serial&nbsp;&nbsp;&nbsp;Phase&nbsp;#:&nbsp;0&nbsp;Files:&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:&nbsp;340s &nbsp;

Serial&nbsp;&nbsp;&nbsp;Phase&nbsp;#:&nbsp;1&nbsp;Files:&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:&nbsp;147s &nbsp;

Restart&nbsp;&nbsp;Phase&nbsp;#:&nbsp;2&nbsp;Files:&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:&nbsp;3s &nbsp;

Parallel&nbsp;Phase&nbsp;#:&nbsp;3&nbsp;Files:&nbsp;18&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:&nbsp;41s &nbsp;

Restart&nbsp;&nbsp;Phase&nbsp;#:&nbsp;4&nbsp;Files:&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:&nbsp;0s &nbsp;

...&nbsp;



Após a execução o seu banco de dados foi migrado do 11g Windows para o Oracle 12C Linux.