Unplugging一个PDB

Posted 王超元

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unplugging一个PDB相关的知识,希望对你有一定的参考价值。

技术分享
Unplugging一个PDB

Unplugging一个pdb不等于remove一个pdb

Unplugging一个pdb会创建一个对应的xml文件,借助该xml文件可以将其添加到其他的cdb

pdb被Unplugging后,还会在v$containers中显示,只是状态为mounted

创建一个目录,用来放Unplugging pdb时创建对应的xml文件
$mkdir -p /u12/app/oracle/unplug/unplugdb

$ sqlplus ‘/as sysdba‘

SQL*Plus: Release 12.1.0.1.0 Production on Tue Jun 23 14:19:54 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> select con_id,name,open_mode,restricted from v$pdbs order by 1;

    CON_ID NAME                           OPEN_MODE  RES
---------- ------------------------------ ---------- ---
         2 PDB$SEED                       READ ONLY  NO
         3 YB                             READ ONLY  NO
         4 YB1                            MOUNTED
         5 CLONEDB                        READ WRITE NO

SQL> alter session set container=clonedb;

Session altered.

SQL> shutdown immediate;
Pluggable Database closed.
SQL> conn /as sysdba
Connected.
SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> select con_id,name,open_mode,restricted from v$pdbs order by 1;

    CON_ID NAME                           OPEN_MODE  RES
---------- ------------------------------ ---------- ---
         2 PDB$SEED                       READ ONLY  NO
         3 YB                             READ ONLY  NO
         4 YB1                            MOUNTED
         5 CLONEDB                        MOUNTED

SQL> alter pluggable database clonedb unplug into ‘/u12/app/oracle/unplug/unplugdb/unplugdb.xml‘;

Pluggable database altered.

SQL> select con_id,name,open_mode,restricted from v$pdbs order by 1;

    CON_ID NAME                           OPEN_MODE  RES
---------- ------------------------------ ---------- ---
         2 PDB$SEED                       READ ONLY  NO
         3 YB                             READ ONLY  NO
         4 YB1                            MOUNTED
         5 CLONEDB                        MOUNTED

SQL> select name,open_mode,total_size from v$pdbs;

NAME                           OPEN_MODE  TOTAL_SIZE
------------------------------ ---------- ----------
PDB$SEED                       READ ONLY   283115520
YB                             READ ONLY   393216000
YB1                            MOUNTED             0
CLONEDB                        MOUNTED             0

SQL> select pdb_name,status from dba_pdbs;

PDB_NAME                                           STATUS
-------------------------------------------------- -------------
YB                                                 NORMAL
PDB$SEED                                           NORMAL
YB1                                                NORMAL
CLONEDB                                            UNPLUGGED



如果想重用该pdb,需要先将该pdb删除,再重新plug到cdb中
SQL> drop pluggable database clonedb;

Pluggable database dropped.

SQL> select pdb_name,status from dba_pdbs;

PDB_NAME                                           STATUS
-------------------------------------------------- -------------
YB                                                 NORMAL
PDB$SEED                                           NORMAL
YB1                                                NORMAL

SQL> 
技术分享

以上是关于Unplugging一个PDB的主要内容,如果未能解决你的问题,请参考以下文章

Unplugging, Plugging, and Upgrading a PDB to a New

使用 pdb 进行调试

pdb 调试+ PyCharm+PyDev 调试

pdb 调试+ PyCharm+PyDev 调试

python调试之pdb调试工具

python调试:pdb基本用法(转)