DBCA新特性Oracle 19c

发布于:2021-02-07 10:25:20

0

674

0

DBCA Oracle Oracle 19c

在oracle19c中,DBCA在静默模式下添加了许多新功能。

在oracle18c中,我们可以通过guidbca和DBCA-silent-createPluggableDatabase命令克隆PDB。

Oracle 19c中的新功能是创建PDB的远程克隆,以及使用DBCA静默模式执行PDB的重定位。

我们可以使用DBCA命令createPluggableDatabase的createfromlotepdb参数通过克隆远程PDB来创建PDB,也可以使用relocatePDB选项将PDB从一个容器数据库重定位到另一个容器数据库。

让我们看一个成功的例子。

以下是19c环境:

  • host01:CDB1(PDB1,PDB2)

  • host02:CDB2(PDB2)

我们将从CDB1远程克隆PDB1,并在容器数据库CDB2中创建可插入数据库。

然后,我们将通过使用dbca silent方法克隆PDB1,在CDB1中创建另一个可插入数据库PDB3。

然后我们将PDB3从CDB1重新定位到CDB2。

为此,我们需要在CDB1中创建一个公共用户,并使用此用法创建从CDB2到CDB1的数据库链接。

***Create common user in CDB1***

SQL> create user c##link_user identified by oracle container=all;

User created.

SQL> grant sysoper,sysdba to c##link_user container=all;

Grant succeeded.

SQL> grant create pluggable database to c##link_user container=all;

Grant succeeded.

SQL> grant create session to c##link_user container=all;

Grant succeeded.


***Add TNS entry to connect to CDB1 from CDB2***

CDB1 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = host02.localdomain)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = cdb1.localdomain)
   )
 )

***Create database link from CDB2 to CDB1***

SQL> create database link cdb1_link connect to c##link_user identified by oracle
   using 'cdb1';

Database link created.


SQL>  select * from dual@cdb1_link;

D
-
X


***Note the PDB's currently in CDB2***

SQL> show pdbs

   CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED  READ ONLY  NO
3 PDB2  READ WRITE NO

 远程可插拔克隆

使用带有-createfromlotepdb子句的dbca-silent-createPluggableDatabase命令创建可插入数据库。

[oracle@host02 ~]$ dbca -silent -createPluggableDatabase -pdbname pdb1 -sourceDB cdb2 -createFromRemotePDB -remotePDBName pdb1 -dbLinkUsername c##link_user -remoteDBConnString "host01:1521/cdb1.localdomain" -remoteDBSYSDBAUserName SYS -dbLinkUserPassword oracle -remoteDBSYSDBAUserPassword welcome1 -sysDBAUserName SYS -sysDBAPassword welcome1 -pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb1/'

Prepare for db operation
50% complete
Create pluggable database using remote clone operation
100% complete
Pluggable database "pdb1" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb1/cdb2.log" for further details.


SQL> show pdbs

   CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED  READ ONLY  NO
3 PDB2  READ WRITE NO
4 PDB1  READ WRITE NO

 重新定位可插入数据库

 首先,我们使用dbca-silent-createPluggableDatabase命令从PDB1克隆来创建CDB1中的PDB3

[oracle@host01 ~]$ dbca -silent -createPluggableDatabase -sourceDB cdb1 -pdbName pdb3 -createAsClone FALSE -createPDBFrom PDB -sourcePDB pdb1 -fileNameConvert '/u01/app/oracle/oradata/CDB1/pdb1/','/u01/app/oracle/oradata/CDB1/pdb3/'
Prepare for db operation
13% complete
Creating Pluggable Database
15% complete
19% complete
23% complete
31% complete
53% complete
Completing Pluggable Database Creation
60% complete
Executing Post Configuration Actions
100% complete
Pluggable database "pdb3" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb1/pdb3/cdb1.log" for further details.

SQL> show pdbs

   CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED  READ ONLY  NO
3 PDB1  READ WRITE NO
4 PDB2  READ WRITE NO
5 PDB3  READ WRITE NO

使用dbca-silent-relocatePDB命令将PDB3从CDB1重新定位到CDB2。

[oracle@host02 ~]$ dbca -silent  -relocatePDB -pdbname pdb3 -sourceDB cdb2 -remotePDBName pdb3 -dbLinkUsername c##link_user -remoteDBConnString "host02:1521/cdb1.localdomain" -remoteDBSYSDBAUserName SYS -dbLinkUserPassword oracle -remoteDBSYSDBAUserPassword G#vin2407 -sysDBAUserName SYS -sysDBAPassword G#vin2407 -pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb3/'
Prepare for db operation
50% complete
Create pluggable database using relocate PDB operation
100% complete
Pluggable database "pdb3" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb3/cdb2.log" for further details.


****Note the PDB's now in CDB2****

SQL> show pdbs

   CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED  READ ONLY  NO
3 PDB2  READ WRITE NO
4 PDB1  READ WRITE NO
5 PDB3  READ WRITE NO

****Note the PDB's now in CDB1****

SQL> show pdbs

   CON_ID CON_NAME  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED  READ ONLY  NO
3 PDB1  READ WRITE NO
4 PDB2  READ WRITE NO