Hi guys... in this blog I am going to explain you the detailed steps about how to restore a database on New Host using RMAN. You can also use it to move a production database to new host as test database.
Here, we are going to use the source database with the DB_NAME=ORCL and we are going to restore this ORCL database on the test database machine.
Record the DBID for your source database. You can find the DBID
When we start the database in nomount mode we receive error because the parameter file is not found. This is expected because we are restoring to a new host, hence, Oracle will use a “dummy” parameter file to start the instance.
Restore and edit the server parameter file which is in the SP_FILE.BKP. Since SPFILE is a binary file we need to create the file from it and then make the initialization parameter changes.
Now that we have the SPFILE, we need to edit some of the location specific parameters in the initorcl.ora file to reflect the new host's directory structure. Following are the parameters that need to be changed:
Restart the instance with the edited initialization parameter file.Then, restore the control file to whatever locations you specified in the
1. Preparing to restore the database on a new host:
If you use the procedure in this section, then the DBID for the restored database equals the DBID for the original database. Do not register a test database created in this way in the same recovery catalog as the source database. Because the DBID of the two databases is the same, the metadata for the test database can interfere with RMAN's ability to restore and recover the source database.
by connecting to the database with RMAN as shown below:
Take backups of all the datafiles, controlfiles, spfile and archivelog files on the source database machine.
Perform following steps on the source database machine:
Ensure that the initialization parameter file and the backups of datafiles, controlfiles and archivelogs are available on the new host machine for the restore operation. Copy all the backup files from the old host to new host using operating system utility or you can transfer it through pendrive also. If you are using operating system utility then you can perform following step to copy the files from shared folder 'backup' of Neha-pc:
When we restore the database, we are not going to have the active redo logs from the source database, so we will need the last SCN of archivelogs for the restore operation. We can find it by querying V$BACKUP_ARCHIVELOG_DETAILS.
2. Creating the instance for the test machine and creating the pfile by restoring it from spfile:
Perform the following steps on the test database machine:
Use the oradim utility to create the instance for orcl database on the test machine.
CONTROL_FILES
initialization parameter and then mount the database. After that, catalog the datafiles and archivelogs from the FULL_DATAFILES_350.bkp, ARCHIVE_LOG_356.bkp and ARCHIVE_LOG_357.bkp.
Execute the following RMAN restore and recovery script. The script does the following things:
- SET NEWNAME : For each data file on the destination host that is restored to a different path than it had on the source host, use this command to specify the new path on the test machine. If the file systems on the destination system are set up to have the same paths as the source host, then do not use
SET NEWNAME
for those files restored to the same path as on the source host. - ALTER DATABASE RENAME FILE :
ALTER DATABASE RENAME FILE
for those files restored to the same path as on the source host. - SET UNTIL : Perform this
operation to limit recovery to the end of the archived redo logs. The recovery stops with an error if no
SET UNTIL
command is specified. - RESTORE the database.
- SWITCH DATAFILE ALL : Run the
SWITCH DATAFILE ALL
command so that the control file recognizes the new path names as the official new names of the data files. - RECOVER the database.
Following is the output of the restore-script.sql. Execute the following code in RMAN:
From the RMAN prompt, open the database with the
Stay tuned for more contents...
RESETLOGS
option:
If all the above steps are executed properly, then you will have the production database installed on the test machine.Stay tuned for more contents...