Multitenant 아키텍쳐


데이터베이스 상태와 버전 정보를 확인합니다
.

 

[oracle@New-Features-12c ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 12.1.0.2.0 Production on Fri Aug 7
07:51:06 2015

 

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> select instance_name,status from
v$instance;

 

INSTANCE_NAME    STATUS

—————- ————

CDB1             OPEN

 

SQL> set lines 100

SQL> select * from v$version;

 

BANNER                                                                               CON_ID

——————————————————————————–
———-

Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 – 64bit Production              0

PL/SQL Release 12.1.0.2.0 – Production                                                    0

CORE    12.1.0.2.0      Production                                                        0

TNS for Linux: Version 12.1.0.2.0 – Production                                            0

NLSRTL Version 12.1.0.2.0 – Production                                                    0

 

Listener 상태를 확인합니다. 서비스가 기동되어 있고 해당 인스턴스가 “READY” 인 것을 확인합니다.

 

SQL> !lsnrctl status

 

LSNRCTL for Linux: Version 12.1.0.2.0 – Production on
12-AUG-2015 05:07:01

 

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

 

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=New-Features-12c.compute-kroracleko58578.oraclecloud.internal)(PORT=1521)))

STATUS of the LISTENER

————————

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 12.1.0.2.0 – Production

Start Date                12-AUG-2015 00:47:44

Uptime                    0 days 4 hr. 19 min. 17 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/New-Features-12c/listener/alert/log.xml

Listening Endpoints Summary…

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=New-Features-12c.compute-kroracleko58578.oraclecloud.internal)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=New-Features-12c.compute-kroracleko58578.oraclecloud.internal)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0/dbhome_1/admin/CDB1/xdb_wallet))(Presentation=HTTP)(Session=RAW))

Services Summary…

Service “CDB1.kroracleko58578.oraclecloud.internal” has
1 instance(s).

  Instance “CDB1”, status READY, has
1 handler(s) for this service…

Service “CDB1XDB.kroracleko58578.oraclecloud.internal”
has 1 instance(s).

  Instance “CDB1”, status READY, has
1 handler(s) for this service…

Service “pdb1.kroracleko58578.oraclecloud.internal” has
1 instance(s).

  Instance “CDB1”, status READY, has
1 handler(s) for this service…

The command completed successfully

 

현재 생성되어 있는 서비스 목록도 확인합니다.

 

SQL> set lines 120

SQL> col name for a80

SQL> select name,con_id from v$services;

 

NAME                                                                                 CON_ID

——————————————————————————–
———-

pdb1.kroracleko58578.oraclecloud.internal                                                 3

CDB1XDB                                                                                   1

CDB1.kroracleko58578.oraclecloud.internal                                                 1

SYS$BACKGROUND                                                                            1

SYS$USERS                                                                                 1

 

CON_ID 칼럼 값이 의미하는 바는 아래와 같습니다.

 

Value in CON_ID Column

Description

0

The data pertains to the entire CDB

1

The data pertains to the root

2

The data pertains to the seed

3-254

The data pertains to a PDB. Each PDB has its own
Container ID

 

생성되어 있는PDB목록을 확인합니다. SHOW 명령으로도 확인 할 수 있습니다.

 

SQL> set lines 120

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

 

    CON_ID NAME                           OPEN_MODE

———- ——————————
———-

         2 PDB$SEED                       READ ONLY

         3 PDB1                           READ WRITE

 

SQL> show pdbs

 

    CON_ID CON_NAME                       OPEN
MODE  RESTRICTED

———- —————————— ———-
———-

         2 PDB$SEED                       READ ONLY  NO

         3 PDB1                           READ WRITE NO

 

SHOW 명령으로 현재 접속한 컨테이너 데이터베이스 이름과ID를 확인합니다. SYS_CONTEXT 함수로도 확인할 수 있습니다.

 

SQL> show con_name

 

CON_NAME

——————————

CDB$ROOT

SQL> show con_id

 

CON_ID

——————————

1

 

SQL> select sys_context(‘userenv’,’con_name’) from
dual;

 

SYS_CONTEXT(‘USERENV’,’CON_NAME’)

———————————————————————————————

CDB$ROOT

 

SQL> select sys_context(‘userenv’,’con_id’) from
dual;

 

SYS_CONTEXT(‘USERENV’,’CON_ID’)

———————————————————————————————

1

 

CDBredo log filecontrol file 구조를 확인합니다. redo log filecontrol file Root 컨테이너나 특정 PDB가 아닌 전체 CDB 소속임을 알 수 있습니다.

 

SQL> col member for a50

SQL> select group#,con_id,member from
v$logfile;

 

    GROUP#     CON_ID MEMBER

———- ———-
————————————————–

         3          0 /u04/app/oracle/redo/redo03.log

         2          0 /u04/app/oracle/redo/redo02.log

         1          0 /u04/app/oracle/redo/redo01.log

 

SQL> col name for a60

SQL> select name,con_id from v$controlfile;

 

NAME                                                             CON_ID

————————————————————
———-

/u02/app/oracle/oradata/CDB1/control01.ctl                            0

/u03/app/oracle/fast_recovery_area/CDB1/control02.ctl                 0

 

 

CDB의 데이터파일 구조를 확인합니다. CDB_* View를 통해PDB포함 전체 데이터파일 정보를 확인합니다.

 

SQL> col file_id for 99999

SQL> col con_id for 99999

SQL> select file_name,tablespace_name,file_id,con_id from
cdb_data_files order by 4;

 

FILE_NAME                                                    TABLESPACE FILE_ID CON_ID

————————————————————
———- ——- ——

/u02/app/oracle/oradata/CDB1/system01.dbf                    SYSTEM           1      1

/u02/app/oracle/oradata/CDB1/sysaux01.dbf                    SYSAUX           3      1

/u02/app/oracle/oradata/CDB1/undotbs01.dbf                   UNDOTBS1         4      1

/u02/app/oracle/oradata/CDB1/users01.dbf                     USERS            6      1

/u02/app/oracle/oradata/CDB1/PDB1/system01.dbf               SYSTEM          12      3

/u02/app/oracle/oradata/CDB1/PDB1/example01.dbf              EXAMPLE         15      3

/u02/app/oracle/oradata/CDB1/PDB1/SAMPLE_SCHEMA_users01.dbf  USERS           14      3

/u02/app/oracle/oradata/CDB1/PDB1/sysaux01.dbf               SYSAUX          13      3

 

8 rows selected.

 

이번에는DBA_*  View를 통해 데이터파일 정보를 확인해 봅니다. Root 컨테이너의 데이터파일 정보만 나오는 것을 알 수 있습니다.

 

SQL> select file_name,tablespace_name,file_id from
dba_data_files;

 

FILE_NAME                                                    TABLESPACE FILE_ID

————————————————————
———- ——-

/u02/app/oracle/oradata/CDB1/system01.dbf                    SYSTEM           1

/u02/app/oracle/oradata/CDB1/sysaux01.dbf                    SYSAUX           3

/u02/app/oracle/oradata/CDB1/undotbs01.dbf                   UNDOTBS1         4

/u02/app/oracle/oradata/CDB1/users01.dbf                     USERS            6

 

V$~ View에서는 모든PDB들의 정보가 출력됩니다. 컨테이너별 테이블스페이스 이름은 동일하더라도 해당 데이터파일의 file# 는 다른 것을 알 수 있습니다.

 

SQL> col name for a20

SQL> select a.file#, b.name, b.ts#, b.con_id from v$datafile
a, v$tablespace b where a.ts# = b.ts# and a.con_id = b.con_id order by
4,3;

 

     FILE#
NAME                        TS# CON_ID

———- ——————– ———-
——

         1 SYSTEM                        0      1

         3 SYSAUX                        1      1

         4 UNDOTBS1                      2      1

         6 USERS                         4      1

         5 SYSTEM                        0      2

         7 SYSAUX                        1      2

        16 USERS                         3      2

        12 SYSTEM                        0      3

        13 SYSAUX                        1      3

        14 USERS                         3      3

        15
EXAMPLE                       4      3

 

11 rows selected.

 

CDBtemp file 구조를 확인합니다. 컨테이너마다temp file을 별도로도 가질 수 있음을 알 수 있습니다.

 

SQL> select file_name,tablespace_name,file_id from
cdb_temp_files;

 

FILE_NAME                                                    TABLESPACE
FILE_ID

————————————————————
———- ——-

/u02/app/oracle/oradata/CDB1/temp01.dbf                      TEMP             1

/u02/app/oracle/oradata/CDB1/PDB1/PDB1_temp012015-08-12_01-1
TEMP             3

5-39-AM.dbf

 

 

SYSTEM 유저가 어떻게 생성되어 있는 지 확인합니다. SYSTEM 유저와 같이 모든 컨테이너에 존재하는 유저를Common User라고 합니다.

 

SQL> col username for a30

SQL> select username,common,con_id from cdb_users where
username = ‘SYSTEM’;

 

USERNAME                       COM CON_ID

—————————— — ——

SYSTEM                         YES      1

SYSTEM                         YES      3

 

현재CDB에 생성된 모든Common User를 확인해 봅니다.

 

SQL> set pages 100

SQL> select distinct username from cdb_users where
common = ‘YES’;

 

USERNAME

——————————

DVF

APEX_040200

MDSYS

FLOWS_FILES

GSMUSER

AUDSYS

DVSYS

OJVMSYS

APPQOSSYS

C##DBAAS_MONITOR

WMSYS

LBACSYS

ANONYMOUS

SI_INFORMTN_SCHEMA

C##PDBMGR

SPATIAL_WFS_ADMIN_USR

SYSBACKUP

CTXSYS

OUTLN

ORACLE_OCM

APEX_REST_PUBLIC_USER

GSMADMIN_INTERNAL

MDDATA

APEX_PUBLIC_USER

ORDDATA

SYSDG

SYSKM

XS$NULL

DIP

APEX_LISTENER

SPATIAL_CSW_ADMIN_USR

OLAPSYS

SYSTEM

ORDSYS

DBSNMP

ORDPLUGINS

GSMCATUSER

XDB

SYS

 

39 rows selected.

 

Local User는 어떤 것이 있는 지 확인합니다. Root 컨테이너에는Local User 생성이 불가합니다.

 

SQL> select distinct username,con_id from cdb_users where
common = ‘NO’;

 

USERNAME                       CON_ID

—————————— ——

DBAAS_MONITOR                       3

SH                                  3

PDBADMIN                            3

HR                                  3

OE                                  3

SCOTT                               3

PM                                  3

BI                                  3

IX                                  3

 

9 rows selected.

 

 

CDB 의 Role 구조를 확인합니다. Root 컨테이너에는Local Role 생성이 불가합니다.

 

SQL> col role for a50

SQL> select role,common,con_id from
cdb_roles;

 

ROLE                                               COM CON_ID

————————————————– —
——

CONNECT                                            YES      1

RESOURCE                                           YES      1

DBA                                                YES      1

AUDIT_ADMIN                                        YES      1

:

:

:

DV_DATAPUMP_NETWORK_LINK                           YES      3

DV_REALM_RESOURCE                                  YES      3

DV_REALM_OWNER                                     YES      3

 

168 rows selected.

 

 

Privilege 구조를 확인합니다. Privilege의 경우, Common 또는Local의 구분이 없기 때문에 관련 딕셔너리뷰에COMMON 칼럼이 없습니다.

 

SQL> desc sys.system_privilege_map

 Name                                      Null?    Type

 —————————————– ——–
—————————-

 PRIVILEGE                                 NOT NULL NUMBER

 NAME                                      NOT NULL VARCHAR2(40)

 PROPERTY                                  NOT NULL NUMBER

 

SQL> desc sys.table_privilege_map

 Name                                      Null?    Type

 —————————————– ——–
—————————-

 PRIVILEGE                                 NOT NULL NUMBER

 NAME                                      NOT NULL VARCHAR2(40)

 

 

Privilege 자체는Common 또는Local 구분이 없으나, Privilege가 부여될 때는 그 구분이 있습니다. 아래system Privilege, object privilege 관련 뷰에는COMMON 칼럼이 있는 것을 확인할 수 있습니다.

 

SQL> desc cdb_sys_privs

 Name                                      Null?    Type

 —————————————– ——–
—————————-

 GRANTEE                                            VARCHAR2(128)

 PRIVILEGE                                          VARCHAR2(40)

 ADMIN_OPTION                                       VARCHAR2(3)

 COMMON                                             VARCHAR2(3)

 CON_ID                                             NUMBER

 

SQL> desc cdb_tab_privs

 Name                                      Null?    Type

 —————————————– ——–
—————————-

 GRANTEE                                            VARCHAR2(128)

 OWNER                                              VARCHAR2(128)

 TABLE_NAME                                         VARCHAR2(128)

 GRANTOR                                            VARCHAR2(128)

 PRIVILEGE                                          VARCHAR2(40)

 GRANTABLE                                          VARCHAR2(3)

 HIERARCHY                                          VARCHAR2(3)

 COMMON                                             VARCHAR2(3)

 TYPE                                               VARCHAR2(24)

 CON_ID                                             NUMBER

 

아래 쿼리에서 알 수 있듯이ROLE COMMON 또는LOCAL 속성으로 부여될 수 있습니다.

 

SQL> set lines 120

SQL> col grantee for a30

SQL> col granted_role for a40

SQL> select grantee,granted_role,common,con_id from
cdb_role_privs where grantee=’SYSTEM’;

 

GRANTEE                        GRANTED_ROLE                             COM     CON_ID

——————————
—————————————- — ———-

SYSTEM                         DBA                                      YES          1

SYSTEM                         AQ_ADMINISTRATOR_ROLE                    YES          1

SYSTEM                         DBA                                      YES          3

SYSTEM                         AQ_ADMINISTRATOR_ROLE                    YES          3

 

SQL> exit

Disconnected from 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

 

By haisins

오라클 DBA 박용석 입니다. haisins@gmail.com 으로 문의 주세요.

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다