2020年3月3日 星期二

Oracle DB - Restore PRD DB to QAS env


cat /usr/openv/netbackup/bp.conf
SERVER = dao-nbu
CLIENT_NAME = daoqas
CONNECT_OPTIONS = localhost 1 0 2

su - oraqas
/usr/openv/netbackup/bin/oracle_link
ll $ORACLE_HOME/lib|grep libobk

/usr/openv/netbackup/bin/bplist -C daoprd -t 4 -R /


cd /oracle/QAS/112_64/dbs
mv initQAS.ora initQAS_bak.ora
create pfile='/oracle/QAS/112_64/dbs/initQAS.ora' from spfile;
vi /oracle/QAS/112_64/dbs/initQAS.ora
#*.db_name='QAS'
*.db_name=PRD
*.db_unique_name=QAS


sqlplus / as sysdba
startup nomount pfile=/oracle/QAS/112_64/dbs/initQAS.ora
# rman catalog rman/rman@catalogdb
RMAN>
set dbid=9876555555
connect target /

RMAN>
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
SEND 'NB_ORA_SERV=dao-nbu, NB_ORA_CLIENT=daoprd';
RESTORE controlfile;
RELEASE CHANNEL ch00;
}

sqlplus / as sysdba
alter database mount;


RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64';
SEND 'NB_ORA_SERV=dao-nbu.dao.com, NB_ORA_CLIENT=daoprd';
set newname for datafile 1 to '/oracle/QAS/sapdata1/system_1/system.data1';
set newname for datafile 2 to '/oracle/QAS/sapdata1/undo_1/undo.data1';
set newname for datafile 3 to '/oracle/QAS/sapdata1/sysaux_1/sysaux.data1';
SET UNTIL TIME "TO_DATE('2020/02/19 04:00:00','YYYY/MM/DD HH24:MI:ss')";
restore database;
switch datafile all;
RECOVER DATABASE;
}


cd  /home/oraqas
vi restoredb_20200219.rman

# cd  /home/oraqas
# rman target / nocatalog cmdfile=restoredb_20200219.rman log=restoredb_20200219-1.log &

sqlplus / as sysdba
alter database open resetlogs;


cd $ORACLE_HOME/dbs
mv spfileQAS.ora spfileQAS.ora.20200115bak

SQL> create spfile from pfile;

CREATE TEMPORARY TABLESPACE psaptemp1 TEMPFILE '/oracle/QAS/sapdata1/temp_1/temp1.data1' SIZE 3000M;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE psaptemp1;
DROP TABLESPACE psaptemp INCLUDING CONTENTS AND DATAFILES;
select tablespace_name from dba_temp_files;
shutdown immediate


su - oraqas
sqlplus / as sysdba
SQL> STARTUP MOUNT

nid TARGET=sys DBNAME=QAS
sqlplus / as sysdba
SQL> startup mount
SQL> alter system set db_name=QAS scope=spfile;
SQL> alter database noarchivelog;
SQL> shutdown immediate


SQL> startup
SQL> ALTER DATABASE OPEN RESETLOGS;
SQL> shutdown immediate
SQL> startup
select DBID,NAME,DB_UNIQUE_NAME,OPEN_MODE,DATABASE_ROLE from v$database;