Skip to content
Home » Oracle » How to Clone Oracle Home

How to Clone Oracle Home

Cloning Database Home

Cloning an Oracle database home to another place by clone.pl might be more complicated than you thought, especially in a RAC environment.

Although it still works in 19c, clone.pl is deprecated and might be removed in the future. Oracle recommends that we should perform a software-only installation to the new home instead.

In this post, we introduce the formal way to clone a database home to another place in a single-instance database and a RAC database.

  1. Single-Instance DB
  2. RAC Database

Please note that, we didn't clone or move ORACLE_BASE in this case.

Single-Instance DB

We take the following steps to clone an Oracle home to another directory.

  1. Shutdown Database
  2. Copy Home Files
  3. Update ORACLE_HOME
  4. Run clone.pl
  5. Run root.sh
  6. Update /etc/oratab
  7. Startup Database
  8. Test Connection

Here are steps:

1. Shutdown Database

Before copying anything to the new location, we have to make sure all Oracle services are stop. Here we shutdown the database by dbshut

[oracle@test ~]$ dbshut $ORACLE_HOME
Processing Database instance "ORCLCDB": log file /u01/app/oracle/product/19.3.0/db_1/rdbms/log/shutdown.log

2. Copy Home Files

In this case, we copy the original Oracle home to the new home /oracle/product/19.3.0/db_1.

[root@test ~]# mkdir -p /oracle/product/19.3.0/db_1
[root@test ~]# chown -R oracle:oinstall /oracle
[root@test ~]# cp -rp /u01/app/oracle/product/19.3.0/db_1 /oracle/product/19.3.0/
[root@test ~]# echo $?
0

3. Update ORACLE_HOME

Since we have copied the new home, we should update the environment variable ORACLE_HOME.

[oracle@test ~]$ vi ~/.bash_profile
...
ORACLE_HOME=/oracle/product/19.3.0/db_1
[oracle@test ~]$ . ~/.bash_profile
[oracle@test ~]$ echo $ORACLE_HOME
/oracle/product/19.3.0/db_1

4. Run clone.pl

Next, we execute a perl executable file, clone.pl to automatically configure the new home for ourselves. In the command, ORACLE_HOME points to the new path, whereas ORACLE_BASE remains unchanged.

[oracle@test ~]$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_HOME_NAME="OraDB19Home2" ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/oracle/product/19.3.0/db_1"


[INFO] [INS-32183] Use of clone.pl is deprecated in this release. Clone operation is equivalent to performing a Software Only installation from the image.
You must use /oracle/product/19.3.0/db_1/runInstaller script available to perform the Software Only install. For more details on image based installation, refer to help documentation.

Starting Oracle Universal Installer...

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2022-11-11_10-24-13PM.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 OraDB19Home2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2022-11-11_10-24-13PM.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. /oracle/product/19.3.0/db_1/root.sh



..................................................   100% Done.

In the command, ORACLE_HOME_NAME is optional. You can ignore it if you don't care the new home name.

5. Run root.sh

We followed the instruction to run root.sh.

[root@test ~]# /oracle/product/19.3.0/db_1/root.sh
Check /oracle/product/19.3.0/db_1/install/root_ora19c1.example.com_2022-11-11_23-05-22-968505112.log for the output of root script

Let's see what we have in the inventory.

[oracle@ora19c1 ~]$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
...
<HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.3.0/db_1" TYPE="O" IDX="1"/>
<HOME NAME="OraDB19Home2" LOC="/oracle/product/19.3.0/db_1" TYPE="O" IDX="2"/>

Now we have another home for databases.

6. Update /etc/oratab

Since we have switched ORACLE_HOME to the new location, we start to use new home from updating /etc/oratab.

[oracle@test ~]$ vi /etc/oratab
ORCLCDB:/oracle/product/19.3.0/dbhome_1:Y

7. Startup Database

Next, we startup the database by dbstart.

[oracle@test ~]$ dbstart $ORACLE_HOME
Processing Database instance "ORCLCDB": log file /oracle/product/19.3.0/db_1/rdbms/log/startup.log

8. Test Connection

We test the connection by sqlplus.

C:\Users\scott>sqlplus system/password@orclcdb
...
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

SQL>

The new home is working now.

RAC DB

We take the following steps to clone an Oracle home to another directory for a RAC database.

  1. Shutdown Database
  2. Copy Home Files
  3. Update ORACLE_HOME
  4. Run clone.pl
  5. Run root.sh
  6. srvctl modify database
  7. Startup Database
  8. Test Connection

Here are steps:

1. Shutdown Database

Before copying anything to the new location, we have to make sure the database services are stop. Here we shutdown the database by srvctl

[oracle@primary01 ~]$ srvctl stop database -d orclcdb
[oracle@primary01 ~]$ srvctl status database -d orclcdb
Instance ORCLCDB1 is not running on node primary01
Instance ORCLCDB2 is not running on node primary02

2. Copy Home Files

We should copy the original database home to the new place on all nodes of the cluster by root.

Node 1

[root@primary01 ~]# mkdir -p /oracle/product/19.3.0/db_1
[root@primary01 ~]# chown -R oracle:oinstall /oracle
[root@primary01 ~]# cp -rp /u01/app/oracle/product/19.3.0/db_1 /oracle/product/19.3.0/

Node 2

[root@primary02 ~]# mkdir -p /oracle/product/19.3.0/db_1
[root@primary02 ~]# chown -R oracle:oinstall /oracle
[root@primary02 ~]# cp -rp /u01/app/oracle/product/19.3.0/db_1 /oracle/product/19.3.0/

3. Update ORACLE_HOME

We update the environment variable ORACLE_HOME with the new location on all nodes.

Node 1

[oracle@primary01 ~]$ vi ~/.bash_profile
...
ORACLE_HOME=/oracle/product/19.3.0/db_1
[oracle@primary01 ~]$ . ~/.bash_profile
[oracle@primary01 ~]$ echo $ORACLE_HOME

Node 2

[oracle@primary02 ~]$ vi ~/.bash_profile
...
ORACLE_HOME=/oracle/product/19.3.0/db_1
[oracle@primary02 ~]$ . ~/.bash_profile
[oracle@primary02 ~]$ echo $ORACLE_HOME

4. Run clone.pl

Next, we execute clone.pl to automatically configure the new home for ourselves. In the command, ORACLE_HOME points to the new path, whereas ORACLE_BASE remains unchanged.

Node 1

[oracle@primary01 ~]$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_HOME_NAME="OraDB19Home2" ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/oracle/product/19.3.0/db_1" CLUSTER_NODES="{primary01,primary02}" LOCAL_NODE=primary01


[INFO] [INS-32183] Use of clone.pl is deprecated in this release. Clone operation is equivalent to performing a Software Only installation from the image.
You must use /oracle/product/19.3.0/db_1/runInstaller script available to perform the Software Only install. For more details on image based installation, refer to help documentation.

Starting Oracle Universal Installer...

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2022-11-14_01-36-08AM.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 OraDB19Home2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2022-11-14_01-36-08AM.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. /oracle/product/19.3.0/db_1/root.sh

Execute /oracle/product/19.3.0/db_1/root.sh on the following nodes:
[primary01]


..................................................   100% Done.

In the command, ORACLE_HOME_NAME is optional. You can ignore it if you don't care the new home name.

Node 2

[oracle@primary02 ~]$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_HOME_NAME="OraDB19Home2" ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/oracle/product/19.3.0/db_1" CLUSTER_NODES="{primary01,primary02}" LOCAL_NODE=primary02


[INFO] [INS-32183] Use of clone.pl is deprecated in this release. Clone operation is equivalent to performing a Software Only installation from the image.
You must use /oracle/product/19.3.0/db_1/runInstaller script available to perform the Software Only install. For more details on image based installation, refer to help documentation.

Starting Oracle Universal Installer...

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2022-11-14_01-45-38AM.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 OraDB19Home2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2022-11-14_01-45-38AM.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. /oracle/product/19.3.0/db_1/root.sh

Execute /oracle/product/19.3.0/db_1/root.sh on the following nodes:
[primary02]


..................................................   100% Done.

5. Run root.sh

We followed the instruction to run root.sh on all nodes.

Node 1

[root@primary01 ~]# /oracle/product/19.3.0/db_1/root.sh
Check /oracle/product/19.3.0/db_1/install/root_primary01.example.com_2022-11-14_01-43-54-491162614.log for the output of root script

Then we check the inventory on this node.

[oracle@primary01 ~]$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
...
<HOME_LIST>
<HOME NAME="OraGI19Home1" LOC="/u01/app/19.0.0/grid" TYPE="O" IDX="1" CRS="true"/>
<HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.0.0/db_1" TYPE="O" IDX="2"/>
<HOME NAME="OraDB19Home2" LOC="/oracle/product/19.3.0/db_1" TYPE="O" IDX="3"/>
</HOME_LIST>

Node 2

[root@primary02 ~]# /oracle/product/19.3.0/db_1/root.sh
Check /oracle/product/19.3.0/db_1/install/root_primary02.example.com_2022-11-14_01-52-02-329293496.log for the output of root script

Then we check the inventory on this node.

[oracle@primary02 ~]$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
...
<HOME_LIST>
<HOME NAME="OraGI19Home1" LOC="/u01/app/19.0.0/grid" TYPE="O" IDX="1" CRS="true"/>
<HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.0.0/db_1" TYPE="O" IDX="2"/>
<HOME NAME="OraDB19Home2" LOC="/oracle/product/19.3.0/db_1" TYPE="O" IDX="3"/>
</HOME_LIST>

6. srvctl modify database

We should update the new home to the cluster by srvctl.

[oracle@primary01 ~]$ srvctl modify database -d orclcdb -o "/oracle/product/19.3.0/db_1"
[oracle@primary01 ~]$ srvctl config database -d orclcdb
...
Oracle home: /oracle/product/19.3.0/db_1

7. Startup Database

To start a RAC database, we use utility srvctl.

[oracle@primary01 ~]$ srvctl start database -d orclcdb
[oracle@primary01 ~]$ srvctl status database -d orclcdb
Instance ORCLCDB1 is running on node primary01
Instance ORCLCDB2 is running on node primary02

8. Test Connection

We test the connection by sqlplus.

C:\Users\scott>sqlplus system/password@orclcdb
...
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

SQL>

We have move the database home to a new place.

Leave a Reply

Your email address will not be published. Required fields are marked *