Oracle Database 19c offers to complete the same operation by using DBCA in silent mode. In Oracle Database 19c, the use case of creating a non-OMF duplicate database of an OMF primary database is supported.
1--从单实例到单实例 2dbca -silent -createDuplicateDB -gdbName CDB2 -sid CDB2 3-primaryDBConnectionString host01:1521/CDB1 -databaseConfigType SI 4-initParams db_unique_name=CDB2 -sysPassword password 5-datafileDestination /u02/oracle/app/oradata 6 7--从单实例到rac 8dbca -silent -createDuplicateDB -gdbName RACDUP 9-primaryDBConnectionString PRIMSI -sid dup -databaseConfigType RAC 10-adminManaged -nodelist node1,node2 11-initParams db_unique_name=RACDUP 12-sysPassword password -storageType ASM -datafileDestination +DG 13-useOMF true -createListener LISTENERRACDUP:1530
优点:
1、只需要一条命令即可复制一个新的cdb出来,其实比dbca静默直接创建数据库要快很多。
2、可以克隆远程,也可以克隆本地的CDB
下面给出一个使用示例:
环境介绍:
源库 | 目标库 | |
IP地址 | 172.17.0.2 | 172.17.0.3 |
主机名 | lhr2019ocp | ocp19c |
存储方式 | FS | FS |
ORACLE_SID、DB_NAME | CDB2 | CDB4 |
归档模式 | Yes | Yes |
执行克隆的命令为:
1dbca -silent -createDuplicateDB -gdbName CDB4 -sid CDB4 \ 2-primaryDBConnectionString 172.17.0.2:1521/CDB2 -databaseConfigType SI \ 3-initParams db_unique_name=CDB4 -sysPassword lhr \ 4-datafileDestination /opt/oracle/oradata
-primaryDBConnectionString:源库的连接串
-databaseConfigType SI:代表源库是单实例
-gdbName CDB4 -sid CDB4:目标库的sid和db_name
-initParams db_unique_name=CDB4:目标库的唯一名
-datafileDestination:目标库的数据文件路径
执行日志:
1[oracle@ocp19c ~]$ dbca -silent -createDuplicateDB -gdbName CDB4 -sid CDB4 \ 2> -primaryDBConnectionString 172.17.0.2:1521/CDB2 -databaseConfigType SI \ 3> -initParams db_unique_name=CDB4 -sysPassword lhr \ 4> -datafileDestination /opt/oracle/oradata 5Prepare for db operation 622% complete 7Listener config step 844% complete 9Auxiliary instance creation 1067% complete 11RMAN duplicate 1289% complete 13Post duplicate database operations 14100% complete 15 16Look at the log file "/opt/oracle/cfgtoollogs/dbca/CDB4/CDB4.log" for further details. 17 18[oracle@ocp19c ~]$ . oraenv 19ORACLE_SID = [ORCLCDB] ? CDB4 20The Oracle base remains unchanged with value /opt/oracle 21[oracle@ocp19c ~]$ sas 22 23SQL*Plus: Release 19.0.0.0.0 - Production on Thu Aug 20 21:09:50 2020 24Version 19.3.0.0.0 25 26Copyright (c) 1982, 2019, Oracle. All rights reserved. 27 28 29Connected to: 30Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production 31Version 19.3.0.0.0 32 33SYS@CDB4> show pdbs 34 35 CON_ID CON_NAME OPEN MODE RESTRICTED 36---------- ------------------------------ ---------- ---------- 37 2 PDB$SEED READ ONLY NO 38 3 ORCLPDB1 READ WRITE NO 39SYS@CDB4>
是不是很爽,建库变得越来越简单了。