克隆pdb
Posted 雅冰石
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了克隆pdb相关的知识,希望对你有一定的参考价值。
一 实验目的
目前多租户环境里有三个pdb,想根据orclpdb3克隆一个orclpdb4。
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ WRITE NO
4 ORCLPDB2 READ WRITE NO
6 ORCLPDB3 READ WRITE NO
SQL> alter session set container=orclpdb3;
Session altered.
SQL> select * from baidd.t1;
ID NAME
---------- ------------------------------------------------------------
1 dan
1 jiao
二 实验步骤
2.1 将源端pdb启动到read only状态
[oracle@PC ~]$ export ORACLE_SID=orclcdb
[oracle@PC ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Oct 14 21:16:23 2022
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter pluggable database orclpdb3 close;
Pluggable database altered.
--注意,发现是必须没有任何连接pdb的会话,才能成功关闭该pdb。
SQL> alter pluggable database orclpdb3 open read only;
Pluggable database altered.
2.2 克隆pdb
SQL>create pluggable database orclpdb4 from orclpdb3 file_name_convert=('orclpdb3','orclpdb4') ;
Pluggable database created.
2.3 启动pdb
SQL> alter pluggable database orclpdb3 close;
Pluggable database altered.
SQL> alter pluggable database orclpdb3,orclpdb4 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCLPDB1 READ ONLY NO
4 ORCLPDB2 READ WRITE NO
6 ORCLPDB3 READ WRITE NO
9 ORCLPDB4 READ WRITE NO
2.4 配置服务名
cd /u01/app/oracle/product/12c/db_1/network/admin
vi tnsnames.ora
新增如下内容:
orclpdb4 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb4)
)
)
#
2.5 验证
[oracle@PC admin]$ sqlplus sys@orclpdb4 as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Oct 14 21:28:53 2022
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select * from baidd.t1;
ID NAME
---------- ------------------------------------------------------------
1 dan
1 jiao
可以看到orclpdb3的数据已经克隆到了orclpdb4.
--本篇文章主要参考了113-云数据库中-从现有的PDB克隆一个PDB_哔哩哔哩_bilibili
以上是关于克隆pdb的主要内容,如果未能解决你的问题,请参考以下文章
ORACLE 19C PDB克隆遇到ORA-65169错误问题
ORACLE 19C PDB克隆遇到ORA-65169错误问题