重庆思庄Oracle、Redhat认证学习论坛
标题:
使用RMAN DUPLICATE复制数据库(Oracle 12c)到本机
[打印本页]
作者:
jiawang
时间:
2021-2-28 20:21
标题:
使用RMAN DUPLICATE复制数据库(Oracle 12c)到本机
本帖最后由 jiawang 于 2021-3-1 11:19 编辑
--使用RMAN DUPLICATE复制数据库(Oracle 12c)到本机
--克隆CDB的方法与11g相同。
--PDB的克隆比CDB的克隆要简单且快。
--步骤
--1.克隆本机pdb
--create pluggable database pdb_new from pdb_old file_name_convert=('pdb_old路径','pdb_new路径');
--*但是pdb_old需要在只读状态,alter pluggable database pdb_old close;
--2.克隆远程pdb
--create database link old12c connect to sys identified by oracle using 'tns_old_12c';
--create pluggable database pdb_new from pdb_old@old12c file_name_convert=('pdb_old路径','pdb_new路径');
实验:
--1.本机复制seed数据库为pdb1
SQL> select con_id,name from v$datafile where con_id=2; --容器编号为2的是seed库
CON_ID NAME
---------- ------------------------------------------------------------
2 /u01/oracle/oradata/orcl/pdbseed/system01.dbf
2 /u01/oracle/oradata/orcl/pdbseed/sysaux01.dbf
SQL> select name,open_mode from v$pdbs; --SEED库在只读状态
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBORCL MOUNTED
SQL> create pluggable database pdb1 admin user pdb1 identified by oracle file_name_convert=('/u01/oracle/oradata/orcl/pdbseed/','/u01/oracle/oradata/orcl/pdb1/');
Pluggable database created.
克隆完成。
--2.本机复制pdborcl到pdb2
SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------------------------------------ ----------
PDB$SEED READ ONLY
PDBORCL MOUNTED
PDB1 MOUNTED
SQL> alter pluggable database pdbwyzc open read only;
Pluggable database altered.
SQL> select name,open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------------------------------------ ----------
PDB$SEED READ ONLY
PDBORCL READ ONLY
PDB1 MOUNTED
SQL> select con_id,name from v$pdbs;
CON_ID NAME
---------- ------------------------------------------------------------
2 PDB$SEED
3 PDBORCL
4 PDB1
SQL> select name from v$datafile where con_id=3;
NAME
------------------------------------------------------------
/u01/oracle/oradata/orcl/pdborcl/system01.dbf
/u01/oracle/oradata/orcl/pdborcl/sysaux01.dbf
/u01/oracle/oradata/orcl/pdborcl/SAMPLE_SCHEMA_users01.dbf
/u01/oracle/oradata/orcl/pdborcl/example01.dbf
SQL> create pluggable database pdb2 from pdbwyzc file_name_convert=('/u01/oracle/oradata/orcl/pdborcl/','/u01/oracle/oradata/orcl/pdb2/');
Pluggable database created.
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/)
Powered by Discuz! X3.2