Clone the Oracle Database to new host, without RMAN
This is a follow up on my article on cloning the Oracle Database binaries
The steps are as follow:
- Find all required files
- Shutdown the database
- Create same folder structure as on source
- Copy all files to the target location
- Set Environment variables for the database
- Startup the database on the target host
Scenario in this case is as follow: Source host name:PRODB01
Target host name:PRODB02
Database namae prodb01
Target host name:PRODB02
Database namae prodb01
Video of clone in action:
Find all required files
To find the location of the datafile, redofiles and logfiles you can run the following:
1
2
3
| select name from v$datafile; select name from v$controlfile; select member from v$logfile; |
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| SQL> select name from v$datafile; select name from v$controlfile; select member from v$logfile; NAME -------------------------------------------------------------------------------- /oradata/prodb01/system01.dbf /oradata/prodb01/sysaux01.dbf /oradata/prodb01/undotbs01.dbf /oradata/prodb01/users01.dbf SQL> NAME -------------------------------------------------------------------------------- /oradata/prodb01/control01.ctl /oradata/prodb01/control02.ctl SQL> MEMBER -------------------------------------------------------------------------------- /oradata/prodb01/redo03.log /oradata/prodb01/redo02.log /oradata/prodb01/redo01.log |
So this are the files we need to move
Remember if you have archivelogs, these need to be moved as well!
Find spfile, init file and password file
Find the location of spfile or init file and password file that needs to be copied to new server. These files are present in $ORACLE_HOME/dbs folder:
1
2
3
4
5
6
7
8
| oracle@prodb01:~$ cd $ORACLE_HOME /dbs oracle@prodb01: /oracle/app/oracle/product/11 .2.0 /dbhome_1/dbs $ ls -l * -rw-rw---- 1 oracle oinstall 1544 Nov 14 15:03 hc_DBUA0038464.dat -rw-rw---- 1 oracle oinstall 1544 Nov 19 02:00 hc_prodb01.dat -rw-r--r-- 1 oracle oinstall 2851 May 15 2009 init.ora -rw-r----- 1 oracle oinstall 24 Nov 17 22:53 lkPRODB01 -rw-r----- 1 oracle oinstall 1536 Nov 17 22:55 orapwprodb01 -rw-r----- 1 oracle oinstall 2560 Nov 18 12:23 spfileprodb01.ora |
Shutdown the database
1
| SQL> shutdown immediate |
Create same folder structure as on source
According to previously commands we create the same folder structure as step 1
/oradata/prodb01
on the target host (prodb02 in this case):
1
| oracle@prodb02:~$ mkdir -p /oradata/prdb01 |
We also need to create some administrative folders on the target for trace files, audit files etc
The trace files are located in the
user_dump_dest
1
2
3
4
5
6
| SQL> show parameter user_dump NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ user_dump_dest string /oracle/app/oracle/diag/rdbms/ prodb01/prodb01/trace |
So we have to create this folder:
1
| oracle@prodb02:~$ mkdir -p /oracle/app/oracle/diag/rdbms/prodb01/prodb01/trace |
in 11g we also have to create the adump folder for sysdba login auditing located under $ORACLE_BASE:
1
| oracle@prodb02:~$ mkdir -p /oracle/app/oracle/admin/prodb01/adump |
For Oracle 10g:
If you are doing this on 10g then you need to create the following:
If you are doing this on 10g then you need to create the following:
mkdir adump bdump cdump dpdump pfile udump
under the folder
/oracle/app/oracle/admin/prodb01
.Copy all files to the target location
In this case all datafile, controlfile and logfiles are all in the same location, that is very convenient right now, but it’s really bad practice in a production system.
From the target host we can now:
1
2
3
4
| oracle@prodb02:~$ cd /oradata/prodb01/ oracle@prodb02: /oradata/prodb01 $ rsync -avz -e ssh oracle@prodb01: /oradata/prodb01/ . oracle@prodb02: /oradata/prodb01 $ scp oracle@prodb01: /oracle/app/oracle/product/11 .2.0 /dbhome_1/dbs/orapwprodb01 /oracle/app/oracle/product/11 .2.0 /dbhome_1/dbs/orapwprodb01 oracle@prodb02: /oradata/prodb01 $ scp oracle@prodb01: /oracle/app/oracle/product/11 .2.0 /dbhome_1/dbs/spfileprodb01 .ora /oracle/app/oracle/product/11 .2.0 /dbhome_1/dbs/spfileprodb01 .ora |
Set Environment variables for the database
Set the ORACLE_HOME, ORACLE_SID and update the PATH
1
2
3
| oracle@prodb02: /oradata/prodb01 $ export ORACLE_HOME= /oracle/app/oracle/product/11 .2.0 /dbhome_1 oracle@prodb02: /oradata/prodb01 $ export ORACLE_SID=prodb01 oracle@prodb02: /oradata/prodb01 $ export PATH=$ORACLE_HOME /bin :$PATH |
Startup the database on the target host
Only startup and verify everything left:
1
2
3
4
5
6
7
8
9
10
11
12
13
| oracle@prodb02: /oradata/prodb01 $ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Nov 19 12:52:18 2014 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup ORACLE instance started. Total System Global Area 3206836224 bytes Fixed Size 2255144 bytes Variable Size 1811941080 bytes Database Buffers 1375731712 bytes Redo Buffers 16908288 bytes Database mounted. Database opened. |
Then to be sure it is the correct database we can check the DB Name by:
1
2
3
4
5
| SQL> select name from v$ database ; NAME --------- PRODB01 |
All done!
No comments:
Post a Comment