Home » Restoring an Oracle Database on a New Server

Restoring an Oracle Database on a New Server

by tuanlp

 ðŸ’¡ In this article I am going to give you the steps of restoring an oracle DB on a new server:

Step 1: Install the Oracle Software on the new server (do not create any database).

Step 2: If you are using Windows OS, create a new instance on the new server and start it by executing the below commands in command prompt. Please note: the DB name should be the same as the source’s one. This step is not required to be done on Linux OS

set ORACLE_SID=orcl
oradim –new -sid orcl
net start OracleService<db_name>

Step 3: Copy the Password file from source server to the new server into the same directory:

- on Linux: $ORACLE_HOME/dbs/orapwd*<db_name>*
- on Windows: %ORACLE_HOME/database/PWD*<db_name>*

Step4: Connect to the source database and create a PFile from the SPFile

set ORACLE_SID=<db_name>
sqlplus / as sysdba
sql> create pfile from spfile;

Step 5: Copy the PFile from the source server to the new server in the same directory ($ORACLE_HOME/dbs on Linux and %ORACLE_HOME/database on Windows) and edit the required parameters (such as the path of control files, dump files, memory parameters and etc.). You can create your own PFile having the basic parameters; but note that the DB name should be the same as the source DB name.

Step 6: Start the new database in NOMOUNT mode using the new PFile, create an spfile from the pfile and then restart the db in NOMOUNT mode:

set ORACLE_SID=<db_name>
sqlplus / as sysdba
sql> startup nomount pfile='<pfile_name>';
sql> create spfile from pfile='<pfile_name>';
sql> startup force nomount;

Step 7: Create a backup from control file of the source DB and then restore it on the new server:

set ORACLE_SID=<db_name>
rman target /
rman> backup as copy current controlfile format '<path and name of the backup file>'
copy the backup file into the new server
connect to the new DB and restore the control file:
rman> restore controlfile from '<path and name of the backup control file>';
rman> alter database mount;

Step 8: If the oracle directories on the new server are different with the source one, then rename the online redo log files on the new server by using the below command, otherwise this is not required.

sql> alter database rename file '<path and name of the old redo log file>' to '<path and new of the new redo log file>';

Step 9: Take a backup of the source DB files and then copy them into the new server:

set ORACLE_SID=<db_name>
rman target /
rman> sql "alter system switch logfile";
rman> sql "alter system checkpoint";
rman> sql "alter system archive log current";
rman> run{
              allocate channel c1 device type disk format '<path of the backup files>/%d_%T_%s_%p';

              backup databse plus archivelog;

           }

Step 10: Restore the files on the new server and then open the DB.

set ORACLE_SID=<db_name>
rman target /
rman> catalog start with '<the directory path, which includes the backup files>';
rman> restore database;
rman> recover database;
in this step you may get an error, which tells you recover the db until sequence n1 thread n2, so execute the below commands to fix this problem:
rman> run{
           set until sequence n1 thread n2;

            recover database;

         }

alter database open resetlogs;

Please note: if the directories (path of the oracle files) on the new server are different with the source server’s one, before restoring the data files, use the below command to rename them:

sqL> alter database rename file '<path and name of the file'> to 'path and name of the new file'>

Now you can use the new database.

You may also like