Most Oracle administrators know DBCA as the utility used during database creation, but newer Oracle versions also allow it to duplicate an existing database with very little manual work. Internally, DBCA leverages RMAN duplication, so the process is largely automated compared to the traditional method of configuring auxiliary instances and running duplicate scripts manually.
DBCA Database Duplication Overview
Oracle introduced this capability in 12c Release 2 for non-CDB databases, and support was later expanded to CDB environments in Oracle 18c and 19c. The feature is available through command-line execution using the
-createDuplicateDBoption.You can display all available parameters with:
dbca -createDuplicateDB -helpExample output
[oracle@orcl ~]$ dbca -createDuplicateDB -help
-createDuplicateDB - Command to Duplicate a database.
-gdbName <Global database name>
-primaryDBConnectionString <EZCONNECT string to connect to primary database for example "host:port/servicename">
-sid <Database system identifier>
[-useWalletForDBCredentials <true | false> Specify true to load database credentials from wallet]
-dbCredentialsWalletLocation <Path of the directory containing the wallet files>
[-dbCredentialsWalletPassword <Password to open wallet with auto login disabled>]
[-initParams <Comma separated list of name=value pairs>]
[-initParamsEscapeChar <Specify escape character for comma when a specific initParam has multiple values.If the escape character is not specified backslash is the default escape character>]
[-policyManaged | -adminManaged]
[-policyManaged <Policy managed database, default option is Admin managed database>]
-serverPoolName <Specify the single server pool name in case of create server pool or comma separated list in case of existing server pools>
[-pqPoolName <value>]
[-createServerPool <Create a new server pool, which will be used by the database>]
[-pqPoolName <value>]
[-forceServerPoolCreation <To create server pool by force when adequate free servers are not available. This may affect the database which is already in running mode>]
[-pqCardinality <value>]
[-cardinality <Specify the cardinality of the new server pool that is to be created, default is the number of qualified nodes>]
[-adminManaged <Admin managed database, this is default option>]
[-datafileDestination <Destination directory for all database files>]
[-nodelist <Node names separated by comma for the database>]
[-databaseConfigType <SINGLE | RAC | RACONENODE>]
[-RACOneNodeServiceName <Service name for the service to be created for RAC One Node database. This option is mandatory when the databaseConfigType is RACONENODE>]
[-createAsStandby <Option to create a standby database>]
[-dbUniqueName <db_unique_name for standby db>]
[-customScripts <A comma separated list of SQL scripts which needs to be run post db creation.The scripts are run in order they are listed>]
[oracle@orcl ~]$Depending on the environment, DBCA duplication can support several deployment models:
- Active database duplication
- Oracle RAC configurations
- TDE-enabled databases
- Standby database creation
- Post-clone custom SQL execution
In most simple deployments where the source database already uses Oracle Managed Files (OMF), only a few parameters are necessary:
-gdbName— Name of the cloned database-primaryDBConnectionString— Connection string for the source database-sid— SID for the target instanceA basic example looks like this:
dbca -silent -createDuplicateDB \ -gdbName CLONE \ -primaryDBConnectionString "localhost:1521/orcl.localdomain" \ -sid CLONEIf the source environment does not use OMF, the target database can still be configured to use managed files through initialization parameters:dbca -silent -createDuplicateDB \ -gdbName CLONE \ -primaryDBConnectionString "localhost:1521/orcl.localdomain" \ -sid CLONE \ -initParams db_create_file_dest='/u01/app/oracle/oradata'Using backslashes at the end of each line simply improves readability for long commands.
DBCA also allows credentials to be passed directly through the command line using-sysPassword, although many administrators avoid this approach because passwords may remain visible in shell history.Example with password
dbca -silent -createDuplicateDB \ -gdbName CLONE \ -primaryDBConnectionString "hostname:1521/orcl.domainname" \ -sid CLONE \ -sysPassword password
However, it is recommended not to expose passwords directly in the shell history. If omitted, DBCA prompts for the password interactively.Example without password:
dbca -silent -createDuplicateDB \ -gdbName CLONE \ -primaryDBConnectionString "hostname:1521/orcl.domainname" \ -sid CLONE
DBCA then prompts:
Enter SYS user password:In the example, the source database is orcl, and the clone will be named CLONE.Execution output:
DBCA creates logs under:Prepare for db operation 22% complete Listener config step 44% complete Auxiliary instance creation 67% complete RMAN duplicate 89% complete Post duplicate database operations 100% complete
$ORACLE_BASE/cfgtoollogs/dbcaDuring the “RMAN duplicate” phase, you can monitor progress using SQL*Plus:
SELECT SID, ROW_TYPE, OPERATION FROM V$RMAN_STATUS WHERE STATUS = 'RUNNING';
If you are cloning from another server using ASM storage:
dbca -silent -createDuplicateDB \ -gdbName CLONE \ -primaryDBConnectionString "hostname:1521/orcl.domainname" \This method works well for migrations between different storage configurations, including filesystem-to-ASM or ASM-to-filesystem cloning.
-sid CLONE \ -initParams db_create_file_dest='+DATAC1',db_recovery_file_dest='+FRA'
Comments
Post a Comment