oracle 12c 学习之三 pdb 的可拔插测试

DECLARE
l_result BOOLEAN;
BEGIN
l_result := DBMS_PDB.check_plug_compatibility(
pdb_descr_file => '/u02/pdb/pdb3.xml',
pdb_name       => 'pdb3');
IF l_result THEN
DBMS_OUTPUT.PUT_LINE('compatible');
ELSE
DBMS_OUTPUT.PUT_LINE('incompatible');
END IF;
END;
/
1、当前库的可拔插测试
21:06:51 [email protected]> alter pluggable database prod unplug into '/u02/pdb/prod.xml'; 

Pluggable database altered. 

Elapsed: 00:00:04.88
21:07:48 [email protected]> drop pluggable database prod; 

Pluggable database dropped. 

Elapsed: 00:00:04.46
21:09:35 [email protected]> select con_id, dbid, guid, name , open_mode from v$pdbs; 

CON_ID DBID GUID NAME OPEN_MODE
------------- ------------- -------------------------------- ------------------------------ ----------
2 4117202806 117BCA51FD151564E0536506A8C0D708 PDB$SEED READ ONLY
3 3382304421 117C1A2739A394A2E0536506A8C0E86A PDB1 READ WRITE
4 3940876746 117C20359794C040E0536506A8C0B458 PDB2 READ WRITE
6 3885367953 118F19327FCC760FE0536506A8C05BDF PDB4 READ ONLY 

Elapsed: 00:00:00.01
21:09:50 [email protected]> DECLARE
21:12:41 2 l_result BOOLEAN;
21:12:42 3 BEGIN
21:12:42 4 l_result := DBMS_PDB.check_plug_compatibility(
21:12:42 5 pdb_descr_file => '/u02/pdb/prod.xml',
21:12:42 6 pdb_name => 'prod');
21:12:42 7 IF l_result THEN
21:12:42 8 DBMS_OUTPUT.PUT_LINE('compatible');
21:12:42 9 ELSE
21:12:42 10 DBMS_OUTPUT.PUT_LINE('incompatible');
21:12:42 11 END IF;
21:12:42 12 END;
21:12:42 13 /
compatible 

PL/SQL procedure successfully completed. 

Elapsed: 00:00:00.10
21:12:43 [email protected]> create pluggable database prod using '/u02/pdb/prod.xml' nocopy tempfile reuse;

当然,我们在这一步还是可以进行改名的不一定使用原来的名字

21:14:17 [email protected]> alter session set container=prod; 

Session altered. 

Elapsed: 00:00:00.09
21:14:37 [email protected]> select name from v$datafile; 

NAME
----------------------------------------------------------------------------------------------------------------------------------
+DATA/STLDB/DATAFILE/undotbs1.261.874613095
+DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/system.294.874633201
+DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/sysaux.293.874633187
+DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/users.296.874633293
+DATA/STLDB/118073E7A685F068E0536506A8C0A25E/DATAFILE/kiwi.339.874702947 

Elapsed: 00:00:00.08
21:14:45 [email protected]> select name from v$tempfile; 

NAME
----------------------------------------------------------------------------------------------------------------------------------
+DATA/STLDB/118073E7A685F068E0536506A8C0A25E/TEMPFILE/temp.295.874703627

2 跨库的可拔插测试
21:48:28 [email protected]> alter pluggable database pdb3 close; 

Pluggable database altered. 

Elapsed: 00:00:03.97
21:48:53 [email protected]> alter pluggable database pdb3 unplug into '/u02/pdb/pdb3.xml'; 

Pluggable database altered. 

Elapsed: 00:00:05.15
21:49:34 [email protected]> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
[21:50:07 oracle(db)@rac1 ~]$ rman target / 

Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 18 21:50:11 2015 

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. 

connected to target database: STLDB (DBID=3188959514) 

RMAN> BACKUP FOR TRANSPORT AS COMPRESSED BACKUPSET PLUGGABLE DATABASE 'PDB3' FORMAT '/u02/pdb/pdb3.dfb'; 

Starting backup at 18-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=258 instance=stldb1 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00049 name=+DATA/pdb3/pdb3_sysaux01.dbf
input datafile file number=00048 name=+DATA/pdb3/pdb3_system01.dbf
input datafile file number=00051 name=+DATA/pdb3/pdb3_kiwi01.dbf
input datafile file number=00050 name=+DATA/pdb3/pdb3_users01.dbf
channel ORA_DISK_1: starting piece 1 at 18-MAR-15
channel ORA_DISK_1: finished piece 1 at 18-MAR-15
piece handle=/u02/pdb/pdb3.dfb tag=TAG20150318T215139 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
Finished backup at 18-MAR-15 

然后在另外的库上转储进行恢复这个数据库
RMAN> run
2> {
3> set command id  to 'pdb3';
4> RESTORE FOREIGN DATAFILE  48 TO NEW ,49 TO NEW ,50 TO NEW,51 TO NEW  FROM BACKUPSET
5> '/u02/pdb/pdb3.dfb' ;
6>  };

executing command: SET COMMAND ID

Starting restore at 19-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=142 instance=prod1 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring foreign file 00048
channel ORA_DISK_1: restoring foreign file 00049
channel ORA_DISK_1: restoring foreign file 00050
channel ORA_DISK_1: restoring foreign file 00051
channel ORA_DISK_1: reading from backup piece /u02/pdb/pdb3.dfb
channel ORA_DISK_1: restoring foreign file 48 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/system.351.874714735
channel ORA_DISK_1: restoring foreign file 49 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/sysaux.350.874714735
channel ORA_DISK_1: restoring foreign file 50 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/users.353.874714735
channel ORA_DISK_1: restoring foreign file 51 to +DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/kiwi.352.874714735
channel ORA_DISK_1: foreign piece handle=/u02/pdb/pdb3.dfb
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:06
Finished restore at 19-MAR-15

创建pdb
create pluggable database pdb3 as clone  using '/u02/pdb/pdb3.xml'
 source_file_name_convert = (
 '+DATA/pdb3/pdb3_system01.dbf',
'+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/system.351.874714735',
 '+DATA/pdb3/pdb3_sysaux01.dbf',
'+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/sysaux.350.874714735',
'+DATA/pdb3/pdb3_users01.dbf',
'+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/users.353.874714735',
'+DATA/pdb3/pdb3_temp01.dbf',
'+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/temp01.dbf',
'+DATA/pdb3/pdb3_kiwi01.dbf',
'+DATA/PROD/1191435B2E309449E0536506A8C02DFC/DATAFILE/kiwi.352.874714735')
file_name_convert=NONE  NOCOPY;

00:45:17 [email protected]> select con_id, dbid, guid, name , open_mode from v$pdbs; 

CON_ID DBID GUID NAME OPEN_MODE
------------- ------------- -------------------------------- ------------------------------ ----------
2 4117299261 11900B6E18D984BAE0536506A8C0B9FE PDB$SEED READ ONLY
3 3990814677 1193C11BCCBCAD60E0536506A8C0ABA9 PDB3 MOUNTED 

Elapsed: 00:00:00.01
00:46:04 [email protected]> alter pluggable database pdb3 open; 

Pluggable database altered. 

Elapsed: 00:00:20.39
00:46:35 [email protected]> alter session set container=pdb3
00:46:55 2 ; 

Session altered. 

Elapsed: 00:00:00.11
00:46:56 [email protected]> select name from v$tablespace; 

NAME
------------------------------
UNDOTBS1
SYSTEM
SYSAUX
TEMP
USERS
KIWI

时间: 2024-10-13 04:45:47

oracle 12c 学习之三 pdb 的可拔插测试的相关文章

oracle 12c 学习之三 nocdb 转换成pdb

01:23:06 [email protected]> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database; NAME Multitenant Option OPEN_MODE CON_ID --------- -----------------

Oracle 12c 操作 CDB PDB

CREATE TRIGGER open_all_pdbs AFTER STARTUP ON DATABASE BEGIN EXECUTE IMMEDIATE 'alter pluggable database all open'; END open_all_pdbs; / alter pluggable database all open alter pluggable database all close; alter session set container = pdbmyoracle;

oracle 12c 多租户 pdb 恢复(单个pdb数据文件、非系统pdb表空间、整个pdb数据库)

环境:数据库版本 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 实验准备:1.-- 数据库归档模式SQL> select name,log_mode from v$database;NAME  LOG_MODE--------- ------------ANDYCDB   ARCHIVELOG   > 数据库归档模式 2.-- 登录 PDB 中创建实验表空间 与 用户[[email pr

Oracle 12c CDB 和PDB 数据库的启动与关闭 说明

在Oracle 12c中,分CDB 和PDB,他们的启动和关闭操作整理如下. 1  Container Database (CDB) 对于CDB,启动和关闭与之前传统的方式一样,具体语法如下: STARTUP[NOMOUNT | MOUNT | RESTRICT | UPGRADE | FORCE | READ ONLY] SHUTDOWN[IMMEDIATE | ABORT] 要注意,在12c数据库创建完成后,默认情况下使用sqlplus / as sysdba  登录连接的是CDB. [[e

Oracle 12c 学习之启动关闭CDB&PDB

1.默认登陆到CDB <roidb01:cdb:/home/oracle>$sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Sat Jan 20 11:01:46 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. 2.启动CDB SQL> startup ORACLE instan

Oracle 12C -- 使用seed PDB创建新的pdb

$ sqlplus '/as sysdba' SQL*Plus: Release 12.1.0.1.0 Production on Tue Jun 23 13:03:06 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 Part

Oracle 12c CDB与PDB

Oracle安装参考:https://www.cnblogs.com/zhichaoma/p/9288739.html 对于CDB,启动和关闭与之前传统的方式一样,具体语法如下: STARTUP[NOMOUNT | MOUNT | RESTRICT | UPGRADE | FORCE | READ ONLY] SHUTDOWN[IMMEDIATE | ABORT] 手动创建CDB 1. 修改~/.bash_profile文件,修改ORACLE_SID名称 export ORACLE_SID=or

oracle 12c jdbc连接pdb报错的问题

有同学发来消息说,oracle数据库使用jdbc连接会后报ora-12505错误. 下意识地回复说查看jdbc连接串中的数据库sid/服务名是否写错了. 对方反馈说没错.然后让他以下面的方式连接是可以正常连接的: sqlplus scott/[email protected]:1521/pdborcl 然后让他把jdbc的格式改成如下所示后连接成功! Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhos

Oracle 12c CDB 和 PDB 表空间管理和配置 说明

 注:本文谢绝转载. 1  管理CDB中的表空间 CDB表空间的管理和non-CDB 表空间的管理一样,CDB 也有一个实例,在安装的时候指定. --查看表空间: SQL> select instance_name fromv$instance; INSTANCE_NAME ---------------- Cndba SQL> col file_name for a50 SQL> selecttablespace_name,file_id,file_name from dba_data