A dica de hoje é para quem precisar sempre criar ou atualizar um ambiente Oracle de desenvolvimento ou homologação de forma fácil utilizando o duplicate.
1- Criar um init baseado nas configurações do teu ambiente, podem adaptar este init base DEV abaixo e utilizar:
*.audit_trail='DB'
*.commit_logging='BATCH'
*.commit_wait='NOWAIT'
*.compatible='11.2.0.4.0'
*.control_files='/u02/dev/oradata/dev/control01.ctl','/u02/dev/oradata/dev/control02.ctl','/u02/dev/oradata/dev/control03.ctl'#Restore Controlfile
*.core_dump_dest='/u01/app/oracle/admin/dev/cdump'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_domain=”
*.db_file_multiblock_read_count=16
*.db_name='dev'
*.db_writer_processes=2
*.diagnostic_dest='/u01/app/oracle'
*.enable_goldengate_replication=TRUE
*.job_queue_processes=20
*.large_pool_size=0
*.log_archive_dest_1='LOCATION=/u02/dev/backup/archivelog/'
*.log_archive_format='%t_%s_%r.arc'
*.memory_max_target=9663676416
*.memory_target=9663676416
*.open_cursors=6000
*.optimizer_index_caching=70
*.optimizer_index_cost_adj=1
*.optimizer_mode='ALL_ROWS'
*.pga_aggregate_target=0
*.processes=2000
*.recyclebin='OFF'
*.remote_login_passwordfile='EXCLUSIVE'
*.session_cached_cursors=40
*.sessions=1105
*.sga_max_size=0
*.sga_target=0
*.undo_management='AUTO'
*.undo_retention=3600
*.undo_tablespace='UNDOTBS1'
*.utl_file_dir='*'
SQL2 – Adicionar o convert ao init com diretório da origem (oradata/DADOS/prd/) com o novo destino (/u02/dev/oradata/dev/):
*.db_file_name_convert='/oradata/DADOS/prd/','/u02/dev/oradata/dev/','/oradata/INDICES/prd/','/u02/dev/oradata/dev/','/oradata/INDICES/datafile',
'/u02/dev/oradata/dev/'
*.log_file_name_convert='/oradata/DADOS/REDOLOG/prd/','/u02/dev/oradata/dev/','/oradata/INDICES/REDOLOG/prd/','/u02/dev/oradata/dev/'
SQL3 – Ajustar o script do duplicate abaixo data e hora do restore e local do backup que iremos utilizar:
Data e hora: 18/10/2018 23:00:00
Local do backup: /u02/dev/backup/restore
Local dos logs com ações e acompanhamento do duplicate: /u01/app/oracle/logs
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=dev
export BASE=/u01/app/oracle
export DEST=/u02/dev/backup/
export HOJE=`date +%Y%m%d`
export SPOOL=$DEST/logs
export ORACLE_SID=dev
sqlplus / as sysdba << EOF
spool $SPOOL/atualiza_dev_0_shutdown_base_$HOJE.spool
SHUTDOWN ABORT;
# Iniciando a instancia do banco utilizando o pfile que criamos acima
STARTUP NOMOUNT pfile='/u02/dev/backup/scripts/initdev.ora';
spool off
exit
EOF
# clone do backup para dev
rman auxiliary / msglog $SPOOL/clonando_base_$HOJE.spool << EOF
RUN
{
#DATA E HORARIO FINAL DO PONTO DO RESTORE A SER EFETUADO
set until time "to_date('18/10/2018 23:00:00','DD/MM/YYYY HH24:MI:SS')";
allocate auxiliary channel c1 type disk ;
# LOCAL ONDE ESTA O BACKUP DOS CONTROLFILES E DO BACKUPSET
duplicate target database to dev backup location='/u02/dev/backup/restore';
}
EOF
ShellScript4 – Executar o script:
nohup ./duplicate_dev.sh &
ShellScript