This post is also available at:
Português

I came across this script looking for something to snapclone databases, other than SPARSE DISKGROUP.
If you don’t want to read this post, go straight to: gDBClone Powerful Database Clone/Snapshot Management Tool (Doc ID 2099214.1)
I’m going to make a few posts using this script, the first of which will be to make a clone, as if it were an active duplicate with RMAN, but without having to create a tns entry, listener, password file back and forth, it simplifies the boring part.
The clone process is done through “RMAN Duplicate from Active Database”, and by default it allocates 3 channels to make the clone, if necessary you can increase this amount by passing the parameter “-channels
The clone is made without any significant impact on the production environment. It can also be made through a complete backup of the source database, with even less I/O impact on the production database.
Note: The option of making the clone through a backup will not be covered at this stage.
Configuration
It was necessary to add an entry to the /etc/sudoers file with the information below, to give the oracle user execute permission.
## Utilizacao do gDBClone
Cmnd_Alias GDBCLONE_CMD=/opt/gDBClone/gDBClone.bin *
oracle ALL=(root) NOPASSWD:GDBCLONE_CMD
BashAnd inserted the entry in the oracle user’s .bash_profile, to make it easier to call the script.
alias gDBClone='sudo /opt/gDBClone/gDBClone.bin'
BashScript parameter options
Usage:
gDBClone clone -sdbname <source DB name>
-sdbscan <source DB Host SCAN name>
|-sbckloc '<backup location path>' [-time <DD-MON-YYYY_HH24:MI:SS>] [-upgrade [-parallel <number of process>]]
|-sopcbck -opclib '<opc_lib_path>' -opcpfile '<opc_pfile_path'
[-scn <scn>] [-dbid <DB id>] [-rmanpwf <rman password file>] [-upgrade [-parallel <number of process>] ]
|-catuser <catalog user> [-catpwf <rman catalog password file>] -cstring <connect string>
[-scn <scn>] [-dbid <DB ID>] [-sbt1 <sbt params>] [-sbt2 <sbt params>]
-tdbname <Target Database Name> [-tdomain <Target Database Domain Name>] -tdbhome <Target Database Home Name>
-dataacfs <acfs mount point> [-redoacfs <acfs mount point>] [-recoacfs <acfs mount point>]
|-datadg <asm data diskgroup> [-redodg <asm redo diskgroup>] [-recodg <asm reco diskgroup>]
[-sga_max_size <size Mb> ] [-sga_target <size Mb>] | [-pfile <file path>]
[-channels <RMAN channels number> ] [-ssize <size Mb>] [-cbset]
[-sdbport <Source DB SCAN Listener Port> ] [-tdbport <Target DB SCAN Listener Port>]
[-racmod <db type> ]
[-standby [-pmode maxperf|maxavail|maxprot] [-activedg] [-rtapply] [-dgbroker [-dgbpath1 <dgb config path>][-dgbpath2 <dgb config path>]] ]
[-opc ] [-noping]
[-resume ]
[-syspwf <sys password file>]
BashCreating a password file
It’s a good idea to create this file to avoid having to type the password at the prompt.
gDBClone syspwf -syspwf /opt/gDBClone/SYSpasswd_file
BashCloning a database
Before carrying out the clone, we must know the name of the ORACLE_HOME that we are going to clone the target database from. Remember that it must be the same version as the production ORACLE_HOME. To check the name of the ORACLE_HOME present on the server, run the command below.
oracle@hsslab [] /home/oracle> gDBClone listhomes
│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
gDBClone - Version: 3.0.4-02
Copyright (c) 2012-2020 Oracle and/or its affiliates.
--------------------------------------------------------
Author: Ruggero Citton [email protected]
RAC Pack, Cloud Innovation and Solution Engineering Team
│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
Oracle Home Name Home Location
--------------- ------------
OraDB12Home1 /u01/app/oracle/product/12.1.0.2/dbhome_2
OraDB12Home3 /u01/app/oracle/product/12.2.0.1/dbhome_1
OraDB19Home1 /u01/app/oracle/product/19.0.0.0/dbhome_1
BashExplanation of each parameter that will be used in the clone.
gDBClone clone -sdbname <nome banco de origem> \
-sdbscan <nome scan de origem>\
-sdbport <porta do listener na origem>\
-tdbname <nome do banco de destino>\
-tdbport <porta do listener no destino>
-tdbhome <nome da ORACLE_HOME>\
-datadg <DG onde serão criados os datafiles>\
-redodg <DG onde serão criados os redos>\
-recodg <DG de recovery área>
-syspwf <caminho do arquivo de password>
BashMaking the clone
ORIGIN
Servidor = hsslab
Service_name = orcl
Scan: 192.168.0.150
Tamanho do banco = 213GB
Bash
DESTINATION
Servidor = hsslab02
Nome do banco de destino = clone01
Porta do listener = 1521
Oracle Home Name = OraDB12Home1
DG de dados = +DATA
DG de redo = +RECO
DG de reco = +RECO
Arquivo de senha = /opt/gDBClone/SYSpasswd_file
BashThe command is ready:
gDBClone clone -sdbname orcl -sdbscan 192.168.0.150 -sdbport 1521 -tdbname clone01 -tdbport 1521 -tdbhome OraDB12Home1 -datadg +DATAC1 -redodg +RECOC1 -recodg +DATAC1 -syspwf /opt/gDBClone/SYSpasswd_file
BashEXECUTION:
oracle@hsslab [orcl] /home/oracle> gDBClone clone -sdbname orcl -sdbscan 192.168.0.150 -sdbport 1521 -tdbname clone01 -tdbport 1521 -tdbhome OraDB12Home1 -datadg +DATAC1 -redodg +RECOC1 -recodg +DATAC1 -syspwf /opt/gDBClone/SYSpasswd_file
[sudo] password for oracle:
INFO: 2021-02-01 15:20:17: Please check the logfile '/opt/gDBClone/out/log/gDBClone_69167.log' for more details
INFO: 2021-02-01 15:38:44: Starting database 'clone01'
SUCCESS: 2021-02-01 15:39:04: Successfully created clone database 'clone01'
BashThe time taken to clone the 213GB was 18 minutes.
Limitations and considerations
gDBClone works on a Grid Infrastructure environment and on Oracle Restart (SIHA). Source database must be in archivelog mode when cloning/snapshotting as it’s executed a hot clone/snapshot. Multitenant database (CDB) snapshot is not currently supported if it contains PDBs created as “snapshot copy”.
“gDBClone snap” needs EE (Enterprise Edition) Databases as the RMAN snapshot time recovery feature is needed and Grid Infrastructure version 12.1 or above. GI version 11g is not supported due to missing ACFS snapshot-of-snapshot feature capability.