구분 | 내용 |
1 | 오라클 멀티테넌트 소개 |
2 | 멀티테넌트 CDB와 PDB, 데이터 딕셔너리 |
3 | PDB 생성과 삭제 |
4 | 통합 도구로서 PDB 사용 |
5 | PDB와 리소스 관리 |
6 | CDB와 PDB의 관리 |
7 | CDB와 PDB 백업 및 복구 |
CDB와 PDB
CDB: Container Database
PDB: Pluggable Database
톰 카이트의 한 마디
현재 오라클 데이터베이스 12c 릴리스에서는 기존의 아키텍처뿐만 아니라, 멀티테넌트 아키텍처도 지원하지만 향후에는 이전 아키텍처 지원은 중단될 것이다.(오라클 멀티테넌트 라이선스 별도 구매 필요)
따라서 DBA가 이 멀티테넌트 아키텍처에 익숙해지는 것이 앞으로 도움이 될 것으로 생각된다.
CDB에 단 한 개의 PDB로만 되어 있는 경우 일반 라이선스로만 가능
톰 카이트의 한 마디
멀티테넌트 아키텍처는 DBA에게만 변화가 있지 개발자나 애플리케이션의 관점에서는 변화가 없다.
멀티테넌트 아키텍처의 궁극적인 목표는 기존에 존재하는 애플리케이션의 영향 없이 리소스를 좀 더 효과적으로 사용하는 데 있다.
데이터 딕셔너리 뷰가 컨테이너를 참조하기 위해 CON라는 용어를 사용한다. 예를 들어 CON_ID 컬럼은 컨테이너 ID를 나타낸다.
구분 | 내용 |
1 | CDB 생성 |
2 | CDB 구조 |
3 | CDB 명명 |
4 | CDB 장점 |
5 | CDB 생성에 필요한 버전 |
6 | CDB 루트 컨테이너 |
7 | CDB common 유저 |
CDB 아키텍처 |
구분 | 내용 |
인스턴스 | CDB와 모든 PDB들은 동일한 인스턴스를 공유한다. 동일한 SGA 메모리 구조를 공유하고 메모리를 구성하는데 사용되는 파라미터는 한 개만 존재한다. |
CDB | CDB는 전체 데이터베이스로 메타데이터 및 데이터베이스의 데이터를 저장하는 여러 개의 컨테이너가 포함한다. |
컨테이너 | 시스템의 메타데이터와 스키마 정보 또는 데이터베이스의 메타데이터와 스키마 데이터를 위한 고유하고 독집적인 저장 위치를 의미한다. |
루트 컨테이너 | 각 CDB는 하나의 루트 컨테이너를 포함하고 CDB$ROOT라는 이름을 가진다. 이는 스키마, 스키마 오브젝트 또는 전체 CDB에 속한 비스키마 오브젝트에 대한 위치를 제공한다. PDB를 관리하는데 필요한 메타데이터 저장한다. |
루트 CDB |
Seed PDB | CDB는 새로운 PDB를 만드는데 사용되는 PDB$SEED라는 PDB를 가지고 있다. PDB$SEED 내에 오브젝트를 추가하거나 변경할 수 없다. |
PDB | 사용자 스키마, 데이터, 코드와 기타 데이터베이스 관련 오브젝트를 담고 있는 유저가 만든 개체이다. PDB는 CDB 내에서 고유하고 독립된 데이터베이스 환경을 가진다. 하나의 CDB는 복수 개의 PDB를 가질 수 있다. |
CDB 인스턴스 | 인스턴스 파라미터, SGA, 백그라운드 프로세스와 같이 일반적인 인스턴스 항목이 포함된 구조이다. |
하나 이상의 컨트롤 파일 | non-CDB와 같이 컨트롤 파일을 다중화 한다. 이 컨트롤 파일은 CDB와 연결된 PDB를 모두 지원한다. |
온라인 리두 로그 파일 | non-CDB와 같이 여러 그룹을 생성하고 다중화 한다. 이 리두 로그가 전체 CDB와 연결된 PDB를 같이 지원한다. 온라인 리두 로그는 루트 컨테이너의 일부로서 저장되는 것으로 간주한다. CDB가 ARCHIVELOG 모드인 경우 아카이브 파일도 생성한다. ARCHIVELOG 모드의 변경은 CDB레벨에서만 수행한다. |
하나 이상의 Temporary 파일 집합 | CDB는 디폴트로 TEMP라는 단일 Temporary 테이블 스페이스를 최소한 한 개를 가진다. 이 테이블 스페이스는 CDB와 PDB에 대한 임시 작업에 대한 요청을 처리한다. CDB는 추가로 Temporary 테이블 스페이스를 생성하거나 정의할 수 있고, PDB마다 Temporary 테이블 스페이스를 생성할 수 있다. |
Undo 테이블 스페이스와 관련 Tempfile | 하나의 UNDO 테이블 스페이스와 tempfile이 non-RAC인 CDB의 루트 컨테이너에 위치한다. 이 UNDO 테이블 스페이스는 CDB와 PDB를 모두 지원한다. RAC 구성에서 각 노드별로 Undo 테이블 스페이스를 가진다. |
SYSTEM과 SYSAUX | CDB의 시스템 테이블 스페이스의 데이터 파일에는 루트 컨테이너에 관한 데이터 딕셔너리와 PDB와 관련된 데이터 딕셔너리에 대한 Pointer를 가진다. CDB는 유저 테이블 스페이스나 유저에 관련되는 데이터 파일을 가지지 않는다. |
톰 카이트의 한 마디
12c에서 어떠한 아키텍처를 선택하는 것과는 별개로 SYSTEM이나 SYSAUX 테이블 스페이스에 오브젝트를 생성하지 못하는 것은 기존에 SYS나 SYSTEM 스키마에 유저 오브젝트를 생성하는 못하는 것과 마찬가지로 아무리 강조해도 지나치치 않다.
Internal 계정인 SYS나 SYSTEM 계정으로 관리자 작업 외 목적으로 로그인해서는 안 된다.
SQL> select name, cdb from v$database;
NAME CDB
--------------------------- ---------
CDB2 YES
1 | 비용절감 |
2 | 쉽고 간단한 데이터 이동 |
3 | 오라클 데이터베이스 Resource Manager 지원 |
4 | PDB의 독립성 |
5 | 관리 의무의 세분화된 분리 제공 |
6 | 손쉬운 퍼포먼스 튜닝 |
7 | 손쉬운 패치와 업그레이드 |
톰 카이트의 한 마디
CDB를 업그레이드/패치할 때 동시에 관련된 PDB를 모두 적용하거나 선택해서 일부만 적용할 수 있다.
패치를 적용하거나 다음 릴리스로 업그레이드할 때 기존에 존재했던 데이터베이스를 업그레이드하는 대신에 새로운 멀티테넌트 DB 인스턴스를 구성하도록 선택할 수 있다.
그런 다음 PDB를 업그레이드/패치하고 기존의 CDB로부터 간단히 몇 초 안에 언플러그해서 새로운 CDB로 플러그 할 수 있다.
이 방식으로 새로운 릴리스에서 각각의 애플리케이션을 테스트하는 목적으로 며칠 또는 몇 주 간의 과정을 통해 PDB를 업그레이드/패치 할 수 있다.
SQL> create user black identified by black container=all;
create user black identified by black container=all
*
ERROR at line 1:
ORA-65096: invalid common user or role name
SQL> create user c##black identified by black container=all;
User created.
SQL>
SQL> create user c##white identified by white;
User created.
SQL> create user c##gray identified by gray container=current;
create user c##gray identified by gray container=current
*
ERROR at line 1:
ORA-65094: invalid local user or role name
SQL> drop user c##white cascade;
User dropped.
1 | PDB 이해 |
2 | PDB 퍼포먼스 |
3 | PDB 명명 |
4 | PDB local 유저 |
5 | PDB 엑세스 |
1 | PDB는 독립적이고 분리된 저장소로 특정 애플리케이션의 데이터를 저장할 때 사용할 수 있다. |
2 | local 유저의 권한은 PDB 내로 한정되기 때문에 관리 권한을 제어할 수 있다. |
3 | PDB는 다른 CDB로 쉽게 이동이 가능하다. |
4 | PDB를 쉽게 복사해서 데이터베이스를 구축할 수 있기 때문에 프로비저닝 작업 시간을 줄일 수 있다. |
PDB 증가에 따른 메모리 사용률 |
톰 카이트의 한 마디
멀티테넌트 아키텍처의 주된 이점 중에 하나는 단일 호스트상에 복수 개의 데이터베이스를 운영 할 때 리소스에 대한 소비를 줄일 수 있다는 사실이다. 만약 하나의 오라클 인스턴스가 대략적으로 25개의 백그라운드 프로세스가 떠 있다면 10개의 데이터베이스를 단일 호스트에서 구동한다면 250개의 백그라운드 프로세스가 필요하다는 의미다. 멀티테넌트 아키텍처를 사용하는 것은 동일한 10개의 데이터베이스에 단지 25개의 PGA를 가진 25개의 프로세스만이 사용된다는 것이다. OS나 감소된 인스턴스의 메모리 공간뿐만 아니라 관리되는 프로세스 수도 감소함으로써 리소스 절약 효과는 매우 클 수 있다.
1 | 첫 번째 오는 문자는 반드시 알파벳이어야 한다. | ||
2 | 그 다음 문자는 알파벳 또는 밑줄(_)이 올 수 있다. | 3 | PDB명은 대소문자를 구분하지 않는다. |
SQL> alter session set container=PDB1;
Session altered.
SQL> create user test identified by test;
User created.
SQL> grant create session to test;
Grant succeeded.
$ sqlplus test/test;
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 25 16:30:13 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
$ sqlplus test/test@192.168.56.101:1521\/PDB1
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 25 16:32:16 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options
SQL>
$ sqlplus test/test@pdb1
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 25 16:33:33 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Fri Nov 25 2016 16:32:16 +00:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options
SQL>
$ sqlplus sys/oracle@pdb1 as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 25 16:34:46 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options
SQL>
$ sqlplus sys/oracle@192.168.56.101:1521\/PDB1 as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 25 16:36:06 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Advanced Analytics
and Real Application Testing options
SQL>
데이터 딕셔너리 관계 |
1 | 루트 컨테이너에 저장된 데이터 |
2 | 오브젝트 링크: PDB 내 데이터 딕셔너리 오브젝트의 포인터 |
3 | 메타데이터 링크: PDB 내 데이터 딕셔너리 오브젝트의 데이터에 대한 포인터 |
SQL> select count(*) from DBA_OBJECTS;
COUNT(*)
----------
90940
SQL> select count(*) from CDB_OBJECTS;
COUNT(*)
----------
246656
SQL> select sharing, count(*) from DBA_OBJECTS group by sharing;
SHARING COUNT(*)
--------------------------------------- ----------
METADATA LINK 84317
NONE 6449
OBJECT LINK 174
SQL> select sharing, count(*) from CDB_OBJECTS group by sharing;
SHARING COUNT(*)
--------------------------------------- ----------
OBJECT LINK 515
NONE 16541
METADATA LINK 229600
1 | seed 데이터베이스로부터 PDB 생성 | 복제 방식 |
2 | PDB를 언플러그해서 CDB로 플러그 | 플로그인 방식 |
3 | non-CDB를 PDB로 플러그 | 플로그인 방식 |
SQL> create pluggable database PDB3 admin user adm identified by adm file_name_convert=('/oradata/CDB1/pdbseed', '/oradata/CDB1/pdb3');
Pluggable database created.
SQL> alter session set container=pdb3;
Session altered.
SQL>
SQL> startup
Pluggable Database opened.
SQL> @/u01/app/oracle/product/12.1.0.2/rdbms/admin/preupgrd.sql
Loading Pre-Upgrade Package...
***************************************************************************
Executing Pre-Upgrade Checks in PDB3...
***************************************************************************
************************************************************
====>> ERRORS FOUND for PDB3 <<====
The following are *** ERROR LEVEL CONDITIONS *** that must be addressed
prior to attempting your upgrade.
Failure to do so will result in a failed upgrade.
You MUST resolve the above errors prior to upgrade
************************************************************
************************************************************
====>> PRE-UPGRADE RESULTS for PDB3 <<====
ACTIONS REQUIRED:
1. Review results of the pre-upgrade checks:
/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade.log
2. Execute in the SOURCE environment BEFORE upgrade:
/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade_fixups.sql
3. Execute in the NEW environment AFTER upgrade:
/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/postupgrade_fixups.sql
************************************************************
***************************************************************************
Pre-Upgrade Checks in PDB3 Completed.
***************************************************************************
***************************************************************************
***************************************************************************
oracle@localhost:/oradata/CDB1/pdb3$ cat /u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade.log
Oracle Database Pre-Upgrade Information Tool 11-25-2016 11:28:08
Script Version: 12.1.0.2.0 Build: 010
**********************************************************************
Database Name: CDB1
Container Name: PDB3
Container ID: 3
Version: 12.1.0.1.0
Compatible: 12.1.0.0.0
Blocksize: 8192
Platform: Linux x86 64-bit
Timezone file: V18
**********************************************************************
[Update parameters]
[No parameters to update]
**********************************************************************
**********************************************************************
[Renamed Parameters]
[No Renamed Parameters in use]
**********************************************************************
**********************************************************************
[Obsolete/Deprecated Parameters]
[No Obsolete or Desupported Parameters in use]
**********************************************************************
[Component List]
**********************************************************************
--> Oracle Catalog Views [upgrade] VALID
--> Oracle Packages and Types [upgrade] VALID
--> JServer JAVA Virtual Machine [upgrade] VALID
--> Oracle XDK for Java [upgrade] VALID
--> Real Application Clusters [upgrade] OPTION OFF
--> Oracle XML Database [upgrade] VALID
--> Oracle Java Packages [upgrade] VALID
**********************************************************************
[ Unsupported Upgrade: Tablespace Data Suppressed ]
**********************************************************************
**********************************************************************
[Pre-Upgrade Checks]
**********************************************************************
**********************************************************************
[Pre-Upgrade Recommendations]
**********************************************************************
*****************************************
********* Dictionary Statistics *********
*****************************************
Please gather dictionary statistics 24 hours prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:
EXECUTE dbms_stats.gather_dictionary_stats;
^^^ MANUAL ACTION SUGGESTED ^^^
**********************************************************************
[Post-Upgrade Recommendations]
**********************************************************************
*****************************************
******** Fixed Object Statistics ********
*****************************************
Please create stats on fixed objects two weeks
after the upgrade using the command:
EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
^^^ MANUAL ACTION SUGGESTED ^^^
**********************************************************************
************ Summary ************
0 ERRORS exist in your database.
0 WARNINGS exist in your database.
0 INFORMATIONAL messages messages have been reported.
After your database is upgraded and open in normal mode you must run
rdbms/admin/catuppst.sql which executes several required tasks and completes
the upgrade process.
You should follow that with the execution of rdbms/admin/utlrp.sql, and a
comparison of invalid objects before and after the upgrade using
rdbms/admin/utluiobj.sql
If needed you may want to upgrade your timezone data using the process
described in My Oracle Support note 1509653.1
***********************************
SQL> execute dbms_stats.gather_dictionary_stats;
SQL> @/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade_fixups.sql
Pre-Upgrade Fixup Script Generated on 2016-11-25 11:28:05 Version: 12.1.0.2 Build: 010
Beginning Pre-Upgrade Fixups...
Executing in container PDB3
**********************************************************************
[Pre-Upgrade Recommendations]
**********************************************************************
*****************************************
********* Dictionary Statistics *********
*****************************************
Please gather dictionary statistics 24 hours prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:
EXECUTE dbms_stats.gather_dictionary_stats;
^^^ MANUAL ACTION SUGGESTED ^^^
**************************************************
************* Fixup Summary ************
No fixup routines were executed.
**************************************************
**************** Pre-Upgrade Fixup Script Complete *********************
SQL> alter session set container=CDB$ROOT;
SQL> alter pluggable database PDB3 close;
SQL> alter pluggable database PDB3 unplug into '/tmp/pdb3.xml';
SQL> drop pluggable database PDB3 keep datafiles;
SQL> select name, cdb from v$database;
NAME CDB
--------------------------- ---------
CDB2 YES
SQL> SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) := CASE
DBMS_PDB.CHECK_PLUG_COMPATIBILITY( pdb_descr_file => '/tmp/pdb3.xml',
pdb_name => 'PDB3') WHEN TRUE THEN 'YES' ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
NO
SQL> select name,cause,type, status, message
from PDB_PLUG_IN_VIOLATIONS
where name='PDB3'; 2 3
NAME CAUSE TYPE STATUS MESSAGE
---------- ---------- ---------- ---------- ----------------------------------------------------------------------------------------------------
PDB3 VSN not ma ERROR PENDING PDB's version does not match CDB's version: PDB's version 12.1.0.0.0. CDB's version 12.1.0.2.0.
tch
PDB3 APEX WARNING PENDING APEX mismatch: PDB installed version NULL CDB installed version 4.2.5.00.08
PDB3 Parameter WARNING PENDING CDB parameter processes mismatch: Previous 300 Current 200
PDB3 Parameter WARNING PENDING CDB parameter sga_target mismatch: Previous 800M Current 1000M
PDB3 Parameter WARNING PENDING CDB parameter compatible mismatch: Previous 12.1.0.0.0 Current 12.1.0.2.0
PDB3 Parameter WARNING PENDING CDB parameter pga_aggregate_target mismatch: Previous 100M Current 120M
6 rows selected.
SQL> create pluggable database pdb3 using '/tmp/pdb3.xml' file_name_convert=('/oradata/CDB1/pdb3', '/oradata/CDB2/pdb3');
Pluggable database created.
SQL> alter pluggable database PDB3 open upgrade;
Warning: PDB altered with errors.
alter pluggable database PDB3 open upgrade
Fri Nov 25 13:09:18 2016
Pluggable database PDB3 dictionary check beginning
Pluggable Database PDB3 Dictionary check complete
Database Characterset for PDB3 is WE8ISO8859P15
***************************************************************
WARNING: Pluggable Database PDB3 with pdb id - 4 is
altered with errors or warnings. Please look into
PDB_PLUG_IN_VIOLATIONS view for more details.
***************************************************************
Due to limited space in shared pool (need 6094848 bytes, have 3981120 bytes), limiting Resource Manager entities from 2048 to 32
Opening pdb PDB3 (4) with no Resource Manager plan active
Fri Nov 25 13:09:19 2016
ALTER SYSTEM SET _system_trig_enabled=FALSE SCOPE=MEMORY;
Fri Nov 25 13:09:19 2016
ALTER SYSTEM SET enable_ddl_logging=FALSE SCOPE=MEMORY;
Resource Manager disabled during database migration: plan '' not set
Fri Nov 25 13:09:19 2016
ALTER SYSTEM SET resource_manager_plan= SCOPE=MEMORY;
Fri Nov 25 13:09:19 2016
ALTER SYSTEM SET recyclebin='OFF' DEFERRED SCOPE=MEMORY;
Pluggable database PDB3 opened read write
Completed: alter pluggable database PDB3 open upgrade
$ /u01/app/oracle/product/12.1.0.2/perl/bin/perl catctl.pl -c 'PDB3' catupgrd.sql
Argument list for [catctl.pl]
SQL Process Count n = 0
SQL PDB Process Count N = 0
Input Directory d = 0
Phase Logging Table t = 0
Log Dir l = 0
Script s = 0
Serial Run S = 0
Upgrade Mode active M = 0
Start Phase p = 0
End Phase P = 0
Log Id i = 0
Run in c = PDB3
Do not run in C = 0
Echo OFF e = 1
No Post Upgrade x = 0
Reverse Order r = 0
Open Mode Normal o = 0
Debug catcon.pm z = 0
Debug catctl.pl Z = 0
Display Phases y = 0
Child Process I = 0
catctl.pl version: 12.1.0.2.0
Oracle Base = /u01/app/oracle
Analyzing file catupgrd.sql
Log files in /u01/app/oracle/product/12.1.0.2/rdbms/admin
catcon: ALL catcon-related output will be written to catupgrd_catcon_6537.lst
catcon: See catupgrd*.log files for output generated by scripts
catcon: See catupgrd_*.lst files for spool files, if any
Number of Cpus = 2
Parallel PDB Upgrades = 2
SQL PDB Process Count = 2
SQL Process Count = 0
New SQL Process Count = 2
[CONTAINER NAMES]
CDB$ROOT
PDB$SEED
PDB1
PDB3
PDB Inclusion:[PDB3] Exclusion:[]
Start processing of PDB3
[/u01/app/oracle/product/12.1.0.2/perl/bin/perl catctl.pl -c 'PDB3' -I -i pdb3 -n 2 catupgrd.sql]
Argument list for [catctl.pl]
SQL Process Count n = 2
SQL PDB Process Count N = 0
Input Directory d = 0
Phase Logging Table t = 0
Log Dir l = 0
Script s = 0
Serial Run S = 0
Upgrade Mode active M = 0
Start Phase p = 0
End Phase P = 0
Log Id i = pdb3
Run in c = PDB3
Do not run in C = 0
Echo OFF e = 1
No Post Upgrade x = 0
Reverse Order r = 0
Open Mode Normal o = 0
Debug catcon.pm z = 0
Debug catctl.pl Z = 0
Display Phases y = 0
Child Process I = 1
catctl.pl version: 12.1.0.2.0
Oracle Base = /u01/app/oracle
Analyzing file catupgrd.sql
Log files in /u01/app/oracle/product/12.1.0.2/rdbms/admin
catcon: ALL catcon-related output will be written to catupgrdpdb3_catcon_6778.lst
catcon: See catupgrdpdb3*.log files for output generated by scripts
catcon: See catupgrdpdb3_*.lst files for spool files, if any
Number of Cpus = 2
SQL PDB Process Count = 2
SQL Process Count = 2
[CONTAINER NAMES]
CDB$ROOT
PDB$SEED
PDB1
PDB3
PDB Inclusion:[PDB3] Exclusion:[]
------------------------------------------------------
Phases [0-73] Start Time:[2016_11_25 13:15:24]
Container Lists Inclusion:[PDB3] Exclusion:[NONE]
------------------------------------------------------
Serial Phase #: 0 PDB3 Files: 1 Time: 8s
Serial Phase #: 1 PDB3 Files: 5 Time: 30s
Restart Phase #: 2 PDB3 Files: 1 Time: 0s
Parallel Phase #: 3 PDB3 Files: 18 Time: 10s
Restart Phase #: 4 PDB3 Files: 1 Time: 0s
Serial Phase #: 5 PDB3 Files: 5 Time: 12s
Serial Phase #: 6 PDB3 Files: 1 Time: 7s
Serial Phase #: 7 PDB3 Files: 4 Time: 4s
Restart Phase #: 8 PDB3 Files: 1 Time: 0s
Parallel Phase #: 9 PDB3 Files: 62 Time: 37s
Restart Phase #:10 PDB3 Files: 1 Time: 0s
Serial Phase #:11 PDB3 Files: 1 Time: 9s
Restart Phase #:12 PDB3 Files: 1 Time: 0s
Parallel Phase #:13 PDB3 Files: 91 Time: 4s
Restart Phase #:14 PDB3 Files: 1 Time: 0s
Parallel Phase #:15 PDB3 Files: 111 Time: 8s
Restart Phase #:16 PDB3 Files: 1 Time: 0s
Serial Phase #:17 PDB3 Files: 3 Time: 0s
Restart Phase #:18 PDB3 Files: 1 Time: 0s
Parallel Phase #:19 PDB3 Files: 32 Time: 18s
Restart Phase #:20 PDB3 Files: 1 Time: 0s
Serial Phase #:21 PDB3 Files: 3 Time: 4s
Restart Phase #:22 PDB3 Files: 1 Time: 0s
Parallel Phase #:23 PDB3 Files: 23 Time: 91s
Restart Phase #:24 PDB3 Files: 1 Time: 0s
Parallel Phase #:25 PDB3 Files: 11 Time: 38s
Restart Phase #:26 PDB3 Files: 1 Time: 0s
Serial Phase #:27 PDB3 Files: 1 Time: 1s
Restart Phase #:28 PDB3 Files: 1 Time: 0s
Serial Phase #:30 PDB3 Files: 1 Time: 0s
Serial Phase #:31 PDB3 Files: 257 Time: 14s
Serial Phase #:32 PDB3 Files: 1 Time: 0s
Restart Phase #:33 PDB3 Files: 1 Time: 0s
Serial Phase #:34 PDB3 Files: 1 Time: 1s
Restart Phase #:35 PDB3 Files: 1 Time: 0s
Restart Phase #:36 PDB3 Files: 1 Time: 0s
Serial Phase #:37 PDB3 Files: 4 Time: 34s
Restart Phase #:38 PDB3 Files: 1 Time: 0s
Parallel Phase #:39 PDB3 Files: 13 Time: 61s
Restart Phase #:40 PDB3 Files: 1 Time: 0s
Parallel Phase #:41 PDB3 Files: 10 Time: 5s
Restart Phase #:42 PDB3 Files: 1 Time: 0s
Serial Phase #:43 PDB3 Files: 1 Time: 4s
Restart Phase #:44 PDB3 Files: 1 Time: 0s
Serial Phase #:45 PDB3 Files: 1 Time: 1s
Serial Phase #:46 PDB3 Files: 1 Time: 0s
Restart Phase #:47 PDB3 Files: 1 Time: 0s
Serial Phase #:48 PDB3 Files: 1 Time: 56s
Restart Phase #:49 PDB3 Files: 1 Time: 0s
Serial Phase #:50 PDB3 Files: 1 Time: 24s
Restart Phase #:51 PDB3 Files: 1 Time: 0s
Serial Phase #:52 PDB3 Files: 1 Time: 0s
Restart Phase #:53 PDB3 Files: 1 Time: 0s
Serial Phase #:54 PDB3 Files: 1 Time: 29s
Restart Phase #:55 PDB3 Files: 1 Time: 0s
Serial Phase #:56 PDB3 Files: 1 Time: 8s
Restart Phase #:57 PDB3 Files: 1 Time: 1s
Serial Phase #:58 PDB3 Files: 1 Time: 0s
Restart Phase #:59 PDB3 Files: 1 Time: 0s
Serial Phase #:60 PDB3 Files: 1 Time: 0s
Restart Phase #:61 PDB3 Files: 1 Time: 0s
Serial Phase #:62 PDB3 Files: 1 Time: 0s
Restart Phase #:63 PDB3 Files: 1 Time: 0s
Serial Phase #:64 PDB3 Files: 1 Time: 1s
Serial Phase #:65 PDB3 Files: 1 Calling sqlpatch with LD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/lib; export LD_LIBRARY_PATH; LIBPATH=/u01/app/oracle/product/12.1.0.2/lib; export LIBPATH; LD_LIBRARY_PATH_64=/u01/app/oracle/product/12.1.0.2/lib; export LD_LIBRARY_PATH_64; DYLD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/lib; export DYLD_LIBRARY_PATH; /u01/app/oracle/product/12.1.0.2/perl/bin/perl -I /u01/app/oracle/product/12.1.0.2/rdbms/admin -I /u01/app/oracle/product/12.1.0.2/rdbms/admin/../../sqlpatch /u01/app/oracle/product/12.1.0.2/rdbms/admin/../../sqlpatch/sqlpatch.pl -verbose -upgrade_mode_only -pdbs 'PDB3' > catupgrdpdb3_datapatch_upgrade.log 2> catupgrdpdb3_datapatch_upgrade.err
returned from sqlpatch
Time: 37s
Serial Phase #:66 PDB3 Files: 1 Time: 2s
Serial Phase #:68 PDB3 Files: 1 Time: 1s
Serial Phase #:69 PDB3 Files: 1 Calling sqlpatch with LD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/lib; export LD_LIBRARY_PATH; LIBPATH=/u01/app/oracle/product/12.1.0.2/lib; export LIBPATH; LD_LIBRARY_PATH_64=/u01/app/oracle/product/12.1.0.2/lib; export LD_LIBRARY_PATH_64; DYLD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0.2/lib; export DYLD_LIBRARY_PATH; /u01/app/oracle/product/12.1.0.2/perl/bin/perl -I /u01/app/oracle/product/12.1.0.2/rdbms/admin -I /u01/app/oracle/product/12.1.0.2/rdbms/admin/../../sqlpatch /u01/app/oracle/product/12.1.0.2/rdbms/admin/../../sqlpatch/sqlpatch.pl -verbose -pdbs 'PDB3' > catupgrdpdb3_datapatch_normal.log 2> catupgrdpdb3_datapatch_normal.err
returned from sqlpatch
Time: 47s
Serial Phase #:70 PDB3 Files: 1 Time: 72s
Serial Phase #:71 PDB3 Files: 1 Time: 5s
Serial Phase #:72 PDB3 Files: 1 Time: 4s
Serial Phase #:73 PDB3 Files: 1 Time: 0s
------------------------------------------------------
Phases [0-73] End Time:[2016_11_25 13:26:52]
Container Lists Inclusion:[PDB3] Exclusion:[NONE]
------------------------------------------------------
Grand Total Time: 689s PDB3
LOG FILES: (catupgrdpdb3*.log)
Upgrade Summary Report Located in:
/u01/app/oracle/product/12.1.0.2/cfgtoollogs/CDB2/upgrade/upg_summary.log
Total Upgrade Time: [0d:0h:11m:29s]
Time: 691s For PDB(s)
Grand Total Time: 691s
LOG FILES: (catupgrd*.log)
Grand Total Upgrade Time: [0d:0h:11m:31s]
SQL> alter session set container=PDB3;
Session altered.
SQL> startup
Pluggable Database opened.
SQL> @?/rdbms/admin/utlrp.sql
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2016-11-25 13:32:34
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
PL/SQL procedure successfully completed.
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2016-11-25 13:33:40
DOC> The following query reports the number of objects that have compiled
DOC> with errors.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
4 PDB3 READ WRITE NO
SQL> select name, cdb from v$database;
NAME CDB
--------------------------- ---------
UPGR NO
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup open read only;
ORACLE instance started.
Total System Global Area 826277888 bytes
Fixed Size 2929792 bytes
Variable Size 322964352 bytes
Database Buffers 494927872 bytes
Redo Buffers 5455872 bytes
Database mounted.
Database opened.
SQL> exec DBMS_PDB.DESCRIBE('/tmp/pbd1.xml');
PL/SQL procedure successfully completed.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> select name, cdb from v$database;
NAME CDB
--------------------------- ---------
CDB2 YES
SQL> DECLARE
2 compatible CONSTANT VARCHAR2(3) := CASE
3 DBMS_PDB.CHECK_PLUG_COMPATIBILITY( pdb_descr_file => '/tmp/pbd1.xml',
4 pdb_name => 'PDB1') WHEN TRUE THEN 'YES' ELSE 'NO'
5 END;
6 BEGIN
7 DBMS_OUTPUT.PUT_LINE(compatible);
8 END;
9 /
NO
PL/SQL procedure successfully completed.
SQL> select name,cause,type, status, message
from PDB_PLUG_IN_VIOLATIONS
where name='PDB1';
NAME CAUSE TYPE STATUS
---------- -------------------- ---------- ----------
MESSAGE
--------------------------------------------------------------------------------
PDB1 Non-CDB to PDB WARNING PENDING
PDB plugged in is a non-CDB, requires noncdb_to_pdb.sql be run.
PDB1 OPTION WARNING PENDING
Database option DV mismatch: PDB installed version NULL. CDB installed version
12.1.0.2.0.
PDB1 OPTION WARNING PENDING
Database option ORDIM mismatch: PDB installed version NULL. CDB installed
NAME CAUSE TYPE STATUS
---------- -------------------- ---------- ----------
MESSAGE
--------------------------------------------------------------------------------
version 12.1.0.2.0.
PDB1 OPTION WARNING PENDING
Database option SDO mismatch: PDB installed version NULL. CDB installed version
12.1.0.2.0.
PDB1 APEX WARNING PENDING
APEX mismatch: PDB installed version NULL CDB installed version 4.2.5.00.08
NAME CAUSE TYPE STATUS
---------- -------------------- ---------- ----------
MESSAGE
--------------------------------------------------------------------------------
PDB1 Parameter WARNING PENDING
CDB parameter processes mismatch: Previous 300 Current 200
PDB1 Parameter WARNING PENDING
CDB parameter sessions mismatch: Previous 472 Current 322
PDB1 Parameter WARNING PENDING
CDB parameter sga_target mismatch: Previous 788M Current 1000M
NAME CAUSE TYPE STATUS
---------- -------------------- ---------- ----------
MESSAGE
--------------------------------------------------------------------------------
PDB1 Parameter WARNING PENDING
CDB parameter compatible mismatch: Previous '12.1.0' Current '12.1.0.2.0'
PDB1 SQL patch error ERROR PENDING
(PSU bundle patch 5 (Database Patch Set Update : 12.1.0.2.5 (21359755)): APPLY SUCCESS): with status in the PDB.
PDB1 SQL patch error ERROR PENDING
(SQL patch ID/UID 21539301/19298399 (): APPLY SUCCESS): with status in the PDB.
NAME CAUSE TYPE STATUS
---------- -------------------- ---------- ----------
MESSAGE
--------------------------------------------------------------------------------
PDB1 SQL Patch ERROR PENDING
PSU bundle patch 5 (Database Patch Set Update : 12.1.0.2.5 (21359755)):
Installed in the CDB but not in the PDB.
PDB1 SQL Patch ERROR PENDING
SQL patch ID/UID 21539301/19298399 (): Installed in the CDB but not in the PDB.
13 rows selected.
SQL> create pluggable database PDB1 using '/tmp/pbd1.xml' nocopy tempfile reuse;
Pluggable database created.
SQL> alter session set container=PDB1;
Session altered.
SQL> @?/rdbms/admin/noncdb_to_pdb.sql
SQL> SET SERVEROUTPUT ON
SQL> SET FEEDBACK 1
SQL> SET NUMWIDTH 10
SQL> SET LINESIZE 80
SQL> SET TRIMSPOOL ON
SQL> SET TAB OFF
SQL> SET PAGESIZE 100
SQL>
SQL> WHENEVER SQLERROR EXIT;
SQL>
SQL> DOC
DOC>#######################################################################
DOC>#######################################################################
DOC> The following statement will cause an "ORA-01403: no data found"
DOC> error if we're not in a PDB.
DOC> This script is intended to be run right after plugin of a PDB,
DOC> while inside the PDB.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL>
SQL> VARIABLE cdbname VARCHAR2(128)
SQL> VARIABLE pdbname VARCHAR2(128)
SQL> BEGIN
2 SELECT sys_context('USERENV', 'CDB_NAME')
3 INTO :cdbname
4 FROM dual
5 WHERE sys_context('USERENV', 'CDB_NAME') is not null;
6 SELECT sys_context('USERENV', 'CON_NAME')
7 INTO :pdbname
8 FROM dual
9 WHERE sys_context('USERENV', 'CON_NAME') <> 'CDB$ROOT';
10 END;
11 /
PL/SQL procedure successfully completed.
SQL>
SQL> COLUMN pdbname NEW_VALUE pdbname
SQL> COLUMN pdbid NEW_VALUE pdbid
SQL>
SQL> select :pdbname pdbname from dual;
PDBNAME
--------------------------------------------------------------------------------
PDB1
1 row selected.
(중간생략)
SQL> alter session set container = "&pdbname";
Session altered.
SQL> -- leave the PDB in the same state it was when we started
SQL> BEGIN
2 execute immediate '&open_sql &restricted_state';
3 EXCEPTION
4 WHEN OTHERS THEN
5 BEGIN
6 IF (sqlcode <> -900) THEN
7 RAISE;
8 END IF;
9 END;
10 END;
11 /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> WHENEVER SQLERROR CONTINUE;
SQL> startup
Pluggable Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 PDB1 READ WRITE NO
1 | CPU |
2 | 세션 |
3 | 병렬 서버 프로세스 |
4 | 시스템상의 PDB와 CDB 간의 DISK I/O 리소스(엑사데이터인 경우) |
1 | MYPDB | 2 share |
2 | ORCL | 1 share |
3 | YOURPDB | 1 share |
1 | CDB를 시작할 권한을 가진 유저 계정으로만 CDB 루트 컨테이너로 접속할 수 있다. |
2 | PDB는 CDB가 오픈될 때 마운트 된다. |
3 | startup 명령의 startup open recover란 새로운 옵션은 데이터베이스를 자동으로 recovery 모드로 시작하고 오픈한다. |
1 | CDB_PDBS 또는 DBA_PDBS 뷰는 PDB에 대한 name, status 등의 정보를 제공한다. |
2 | V$CONTAINERS 뷰는 컨테이너의 opent_mode와 기타 정보를 제공한다. |
3 | V$PDBS 뷰는 개별적인 PDB가 언제 오픈되었는지, 현재 open_mode, restriced세션 모드로 열렸는지에 대한 정보를 제공한다. |
4 | CDB_PDB_HISTORY는 PDB에 대한 이력 정보를 제공한다. |
1 | CON_NAME_TO_ID | 컨테이너명을 입력해서 컨테이너 ID를 반환 |
2 | CON_DBID_TO_ID | 컨테이너 DBID를 입력해서 컨테이너 ID를 반환 |
3 | CONTAINER_UID_TO_ID | CONTAINER_UID를 입력해서 컨테이너 ID를 반환 |
4 | CONTAINER_GUID_TO_ID | CONTAINER_GUID를 입력해서 컨테이너 ID를 반환 |
1 | startup force | PDB 셧다운 이후에 재시작한다. |
2 | startup restrict | PDB를 제한 세션 모드로 시작한다. restricted session 권한을 가진 유저만이 데이터베이스로 접속이 가능하다. |
3 | startup, startup open | 데이터베이스 시작. READ WRITE(디폴트) 또는 READ ONLY 모드(startup open read only) 모드가 가능하다. |
4 | shutdown | PDB를 모든 세션이 연결이 종료된 이후에 일관성 있게 close한다. |
5 | shutdown immediate | active 상태이거나 실행 중인 세션을 kill시키고 일관성 있는 모드로 PDB를 종료시킨다. |
6 | shutdown abort | PDB를 비일관성 상태로 셧다운시킨다. |
7 | shutdown transactional | 진행 중인 트랜잭션이 종료되기를 기다렸다가 PDB를 종료한다. |
SQL> SHOW PDBS
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
4 PDB3 READ WRITE NO
SQL> alter pluggable database PDB1 open;
Pluggable database altered.
SQL>
SQL>
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 PDB3 READ WRITE NO
SQL>
SQL> alter pluggable database default tablesapce pdb_tbs;
SQL> alter pluggable database default temporary tablesapce pdb_temp_tbs;
SQL> alter pluggable database storage(maxsize 2g);
SQL> alter pluggable database storage(maxsize unlimited);
1 | alter system flush shared_pool |
2 | alter system flush buffer_cache |
3 | alter system enable restricted session |
4 | alter system disable restricted session |
5 | alter system set use_stored_outlines |
6 | alter system resume |
7 | alter system check datafiles |
8 | alter system kill session |
9 | alter system set initialization_parameter |
10 | alter system suspend |
11 | alter system checkpoint |
12 | alter system register |
13 | alter system disconnect session |
1 | 아카이브 로그 백업, 삭제, 복원에 관련된 non-media 복구 |
2 | Point-in-time 복구 |
3 | 테이블 스페이스 Point-in-time 복구 |
4 | 복구 카탈로그 접속 |
5 | Report/Delete obsolete |
6 | configure 명령을 통한 RMAN 설정 변경 |
7 | reset database |
8 | import catalog |
9 | register database |
10 | Data Recovery Adviser |
11 | RMAN에서의 플래시백 작업 |
12 | duplicate 데이터베이스 |
13 | Table 복구 |