Cloning database without RMAN
1. scp all the datafiles from the main server to the remote server
ignore tempfiles and redo logs as they can be created on the new server.
scp all init
Create orapwd file for the new server
Create directory structure on the new server for the new database
2. On the main site issue alter database controlfile to trace;
3. Modify the trace file to point to the new location in the server
4. Create directory structure for udump , bdump , cdump, pfile
5. Startup nomount with init
6. Create the control file
7. Open the database with resetlogs since we created without the redo logs
8. Configure Listener
SCP
First copy the init parameter files to the new location.
cp $ORACLE_HOME/dbs/inittest.ora $ORACLE_HOME/dbs/initnewtest.ora
orapwd file=orapwnewtest password=p entries=20
Create a directory structure for the admin files
such as for udump/bdump and cdump :-
cp -r /u02/app/oracle/admin/test /u02/app/oracle/admin/newtest
Remove all the junk files from the server
$find . -name “*” -exec rm {} \;
On the source database issue the following commands:-
sqlplus /nolog
connect / as sysdba
1. Alter system switch logfile;
2. Alter system switch logfile;
3. Alter system switch logfile;
4. Alter system switch logfile;
5. Alter system checkpoint;
6. Alter system checkpoint;
7. Alter system checkpoint;
8. Alter system checkpoint;
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
Locate your trace file, controlfile trace are always in udump location.
There are two cases of controlfile traces generally written out
one is for resetlogs and the other is for noreset logs.
Since it is a completely new server we will employ the resetlogs case.
**
Make the appropriate changes from “TEST” to “NEWTEST”
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE “NEWTEST” RESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 454
LOGFILE
GROUP 2 ‘/u02/app/oracle/oradata/newtest/redo02.log’ SIZE 10M,
GROUP 3 ‘/u02/app/oracle/oradata/newtest/redo03.log’ SIZE 10M
– STANDBY LOGFILE
DATAFILE
‘/u02/app/oracle/oradata/newtest/system2.dbf’,
‘/u02/app/oracle/oradata/newtest/undotbs01.dbf’,
‘/u02/app/oracle/oradata/newtest/sysaux01.dbf’,
‘/u02/app/oracle/oradata/newtest/users01.dbf’,
‘/u02/app/oracle/oradata/newtest/tools2_02.dbf’,
‘/u02/app/oracle/oradata/newtest/mytools.dbf’,
‘/u02/app/oracle/oradata/newtest/tools2.dbf’,
‘/u02/app/oracle/oradata/newtest/r_tblsp.dbf’
CHARACTER SET WE8ISO8859P1
;
You should get the message controlfile created.
cp -rp inittest.ora initnewtest.ora
Make global replacement for the string test to newtest
export ORACLE_SID=newtest
sqlplus / as sysdba
startup nomount;
Create the control file..
Try opening the database with the resetlogs option
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘/u02/app/oracle/oradata/newtest/system2.dbf’
This message indicates that we have to apply more archive logs to bring
the database to a consistent state.
This means that the datafile are in a fuzzy state. At this point we have to
redo the datafile copy steps.
Remove the destination datafiles altogether:-
rm -rf /u02/app/oracle/oradata/newtest/
At the source site open the database if it is not already open:-
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER SYSTEM CHECKPOINT;
ALTER SYSTEM CHECKPOINT;
ALTER SYSTEM CHECKPOINT;
Now do a back up of datafile to the new location
cp -rp /u02/app/oracle/oradata/test/ /u02/app/oracle/oradata/newtest/
rm -rf /u02/app/oracle/oradata/newtest/control*.ctl
Now recreate the controlfile and open the database using the resetlogs option.
ERRORS:-
ORA-01161: Datafile header does not match with the new name,
to rectify this change REUSE TO SET in the CONTROLFILE.
ORA-00202: controlfile: ‘/u02/app/oracle/oradata/newtest/control01.ctl’
ORA-27038: created file already exists
Solution: Remove the controlfile and recreate the database.
