Once Oracle Home Copied from Source then clone it using below procedure:
=========================================================================
[oracle@stand dbhome_2]$ export PATH=/u01/app/12c/database/dbhome_2/perl/bin/perl:$PATH
[oracle@stand dbhome_2]$ export ORACLE_HOME=/u01/app/12c/database/dbhome_2
[oracle@stand dbhome_2]$ /usr/bin/perl $ORACLE_HOME/clone/bin/clone.pl '-O"LOCAL_NODE=stand"' ORACLE_BASE=/u01/app/12c/database ORACLE_HOME=/u01/app/12c/database/dbhome_2 ORACLE_HOME_NAME=dbhome_2 '-O-noConfig'
./runInstaller -clone -waitForCompletion "LOCAL_NODE=stand" "ORACLE_BASE=/u01/app/12c/database" "ORACLE_HOME=/u01/app/12c/database/dbhome_2" "ORACLE_HOME_NAME=dbhome_2" -noConfig -silent -paramFile /u01/app/12c/database/dbhome_2/clone/clone_oraparam.ini
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 26774 MB Passed
Checking swap space: must be greater than 500 MB. Actual 3995 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-10-20_01-07-07PM. Please wait ...You can find the log of this install session at:
/u01/app/oraInventory/logs/cloneActions2016-10-20_01-07-07PM.log
.................................................. 5% Done.
.................................................. 10% Done.
.................................................. 15% Done.
.................................................. 20% Done.
.................................................. 25% Done.
.................................................. 30% Done.
.................................................. 35% Done.
.................................................. 40% Done.
.................................................. 45% Done.
.................................................. 50% Done.
.................................................. 55% Done.
.................................................. 60% Done.
.................................................. 65% Done.
.................................................. 70% Done.
.................................................. 75% Done.
.................................................. 80% Done.
.................................................. 85% Done.
..........
Copy files in progress.
Copy files successful.
Link binaries in progress.
Link binaries successful.
Setup files in progress.
Setup files successful.
Setup Inventory in progress.
Setup Inventory successful.
Finish Setup successful.
The cloning of dbhome_2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2016-10-20_01-07-07PM.log' for more details.
Setup Oracle Base in progress.
Setup Oracle Base successful.
.................................................. 95% Done.
As a root user, execute the following script(s):
1. /u01/app/12c/database/dbhome_2/root.sh
.................................................. 100% Done.
Change the Environment file:
=============================
[oracle@stand ~]$ vi test.env
[oracle@stand ~]$ cat test.env
export ORACLE_SID=prim >>>> Kept as Source database
export ORACLE_HOME=/u01/app/12c/database/dbhome_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:/opt/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
[oracle@stand ~]$ . ./test.env
[oracle@stand ~]$ cd $ORACLE_HOME/dbs
[oracle@stand dbs]$ ls -ltr
total 80
-rw-r----- 1 oracle oinstall 4608 Oct 18 16:57 spfilestand.ora
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand_bad
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkSTAND
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkPRIM
-rw-r----- 1 oracle oinstall 0 Oct 18 16:57 lkinststand
-rw-r--r-- 1 oracle oinstall 16 Oct 18 16:57 initstand.ora
-rw-r--r-- 1 oracle oinstall 2992 Oct 18 16:57 init.ora
-rw-r----- 1 oracle oinstall 1544 Oct 18 16:57 hc_stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr2stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr1stand.dat
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 13:16 initPRIM_20OCT >>> Copied from Source
-rw-r----- 1 oracle oinstall 7680 Oct 20 13:16 orapwprim >>> Copied from Source
Nomount the Target:
===================
[oracle@stand dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 13:17:27 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='initPRIM_20OCT';
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
SQL> exit
RMAN backup pieces copied from Source to below target location:
===============================================================
[oracle@stand dbs]$ cd /u01/app/12c/database/fast_recovery_area/PRIM/backupset/
[oracle@stand backupset]$ cd 2016_10_18/
[oracle@stand 2016_10_18]$ ls -ltr
total 1492464
-rw-r----- 1 oracle oinstall 212480 Oct 20 12:45 o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp
-rw-r----- 1 oracle oinstall 1273954304 Oct 20 12:49 o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp
-rw-r----- 1 oracle oinstall 16028992 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp
-rw-r----- 1 oracle oinstall 25372672 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7flh5_.bkp
-rw-r----- 1 oracle oinstall 73538560 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7ds25_.bkp
-rw-r----- 1 oracle oinstall 11042816 Oct 20 12:49 o1_mf_ncsnf_TAG20161018T164053_gtm7kbb6_.bkp
-rw-r----- 1 oracle oinstall 123593728 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm79s7s_.bkp
Restore control file from backup and mount the TARGET also catalog backup pieces:
=================================================================================
[oracle@stand oradata]$ mkdir -p /u01/app/12c/database/oradata/prim
[oracle@stand oradata]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sun Oct 20 13:21:22 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (not mounted)
RMAN> restore controlfile from '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_ncsnf_TAG20161018T164053_gtm7kbb6_.bkp';
Starting restore at 20-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/12c/database/oradata/prim/control01.ctl
output file name=/u01/app/12c/database/fast_recovery_area/prim/control02.ctl
Finished restore at 20-OCT-16
RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp';
using target database control file instead of recovery catalog
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp RECID=8 STAMP=1022161606
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp';
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp RECID=9 STAMP=1022161633
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp';
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp RECID=10 STAMP=1022161645
....
.........
Catalog all the pieces.
[oracle@stand prim]$ mkdir -p /u01/app/12c/database/datafiles/prim
[oracle@stand prim]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sun Oct 20 13:53:36 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (DBID=16077478, not open)
RMAN> run
{
set newname for datafile 1 to '/u01/app/12c/database/datafiles/prim/system01.dbf';
set newname for datafile 3 to '/u01/app/12c/database/datafiles/prim/sysaux01.dbf';
set newname for datafile 6 to '/u01/app/12c/database/datafiles/prim/users01.dbf';
set newname for datafile 4 to '/u01/app/12c/database/datafiles/prim/undotbs01.dbf';
restore database;
switch datafile all;
}2> 3> 4> 5> 6> 7> 8> 9>
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 20-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/12c/database/datafiles/prim/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/12c/database/datafiles/prim/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/12c/database/datafiles/prim/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/12c/database/datafiles/prim/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp
channel ORA_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp tag=TAG20161018T164053
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 20-OCT-16
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/users01.dbf
RMAN> recover database;
Starting recover at 20-OCT-16
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp
channel ORA_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp tag=TAG20161018T164244
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/12c/database/fast_recovery_area/PRIM/archivelog/2016_10_20/o1_mf_1_4_gtr6ood5_.arc thread=1 sequence=4
media recovery complete, elapsed time: 00:00:26
Finished recover at 20-OCT-16
Open reset logs:
================
SQL> alter database open resetlogs;
Database altered.
Check redolog/temp files and recreate those:
==========================================
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/12c/database/oradata/prim/redo03.log
/u01/app/12c/database/oradata/prim/redo02.log
/u01/app/12c/database/oradata/prim/redo01.log
/u01/app/12c/database/oradata/prim/redo04.log
/u01/app/12c/database/oradata/prim/redo05.log
/u01/app/12c/database/oradata/prim/redo06.log
6 rows selected.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/12c/database/oradata/prim/temp01.dbf
SQL> create temporary tablespace temp1 tempfile '/u01/app/12c/database/oradata/prim/temp.dbf' size 50m;
Tablespace created.
SQL> alter database default temporary tablespace temp1;
Database altered.
SQL> drop tablespace temp including contents and datafiles;
Tablespace dropped.
SQL> create temporary tablespace temp tempfile '/u01/app/12c/database/datafiles/prim/temp.dbf' size 50m;
Tablespace created.
SQL> alter database default temporary tablespace temp;
Database altered.
SQL> drop tablespace temp1 including contents and datafiles;
Tablespace dropped.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/12c/database/datafiles/prim/temp.dbf
SQL> alter database drop logfile '/u01/app/12c/database/oradata/prim/redo01.log';
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 1 '/u01/app/12c/database/datafiles/prim/redo01.log' size 50m;
Database altered.
SQL> select GROUP#,TYPE,MEMBER from v$logfile;
GROUP# TYPE MEMBER
---------- ------- --------------------------------------------------
3 ONLINE /u01/app/12c/database/datafiles/prim/redo03.log
2 ONLINE /u01/app/12c/database/datafiles/prim/redo02.log
1 ONLINE /u01/app/12c/database/datafiles/prim/redo01.log
Now change the name using NID:
==============================
SQL> select name from v$database;
NAME
---------
PRIM
SQL> create spfile from pfile='initTEST.ora';
File created.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
Database mounted.
SQL> exit
[oracle@stand admin]$ nid target=sys/oracle@PRIM DBNAME=TEST
DBNEWID: Release 12.1.0.2.0 - Production on Sun Oct 20 14:28:54 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to database PRIM (DBID=16077478)
Connected to server version 12.1.0
Control Files in database:
/u01/app/12c/database/oradata/prim/control01.ctl
/u01/app/12c/database/fast_recovery_area/prim/control02.ctl
Change database ID and database name PRIM to TEST? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 16077478 to 2320251431
Changing database name from PRIM to TEST
Control File /u01/app/12c/database/oradata/prim/control01.ctl - modified
Control File /u01/app/12c/database/fast_recovery_area/prim/control02.ctl - modified
Datafile /u01/app/12c/database/datafiles/prim/system01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/users01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/temp.db - dbid changed, wrote new name
Control File /u01/app/12c/database/oradata/prim/control01.ctl - dbid changed, wrote new name
Control File /u01/app/12c/database/fast_recovery_area/prim/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST changed to 2320251431.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
[oracle@stand admin]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 14:29:56 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@stand admin]$ cd $ORACLE_HOME
[oracle@stand dbhome_2]$ cd dbs
[oracle@stand dbs]$ ls -ltr
total 96
-rw-r----- 1 oracle oinstall 4608 Oct 18 16:57 spfilestand.ora
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand_bad
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkSTAND
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkPRIM
-rw-r----- 1 oracle oinstall 0 Oct 18 16:57 lkinststand
-rw-r--r-- 1 oracle oinstall 16 Oct 18 16:57 initstand.ora
-rw-r--r-- 1 oracle oinstall 2992 Oct 18 16:57 init.ora
-rw-r----- 1 oracle oinstall 1544 Oct 18 16:57 hc_stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr2stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr1stand.dat
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 13:16 initPRIM_20OCT
-rw-r----- 1 oracle oinstall 7680 Oct 20 13:16 orapwprim
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 14:16 initTEST.ora
-rw-r----- 1 oracle oinstall 4608 Oct 20 14:23 spfileprim.ora
-rw-rw---- 1 oracle oinstall 1544 Oct 20 14:29 hc_prim.dat
[oracle@stand dbs]$ vi initTEST.ora
[oracle@stand dbs]$ cd
[oracle@stand ~]$ vi test.env >>> modify instance_name to test
[oracle@stand ~]$ . ./test.env
[oracle@stand ~]$ cd $ORACLE_HOME/dbs
[oracle@stand dbs]$ cp initTEST.ora inittest.ora >>> Here modify db name to test
[oracle@stand dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 14:37:32 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
SQL> alter database mount;
Database altered.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string test
SQL> alter database open resetlogs;
Database altered.
SQL> create spfile from pfile='inittest.ora'
2 ;
File created.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string test
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
TEST READ WRITE
Thanks
=========================================================================
[oracle@stand dbhome_2]$ export PATH=/u01/app/12c/database/dbhome_2/perl/bin/perl:$PATH
[oracle@stand dbhome_2]$ export ORACLE_HOME=/u01/app/12c/database/dbhome_2
[oracle@stand dbhome_2]$ /usr/bin/perl $ORACLE_HOME/clone/bin/clone.pl '-O"LOCAL_NODE=stand"' ORACLE_BASE=/u01/app/12c/database ORACLE_HOME=/u01/app/12c/database/dbhome_2 ORACLE_HOME_NAME=dbhome_2 '-O-noConfig'
./runInstaller -clone -waitForCompletion "LOCAL_NODE=stand" "ORACLE_BASE=/u01/app/12c/database" "ORACLE_HOME=/u01/app/12c/database/dbhome_2" "ORACLE_HOME_NAME=dbhome_2" -noConfig -silent -paramFile /u01/app/12c/database/dbhome_2/clone/clone_oraparam.ini
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 26774 MB Passed
Checking swap space: must be greater than 500 MB. Actual 3995 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-10-20_01-07-07PM. Please wait ...You can find the log of this install session at:
/u01/app/oraInventory/logs/cloneActions2016-10-20_01-07-07PM.log
.................................................. 5% Done.
.................................................. 10% Done.
.................................................. 15% Done.
.................................................. 20% Done.
.................................................. 25% Done.
.................................................. 30% Done.
.................................................. 35% Done.
.................................................. 40% Done.
.................................................. 45% Done.
.................................................. 50% Done.
.................................................. 55% Done.
.................................................. 60% Done.
.................................................. 65% Done.
.................................................. 70% Done.
.................................................. 75% Done.
.................................................. 80% Done.
.................................................. 85% Done.
..........
Copy files in progress.
Copy files successful.
Link binaries in progress.
Link binaries successful.
Setup files in progress.
Setup files successful.
Setup Inventory in progress.
Setup Inventory successful.
Finish Setup successful.
The cloning of dbhome_2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2016-10-20_01-07-07PM.log' for more details.
Setup Oracle Base in progress.
Setup Oracle Base successful.
.................................................. 95% Done.
As a root user, execute the following script(s):
1. /u01/app/12c/database/dbhome_2/root.sh
.................................................. 100% Done.
Change the Environment file:
=============================
[oracle@stand ~]$ vi test.env
[oracle@stand ~]$ cat test.env
export ORACLE_SID=prim >>>> Kept as Source database
export ORACLE_HOME=/u01/app/12c/database/dbhome_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:/opt/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
[oracle@stand ~]$ . ./test.env
[oracle@stand ~]$ cd $ORACLE_HOME/dbs
[oracle@stand dbs]$ ls -ltr
total 80
-rw-r----- 1 oracle oinstall 4608 Oct 18 16:57 spfilestand.ora
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand_bad
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkSTAND
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkPRIM
-rw-r----- 1 oracle oinstall 0 Oct 18 16:57 lkinststand
-rw-r--r-- 1 oracle oinstall 16 Oct 18 16:57 initstand.ora
-rw-r--r-- 1 oracle oinstall 2992 Oct 18 16:57 init.ora
-rw-r----- 1 oracle oinstall 1544 Oct 18 16:57 hc_stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr2stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr1stand.dat
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 13:16 initPRIM_20OCT >>> Copied from Source
-rw-r----- 1 oracle oinstall 7680 Oct 20 13:16 orapwprim >>> Copied from Source
Nomount the Target:
===================
[oracle@stand dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 13:17:27 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='initPRIM_20OCT';
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
SQL> exit
RMAN backup pieces copied from Source to below target location:
===============================================================
[oracle@stand dbs]$ cd /u01/app/12c/database/fast_recovery_area/PRIM/backupset/
[oracle@stand backupset]$ cd 2016_10_18/
[oracle@stand 2016_10_18]$ ls -ltr
total 1492464
-rw-r----- 1 oracle oinstall 212480 Oct 20 12:45 o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp
-rw-r----- 1 oracle oinstall 1273954304 Oct 20 12:49 o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp
-rw-r----- 1 oracle oinstall 16028992 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp
-rw-r----- 1 oracle oinstall 25372672 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7flh5_.bkp
-rw-r----- 1 oracle oinstall 73538560 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm7ds25_.bkp
-rw-r----- 1 oracle oinstall 11042816 Oct 20 12:49 o1_mf_ncsnf_TAG20161018T164053_gtm7kbb6_.bkp
-rw-r----- 1 oracle oinstall 123593728 Oct 20 12:49 o1_mf_annnn_TAG20161018T163837_gtm79s7s_.bkp
Restore control file from backup and mount the TARGET also catalog backup pieces:
=================================================================================
[oracle@stand oradata]$ mkdir -p /u01/app/12c/database/oradata/prim
[oracle@stand oradata]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sun Oct 20 13:21:22 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (not mounted)
RMAN> restore controlfile from '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_ncsnf_TAG20161018T164053_gtm7kbb6_.bkp';
Starting restore at 20-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/12c/database/oradata/prim/control01.ctl
output file name=/u01/app/12c/database/fast_recovery_area/prim/control02.ctl
Finished restore at 20-OCT-16
RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp';
using target database control file instead of recovery catalog
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp RECID=8 STAMP=1022161606
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp';
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp RECID=9 STAMP=1022161633
RMAN> catalog backuppiece '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp';
cataloged backup piece
backup piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T163837_gtm7fook_.bkp RECID=10 STAMP=1022161645
....
.........
Catalog all the pieces.
[oracle@stand prim]$ mkdir -p /u01/app/12c/database/datafiles/prim
[oracle@stand prim]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sun Oct 20 13:53:36 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIM (DBID=16077478, not open)
RMAN> run
{
set newname for datafile 1 to '/u01/app/12c/database/datafiles/prim/system01.dbf';
set newname for datafile 3 to '/u01/app/12c/database/datafiles/prim/sysaux01.dbf';
set newname for datafile 6 to '/u01/app/12c/database/datafiles/prim/users01.dbf';
set newname for datafile 4 to '/u01/app/12c/database/datafiles/prim/undotbs01.dbf';
restore database;
switch datafile all;
}2> 3> 4> 5> 6> 7> 8> 9>
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 20-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/12c/database/datafiles/prim/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/12c/database/datafiles/prim/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/12c/database/datafiles/prim/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/12c/database/datafiles/prim/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp
channel ORA_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp tag=TAG20161018T164053
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 20-OCT-16
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=1022162108 file name=/u01/app/12c/database/datafiles/prim/users01.dbf
RMAN> recover database;
Starting recover at 20-OCT-16
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp
channel ORA_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp tag=TAG20161018T164244
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/12c/database/fast_recovery_area/PRIM/archivelog/2016_10_20/o1_mf_1_4_gtr6ood5_.arc thread=1 sequence=4
media recovery complete, elapsed time: 00:00:26
Finished recover at 20-OCT-16
Open reset logs:
================
SQL> alter database open resetlogs;
Database altered.
Check redolog/temp files and recreate those:
==========================================
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/12c/database/oradata/prim/redo03.log
/u01/app/12c/database/oradata/prim/redo02.log
/u01/app/12c/database/oradata/prim/redo01.log
/u01/app/12c/database/oradata/prim/redo04.log
/u01/app/12c/database/oradata/prim/redo05.log
/u01/app/12c/database/oradata/prim/redo06.log
6 rows selected.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/12c/database/oradata/prim/temp01.dbf
SQL> create temporary tablespace temp1 tempfile '/u01/app/12c/database/oradata/prim/temp.dbf' size 50m;
Tablespace created.
SQL> alter database default temporary tablespace temp1;
Database altered.
SQL> drop tablespace temp including contents and datafiles;
Tablespace dropped.
SQL> create temporary tablespace temp tempfile '/u01/app/12c/database/datafiles/prim/temp.dbf' size 50m;
Tablespace created.
SQL> alter database default temporary tablespace temp;
Database altered.
SQL> drop tablespace temp1 including contents and datafiles;
Tablespace dropped.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/12c/database/datafiles/prim/temp.dbf
SQL> alter database drop logfile '/u01/app/12c/database/oradata/prim/redo01.log';
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 1 '/u01/app/12c/database/datafiles/prim/redo01.log' size 50m;
Database altered.
SQL> select GROUP#,TYPE,MEMBER from v$logfile;
GROUP# TYPE MEMBER
---------- ------- --------------------------------------------------
3 ONLINE /u01/app/12c/database/datafiles/prim/redo03.log
2 ONLINE /u01/app/12c/database/datafiles/prim/redo02.log
1 ONLINE /u01/app/12c/database/datafiles/prim/redo01.log
Now change the name using NID:
==============================
SQL> select name from v$database;
NAME
---------
PRIM
SQL> create spfile from pfile='initTEST.ora';
File created.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
Database mounted.
SQL> exit
[oracle@stand admin]$ nid target=sys/oracle@PRIM DBNAME=TEST
DBNEWID: Release 12.1.0.2.0 - Production on Sun Oct 20 14:28:54 2016
Copyright (c) 1682, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to database PRIM (DBID=16077478)
Connected to server version 12.1.0
Control Files in database:
/u01/app/12c/database/oradata/prim/control01.ctl
/u01/app/12c/database/fast_recovery_area/prim/control02.ctl
Change database ID and database name PRIM to TEST? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 16077478 to 2320251431
Changing database name from PRIM to TEST
Control File /u01/app/12c/database/oradata/prim/control01.ctl - modified
Control File /u01/app/12c/database/fast_recovery_area/prim/control02.ctl - modified
Datafile /u01/app/12c/database/datafiles/prim/system01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/users01.db - dbid changed, wrote new name
Datafile /u01/app/12c/database/datafiles/prim/temp.db - dbid changed, wrote new name
Control File /u01/app/12c/database/oradata/prim/control01.ctl - dbid changed, wrote new name
Control File /u01/app/12c/database/fast_recovery_area/prim/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST changed to 2320251431.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
[oracle@stand admin]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 14:29:56 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@stand admin]$ cd $ORACLE_HOME
[oracle@stand dbhome_2]$ cd dbs
[oracle@stand dbs]$ ls -ltr
total 96
-rw-r----- 1 oracle oinstall 4608 Oct 18 16:57 spfilestand.ora
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand_bad
-rw-r----- 1 oracle oinstall 7680 Oct 18 16:57 orapwstand
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkSTAND
-rw-r----- 1 oracle oinstall 24 Oct 18 16:57 lkPRIM
-rw-r----- 1 oracle oinstall 0 Oct 18 16:57 lkinststand
-rw-r--r-- 1 oracle oinstall 16 Oct 18 16:57 initstand.ora
-rw-r--r-- 1 oracle oinstall 2992 Oct 18 16:57 init.ora
-rw-r----- 1 oracle oinstall 1544 Oct 18 16:57 hc_stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr2stand.dat
-rw-r----- 1 oracle oinstall 12288 Oct 18 16:57 dr1stand.dat
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 13:16 initPRIM_20OCT
-rw-r----- 1 oracle oinstall 7680 Oct 20 13:16 orapwprim
-rw-r--r-- 1 oracle oinstall 1852 Oct 20 14:16 initTEST.ora
-rw-r----- 1 oracle oinstall 4608 Oct 20 14:23 spfileprim.ora
-rw-rw---- 1 oracle oinstall 1544 Oct 20 14:29 hc_prim.dat
[oracle@stand dbs]$ vi initTEST.ora
[oracle@stand dbs]$ cd
[oracle@stand ~]$ vi test.env >>> modify instance_name to test
[oracle@stand ~]$ . ./test.env
[oracle@stand ~]$ cd $ORACLE_HOME/dbs
[oracle@stand dbs]$ cp initTEST.ora inittest.ora >>> Here modify db name to test
[oracle@stand dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Sun Oct 20 14:37:32 2016
Copyright (c) 1682, 2014, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
SQL> alter database mount;
Database altered.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string test
SQL> alter database open resetlogs;
Database altered.
SQL> create spfile from pfile='inittest.ora'
2 ;
File created.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 780140544 bytes
Fixed Size 2929256 bytes
Variable Size 578817432 bytes
Database Buffers 162937984 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string test
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
TEST READ WRITE
Thanks
No comments:
Post a Comment