iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >Oracle 12c CDB&PDBs管理
  • 527
分享到

Oracle 12c CDB&PDBs管理

2024-04-02 19:04:59 527人浏览 泡泡鱼
摘要

本文摘取Database Administrator’s Guide(12.1.0.2)中40,42等章节部分内容,概括介绍管理CDB、PDBs任务。摘取翻译的内容侧重操作和实例,详细内容请参考官方文档:

本文摘取Database Administrator’s Guide(12.1.0.2)中40,42等章节部分内容,概括介绍管理CDB、PDBs任务。摘取翻译的内容侧重操作和实例,详细内容请参考官方文档:

40  Administering a CDB with sql*Plus

https://docs.oracle.com/database/121/ADMIN/cdb_admin.htm#ADMIN13606

42  Administering PDBs with SQL*Plus

Https://docs.oracle.com/database/121/ADMIN/cdb_pdb_admin.htm#ADMIN13663

1.    CDB 管理任务

Table 40-1 Administrative Tasks Common to CDBs and Non-CDBs

Task

Description

Starting up a CDB instance

To start a CDB instance, the current user must be a common   user whose current container is the root.

When you open a CDB, its PDBs are mounted. Use the  ALTER   PLUGGABLE   DATABASE statement   to modify the open mode of one or more PDBs.

Managing processes

A CDB has one set of background processes shared by the root   and all PDBs.

Managing memory

A CDB has a single system global area (SGA) and a single   aggregate program glob

al area (PGA). The memory required by a CDB is the sum   of the memory requirements for all of the PDBs that will be part of the CDB.

Managing security

You can create and drop common users and local users in a CDB.   You can also grant privileges to and revoke privileges from these users. You   can also manage the  CONTAINER_DATA  attributes   of common users.

In addition, grant the following roles to the appropriate   users:

·           Grant the  CDB_DBA  role   to CDB administrators.

·           Grant the  PDB_DBA  role   to PDB administrators.

Monitoring errors and alerts

A CDB has one alert log for the entire CDB. The name of a PDB   is included in records in trace files, when appropriate.

Managing diagnostic data

In a CDB, you can use the Oracle Database fault diagnosability   infrastructure and the Automatic Diagnostic Repository (ADR).

Managing control files

A CDB has one control file.

Managing the online redo log and the arcHived redo log files

A CDB has one online redo log and one set of archived redo log   files.

Managing tablespaces

You can create, modify, and drop tablespaces and temporary   tablespaces for the root and for individual PDBs. You can also specify a   default tablespace, default tablespace type, and a default temporary   tablespace for the root. The root has its own set of Oracle-supplied tablespaces,   such as the  SYSTEM  tablespace,   and each PDB has its own set of Oracle-supplied tablespaces.

Managing data files and temp files

The root has its own data files, and each PDB has its own data   files. In a CDB, you can manage data files and temp files in basically the   same way you would manage them for a non-CDB. However, the following   exceptions apply to CDBs:

·           You can limit the amount of   storage used by the data files for a PDB by using the  STORAGE  clause   in a  CREATE   PLUGGABLE   DATABASE  or  ALTER   PLUGGABLE   DATABASE statement.

·           There is a default temporary   tablespace for the root and for each PDB.

Managing undo

There is one active undo tablespace for a single-instance CDB.   For an Oracle RAC CDB, there is one active undo tablespace for each instance.   In a CDB, the  UNDO_MANAGEMENT initialization   parameter must be set to  AUTO ,   and an undo tablespace is required to manage the undo data.

Only a common user who has the appropriate privileges and   whose current container is the root can create an undo tablespace. Undo   tablespaces are visible in static data dictionary views and dynamic   perfORMance (V$) views when the current container is the root. Undo   tablespaces are visible only in dynamic performance views when the current   container is a PDB. When the current container is a PDB, an attempt to create   an undo tablespace fails without returning an error.

Moving data between PDBs

You can move data between PDBs using the same methods that you   would use to move data between non-CDBs. For example, you can transport the   data or use Data Pump export/import to move the data.

Using Oracle Managed Files

Using Oracle Managed files can simplify administration for   both a CDB and a non-CDB.

Using Transparent Data Encryption

Transparent Data Encryption is a feature that enables   encryption of individual table columns before storing them in the data file,   or enables encryption of entire tablespaces. In a CDB, each PDB has its own   master key for Transparent Data Encryption, and, where applicable, the  ADMINISTER   KEY   MANAGEMENT  SQL   statement enables key management at the CDB level and for individual PDBs.

Using a standby database

Oracle Data Guard can configure a physical standby or a   logical standby of a CDB. Data Guard operates on the entire CDB, not on   individual PDBs.

Using Oracle Database Vault

Oracle Database Vault policies are scoped to individual PDBs.

Dropping a database

When you drop a CDB, the root, seed, and all of its PDBs   (including their data) are also dropped.

You can also drop individual PDBs with the  DROP   PLUGGABLE   DATABASE  statement.

 

2.    CDB 中的可管理特性

Table 40-2 Manageability Features in a CDB

Manageability Feature

Data Location

Data Visibility

Active Session History (ASH)

ASH collects information about active database sessions. You   can use this information to analyze and identify performance issues.

Most of the ASH data is stored in memory. A small percentage   of the ASH data samples are stored in the root.

ASH data related to a PDB is not included if the PDB is   unplugged.

A common user whose current container is the root can view ASH   data for the root and for PDBs.

A user whose current container is a PDB can view ASH data for   the PDB only.

Alerts

An alert is a notification of a possible problem.

Threshold settings that pertain to a PDB are stored in the   PDB.

Alerts posted when thresholds are violated are enqueued into   the alert queue in the root.

Threshold settings that pertain to a PDB are included if the   PDB is unplugged. Alerts related to a PDB are not included if the PDB is   unplugged.

A common user whose current container is the root can view   alerts for the root and for PDBs.

A user whose current container is a PDB can view alert   thresholds and alerts for the PDB only.

Automated Database Maintenance Tasks

Automated database maintenance tasks are tasks that are   started automatically at regular intervals to perform maintenance operations   on the database. Automated tasks include automatic optimizer statistics   collection, Automatic Segment Advisor tasks, and Automatic SQL Tuning Advisor   tasks.

A user can schedule maintenance windows and enable or disable   maintenance tasks for the current container only. If the current container is   the root, then the changes only apply to the root. If the current container   is a PDB, then the changes only apply to the PDB.

Data related to a PDB is stored in the PDB for automatic   optimizer statistics collection and the Automatic Segment Advisor. This data   is included if the PDB is unplugged.

Automatic SQL Tuning Advisor runs only in the root. See the   SQL Tuning Advisor row in this table for information about data collected by   Automatic SQL Tuning Advisor.

See the appropriate row in this table for data visibility   information about the following manageability features: automatic optimizer   statistics collection, Automatic Segment Advisor, and Automatic SQL Tuning   Advisor.

Automatic Database Diagnostic Monitor (ADDM)

ADDM can diagnose a database's performance and determine how   identified problems can be resolved.

All ADDM runs must be performed in the root. All ADDM results   are stored in the root.

ADDM analyzes activity in a PDB within the context of the   current analysis target. ADDM does not analyze one PDB at a time. As in   previous releases, ADDM runs with a target of either the entire instance or   Oracle RAC database.

ADDM results related to a PDB are not included if the PDB is   unplugged.

ADDM results are visible only to a common user whose current   container is the root. The ADDM results can include information about   multiple PDBs. The ADDM results cannot be viewed when the current container   is a PDB.

Automatic Optimizer Statistics Collection

Automatic optimizer statistics collection gathers optimizer   statistics for all schema objects in the database for which there are no   statistics or only stale statistics. The statistics gathered by this task are   used by the SQL query optimizer to improve the performance of SQL execution.

When an automatic optimizer statistics collection task gathers   data for a PDB, it stores this data in the PDB. This data is included if the   PDB is unplugged.

A common user whose current container is the root can view   optimizer statistics data for PDBs.

A user whose current container is a PDB can view optimizer   statistics data for the PDB only.

Automatic Segment Advisor

The Automatic Segment Advisor identifies segments that have   space available for reclamation and makes recommendations on how to   defragment those segments.

When Automatic Segment Advisor gathers data for a PDB, it   stores this data in the PDB. This data is included if the PDB is unplugged.

A common user whose current container is the root can view   Automatic Segment Advisor data for PDBs.

A user whose current container is a PDB can view the Automatic   Segment Advisor data for the PDB only.

Automatic Workload Repository (AWR)

The AWR collects, processes, and maintains performance   statistics for problem detection and self-tuning purposes. This data is   stored in the database. The gathered data can be displayed in both reports   and views.

AWR data is stored in the root.

AWR data related to a PDB is not included if the PDB is   unplugged.

A common user whose current container is the root can view AWR   data for the root and for PDBs.

A user whose current container is a PDB can view AWR data for   the PDB only.

Database Replay

Database Replay is a feature of Oracle Real Application   Testing. Database Replay captures the workload for a database and replays it   exactly on a test database.

Information about database captures and replays are stored in   the root.

A common user whose current container is the root can view   database capture and replay information.

SQL Management Base (SMB)

SMB stores statement logs, plan histories, SQL plan baselines,   and SQL profiles in the data dictionary.

SMB data related to a PDB is stored in the PDB. The SMB data   related to a PDB is included if the PDB is unplugged.

A common user whose current container is the root can view SMB   data for PDBs.

A user whose current container is a PDB can view the SMB data   for the PDB only.

SQL Performance Analyzer (SPA)

SPA can analyze the SQL performance impact of SQL tuning and   other system changes. SPA is often used with Database Replay.

A common user whose current container is the root can run SPA   for any PDB. In this case, the SPA results data is stored in the root and is   not included if the PDB is unplugged.

A user whose current container is a PDB can run SPA on the   PDB. In this case, the SPA results data is stored in the PDB and is included   if the PDB is unplugged.

A common user whose current container is the root can view SPA   results data for PDBs.

A user whose current container is a PDB can view the SPA   results data for the PDB only.

SQL Tuning Sets (STS)

An STS is a database object that includes one or more SQL   statements along with their execution statistics and execution context, and   could include a user priority ranking.

You can use an STS to tune a group of SQL statements or test   their performance using SPA.

An STS can be stored in the root or in any PDB. If it is   stored in the root, then you can load SQL statements from any PDB into it.

When a PDB is unplugged, an STS stored in the root is not   included, even if the STS contains SQL statements from the PDB.

When a PDB is unplugged, an STS stored in the PDB is included.

A common user whose current container is the root can view STS   data stored in the root only.

A user whose current container is a PDB can view STS data for   the PDB only.

SQL Tuning Advisor

SQL Tuning Advisor optimizes SQL statements that have been   identified as high-load SQL statements.

Automatic SQL Tuning Advisor data is stored in the root. It   might have results about SQL statements executed in a PDB that were analyzed   by the advisor, but these results are not included if the PDB is unplugged.

A common user whose current container is the root can run SQL   Tuning Advisor manually for SQL statements from any PDB. When a statement is   tuned, it is tuned in any container that runs the statement.

A user whose current container is a PDB can also run SQL   Tuning Advisor manually for SQL statements from the PDB. When SQL Tuning   Advisor is run manually from a PDB, the results are stored in the PDB from   which it is run. In this case, a statement is tuned only for the current PDB,   and the results related to a PDB are included if the PDB is unplugged.

When SQL Tuning Advisor is run automatically, the results are   visible only to a common user whose current container is the root. These   results cannot be viewed when the current container is a PDB.

When SQL Tuning Advisor is run manually by a user whose   current container is a PDB, the results are only visible to a user whose   current container is that PDB.

 

3.    管理数据库对象

在 CDB 中,不同的容器可以包含不同的数据库对象。

Oracle 数据库存储数据库对象,如表、索引和目录。属于模式的数据库对象称为模式对象,而不属于模式的数据库对象称为非模式对象。 root 和 PDBs 包含模式,模式包含模式对象。 root 和 PDBs 还可以包含非模式对象,比如用户、角色、表空间、目录和版本。

在 CDB 中, root 包含 oracle 提供的模式和数据库对象。 oracle 提供的 Common User ,如 SYS 和 SYSTEM ,拥有这些模式和公共数据库对象。它们还可以拥有 root 和 PDB 中的本地对象。

您可以在 root 中创建 Common User 来管理 CDB 中的容器。用户创建的 Common User 可以在 root 中创建数据库对象。 Oracle 建议,在 root 中,由用户创建的 Common User 拥有的模式只包含数据库触发器及其定义中使用的对象。用户创建的 Common User 还可以拥有 PDB 中的任何类型的本地对象。

您可以在 PDB 中创建 Local User 。 PDB 中的 Local User 可以在 PDB 中创建模式对象和非模式对象。不能在 root 中创建 Local User 。

CDB 中的名称解析类似于非 CDB 中的名称解析,只不过名称是在用户当前容器的字典上下文中解析的。

4.    SQL*PLUS 访问容器的方法


#本地连接到root

sqlplus /nolog

connect system

connect / as sysdba


#通过服务名连接到root

connect C##dba@mycdb

 


#连接到pdbs

CONNECT sh@salespdb

CONNECT system@salespdb


#切换容器

ALTER SESSION SET CONTAINER = container_name

ALTER SESSION SET CONTAINER = CDB$ROOT;

ALTER SESSION SET CONTAINER = PDB$SEED;

ALTER SESSION SET CONTAINER = salespdb;

 

5.    跨容器执行 CODE: DBMS_SQL

DECLARE

  c1 INTEGER;

  rowcount INTEGER;

  taskList VARCHAR2(32767) :=

    'DECLARE

      PRAGMA AUTONOMOUS TRANSACTION;

     BEGIN

       -- Create the hr.identact table.

       EXECUTE IMMEDIATE

         ''CREATE TABLE hr.identact

             (actionno NUMBER(4) NOT NULL,

              action VARCHAR2 (10))'';

       EXECUTE IMMEDIATE

         ''INSERT INTO identact VALUES(1, 'ACTION1')'';

       -- A commit is required if the tasks include DML.

       COMMIT;

       EXCEPTION

         WHEN OTHERS THEN

           -- If there are errors, then drop the table.

           BEGIN

             EXECUTE IMMEDIATE ''DROP TABLE identact'';

           EXCEPTION

            WHEN OTHERS THEN

              NULL;

            END;

        END;';

  TYPE containerListType IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER;

  containerList  containerListType;

BEGIN

  containerList(1) := 'PDB1';

  containerList(2) := 'PDB2';

  c1 := DBMS_SQL.OPEN_CURSOR;

  FOR conIndex IN containerList.first..containerList.last LOOP

    DBMS_OUTPUT.PUT_LINE('Creating in container: ' || containerList(conIndex));

    DBMS_SQL.PARSE(c => c1 ,

                   statement => taskList,

                   language_flag => DBMS_SQL.NATIVE,

                   edition= > NULL,

                   apply_crossedition_trigger => NULL,

                   fire_apply_trigger => NULL,

                   schema => 'HR',

                   container => containerList(conIndex));

     rowcount := DBMS_SQL.EXECUTE(c=>c1);

  END LOOP;

  DBMS_SQL.CLOSE_CURSOR(c=>c1);

END;

/

6.    CDB&PDBs 管理操作

Ø   CDB 管理任务

管理 CDB 的操作通过 alter database ,对于不同 container 有不同的 clause ,大体可以分三部分,一是对整个 CDB 的修改操作,二是仅对 root 的修改操作,三是对 1 个或多个 PDB 的操作;详解见下表:

Table 40-3 Statements That Modify Containers in a CDB

Modify Entire CDB

Modify Root Only

Modify One or More PDBs

When connected as a common user whose current container is the   root,  ALTER   DATABASE  statements   with the following clauses modify the entire CDB:

·           startup_clauses

·           recovery_clauses

·           logfile_clauses

·           controlfile_clauses

·           standby_database_clauses

·           instance_clauses

·           security_clause

·           RENAME   GLOBAL_NAME  clause

·           ENABLE   BLOCK   CHANGE   TRACKING  clause

·           DISABLE   BLOCK   CHANGE   TRACKING  clause

When connected as a common user whose current container is the   root,  ALTER   DATABASE  statements   with the following clauses modify the root only:

·           database_file_clauses

·           DEFAULT   EDITION  clause

·           DEFAULT   TABLESPACE  clause

ALTER   DATABASE  statements   with the following clauses modify the root and set default values for PDBs:

·           DEFAULT   TEMPORARY   TABLESPACE  clause

·           flashback_mode_clause

·           SET   DEFAULT  {  BIGFILE  |  SMALLFILE  }  TABLESPACE clause

·           set_time_zone_clause

You can use these clauses to set non-default values for   specific PDBs.

When connected as a common user whose current container is the   root,  ALTER   PLUGGABLE   DATABASE  statements   with the following clause can modify the open mode of one or more PDBs:

·           pdb_change_state

When the current container is a PDB,  ALTER   PLUGGABLEDATABASE  statements   with this clause can modify the open mode of the current PDB. See " Modifying a PDB with the ALTER PLUGGABLE DATABASE   Statement " .

When connected as a common user whose current container is the   root,  ALTER   PLUGGABLE   DATABASE  statements   with the following clause can preserve or discard the open mode a PDB when   the CDB restarts:

·           pdb_save_or_discard_state

 

1)      对整个 CDB 的修改操作

例如:

ALTER DATABASE BACKUP CONTROLFILE TO '+DATA/dbs/backup/control.bkp';

ALTER DATABASE cdb ADD LOGFILE

  GROUP 4 ('/u01/logs/orcl/redo04a.log','/u02/logs/orcl/redo04b.log')

  SIZE 100M BLOCKSIZE 512 REUSE;

 

2)      仅对 root 的修改操作

Example 40-11 Changing the Default Permanent Tablespace for the Root

ALTER DATABASE DEFAULT TABLESPACE root_tbs;

Example 40-12 Bringing a Data File Online for the Root

ALTER DATABASE DATAFILE '/u02/oracle/cdb_01.dbf' ONLINE;

Example 40-13 Changing the Default Tablespace Type for the Root

ALTER DATABASE SET DEFAULT BIGFILE TABLESPACE;

Example 40-14 Changing the Default Temporary Tablespace for the Root

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE root_temp;

3)      对 1 个或多个 PDB 的操作

Example 40-15 Changing the Open Mode of Listed PDBs

ALTER PLUGGABLE DATABASE salespdb, hrpdb OPEN READ WRITE;

ALTER PLUGGABLE DATABASE salespdb

   OPEN READ ONLY RESTRICTED;

ALTER PLUGGABLE DATABASE salespdb

   OPEN UPGRADE;

ALTER PLUGGABLE DATABASE ALL

   OPEN READ WRITE;

ALTER PLUGGABLE DATABASE ALL

   OPEN READ WRITE FORCE;

ALTER PLUGGABLE DATABASE ALL EXCEPT salespdb, hrpdb

   CLOSE IMMEDIATE;

Example 40-18 Opening a PDB in Read/Write Mode with the STARTUP Command

STARTUP PLUGGABLE DATABASE hrpdb OPEN

STARTUP PLUGGABLE DATABASE hrpdb RESTRICT

STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY RESTRICT

STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY

STARTUP PLUGGABLE DATABASE hrpdb FORCE

4)      restart CDB 时,保留或丢弃 PDB 的 open mode 状态

PDB 在 CDB 启动时默认为 mount 状态,你可以这样做 :

l   当 CDB 重启时,指定 SAVE STATE 以保存 PDBs 模式。

例如,如果 PDB 在重启前处于开读 / 写模式,那么在重启后 PDB 处于开读 / 写模式 ; 如果在重启 CDB 之前 PDB 处于 mount 模式,那么在重启 CDB 之后 PDB 也处于 mount 模式。

l   指定 DISCARD STATE   ,以便在 CDB 重启时忽略 PDBs 的 open 模式。

当为 PDB 指定 DISCARD STATE   时,总是在重新启动 CDB 之后挂载 PDB 。

对于 Oracle RAC CDB 中的 PDB , save state 和 discard state 只影响当前实例的模式。即使在 instances 子句中指定了多个实例,它们也不会影响其他实例的模式。

在 Oracle RAC CDB 中的 PDB ,如果创建 service 时,指定了 -pdb 选项,启动 service 时,同时也会 open 对应的 pdb ;

 

如何查询 saved state 的 pdbs ?

col con_name for a20

col instance_name for a20

set linesize 200

select * from DBA_PDB_SAVED_STATES ;

 

您可以通过以下方式指定要修改哪些 PDBs:

l   列出一个或多个 PDBs 。

l   指定 ALL 来修改所有的 PDBs 。

l   指定例外 PDBs 外的所有 PDBs ,列出的 PDBs 除外。

Example 40-23 Preserving the Open Mode of a PDB When the CDB Restarts

ALTER PLUGGABLE DATABASE salespdb SAVE STATE;

Example 40-24 Discarding the Open Mode of a PDB When the CDB Restarts

ALTER PLUGGABLE DATABASE salespdb DISCARD STATE;

Example 40-25 Preserving the Open Mode of All PDBs When the CDB Restarts

ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Example 40-26 Preserving the Open Mode of Listed PDBs When the CDB Restarts

ALTER PLUGGABLE DATABASE salespdb, hrpdb SAVE STATE;

Example 40-27 Preserving the Open Mode of All PDBs Except for Listed Ones When the CDB Restarts

ALTER PLUGGABLE DATABASE ALL EXCEPT salespdb, hrpdb SAVE STATE;

 

5)      CDB 中 ALTER SYSTEM SET 语句

ALTER SYSTEM RESET OPEN_CURSORS SCOPE = SPFILE;

Example 40-28 Setting an Initialization Parameter for All Containers

ALTER SYSTEM SET OPEN_CURSORS = 200 CONTAINER = ALL;

Example 40-29 Setting an Initialization Parameter for the Root

ALTER SYSTEM SET OPEN_CURSORS = 200 CONTAINER = CURRENT;

 

6)      CDB 中 DDL 语句

Table 40-8 DDL Statements and the CONTAINER Clause in a CDB

DDL Statement

CONTAINER = CURRENT

CONTAINER = ALL

CREATE   USER

Creates a local user in the current PDB.

Creates a common user.

ALTER   USER

Alters a local user in the current PDB.

Alters a common user.

CREATE   ROLE

Creates a local role in the current PDB.

Creates a common role.

GRANT

Grants a privilege in the local container to a local user,   common user, or local role.

The  SET   CONTAINER  privilege   can be granted to a user-created common user in the current PDB.

Grants a system privilege or object privilege on a common   object to a common user or common role. The specified privilege is granted to   the user or role across the entire CDB.

REVOKE

Revokes a privilege in the local container from a local user,   common user, or local role.

This statement can revoke only a privilege granted with  CURRENT  specified   in the  CONTAINER  clause   from the specified user or role in the local container. The statement does   not affect privileges granted with  ALL  specified   in the  CONTAINER  clause.

The  SET   CONTAINER  privilege   can be revoked from a user-created common user in the current PDB.

Revokes a system privilege or object privilege on a common   object from a common user or common role. The specified privilege is revoked   from the user or role across the entire CDB.

This statement can revoke only a privilege granted with  ALL  specified   in the  CONTAINER  clause   from the specified common user or common role. The statement does not affect   privileges granted with  CURRENT  specified   in the  CONTAINER  clause.   However, any privileges granted locally that depend on the privilege granted   commonly that is being revoked are also revoked.

Example 40-30 Creating Local User in a PDB

CREATE USER testpdb IDENTIFIED BY passWord

   DEFAULT TABLESPACE pdb1_tbs

   QUOTA UNLIMITED ON pdb1_tbs

   CONTAINER = CURRENT;

Example 40-31 Creating Common User in a CDB

CREATE USER c##testcdb IDENTIFIED BY password

   DEFAULT TABLESPACE cdb_tbs

   QUOTA UNLIMITED ON cdb_tbs

   CONTAINER = ALL;

 

7)      CDB 中执行 SQL 脚本

Example 40-32 Running the catblock.sql Script in All Containers in a CDB

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS

-d $ORACLE_HOME/rdbms/admin -b catblock_output catblock.sql

Example 40-33 Running the catblock.sql Script in Specific PDBs

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -U SYS

-d $ORACLE_HOME/rdbms/admin -l '/disk1/script_output' -c 'HRPDB SALESPDB'

-b catblock_output catblock.sql

Example 40-34 Running the catblock.sql Script in All Containers Except for Specific PDBs

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS

-d $ORACLE_HOME/rdbms/admin -l '/disk1/script_output' -C 'HRPDB SALESPDB'

-b catblock_output catblock.sql

Example 40-35 Running a SQL Script with Command Line Parameters

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS

-d /u01/scripts -b custom_script_output custom_script.sql

'--phr' '--PEnter password for user hr:'

Example 40-36 Running a SQL Statement in All Containers in a CDB

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -e -b select_output -- --x"SELECT * FROM DUAL"

 

8)      shutdown CDB

SQL*Plus

SRVCTL (When Oracle Restart Is In Use)

SHUTDOWN IMMEDIATE

srvctl stop database -db db_unique_name   -stopoption immediate

SHUTDOWN TRANSACTIONAL

srvctl stop database -db db_unique_name   -stopoption transactional

SHUTDOWN ABORT

srvctl stop database -db db_unique_name -stopoption   abort

 

Ø   PDB 管理任务

Table 42-1 Administrative Tasks Common to PDBs and Non-CDBs

Task

Description

Managing tablespaces

You can create, modify, and drop tablespaces for a PDB. You   can specify a default tablespace and default tablespace type for each PDB.   Also, there is a default temporary tablespace for each PDB. You optionally   can create additional temporary tablespaces for use by individual PDBs.

Managing data files and temp files

Each PDB has its own data files. You can manage data files and   temp files in the same way that you would manage them for a non-CDB. You can   also limit the amount of storage used by the data files for a PDB by using   the  STORAGE  clause   in a  CREATE   PLUGGABLE   DATABASE  or  ALTER   PLUGGABLE   DATABASE  statement.

Managing schema objects

You can create, modify, and drop schema objects in a PDB in   the same way that you would in a non-CDB. You can also create triggers that   fire for a specific PDB.

When you manage database links in a CDB, the root has a unique   global database name, and so does each PDB. The global name of the root is   defined by the  DB_NAME  and  DB_DOMAIN initialization   parameters. The global database name of a PDB is defined by the PDB name and   the  DB_DOMAIN  initialization   parameter. The global database name of each PDB must be unique within the   domain.

 

9)      PDB 中的 ALTER PLUGGABLE DATABASE

Example 42-2 Changing the Open Mode of a PDB

ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;

ALTER PLUGGABLE DATABASE OPEN READ ONLY;

ALTER PLUGGABLE DATABASE OPEN FORCE;

ALTER PLUGGABLE DATABASE OPEN UPGRADE;

Example 42-3 Bringing a Data File Online for a PDB

ALTER PLUGGABLE DATABASE DATAFILE '/u03/oracle/pdb1_01.dbf' ONLINE;

Example 42-4 Changing the Default Tablespaces for a PDB

ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE pdb1_tbs;

ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE pdb1_temp;

Example 42-5 Changing the Default Tablespace Type for a PDB

ALTER PLUGGABLE DATABASE SET DEFAULT BIGFILE TABLESPACE;

Example 42-6 Setting Storage Limits for a PDB

ALTER PLUGGABLE DATABASE STORAGE(MAXSIZE 2G);

ALTER PLUGGABLE DATABASE STORAGE(MAXSIZE UNLIMITED);

ALTER PLUGGABLE DATABASE STORAGE UNLIMITED;

Example 42-7 Setting the Logging Attribute of a PDB

ALTER PLUGGABLE DATABASE NOLOGGING;

Example 42-8 Setting the Force Logging Mode of a PDB

ALTER PLUGGABLE DATABASE ENABLE FORCE LOGGING;

Example 42-9 Setting the Default Edition for a PDB

ALTER PLUGGABLE DATABASE DEFAULT EDITION = PDB1E3;

10)             PDB 的 STARTUP 、 SHUTDOWN 命令

执行 STARTUP 、 SHUTDOWN 必须符合以下条件:

• 当前用户必须拥有 SYSDBA 、 SYSOPER 、 SYSBACKUP 或 SYSDG 管理权限,权限必须在 PDB 中被公共授予或本地授予。用户必须在连接时分别使用 SYSDBA 、 SYSOPER 、 SYSBACKUP 或 SYSDG 来行使权限。

• 除使用 FORCE 选项外, PDB 必须处于挂载模式才能打开。

• 要将 PDB 置于挂载模式, PDB 必须处于 open 只读或 open read/write 模式。

Example 42-10 Opening a PDB in Read/Write Mode with the STARTUP Command


STARTUP OPEN

Example 42-11 Opening a PDB in Read-Only Mode with the STARTUP Command


STARTUP OPEN READ ONLY

Example 42-12 Opening a PDB in Read-Only Restricted Mode with the STARTUP Command


STARTUP RESTRICT OPEN READ ONLY

Example 42-13 Opening a PDB in Read/Write Mode with the STARTUP Command and the FORCE Option


STARTUP FORCE

Example 42-14 Closing a PDB with the SHUTDOWN IMMEDIATE Command


SHUTDOWN IMMEDIATE

11)             PDB 的 alter system 命令

PDB 中可执行如下 alter system 命令:

l   ALTER SYSTEM FLUSH SHARED_POOL

l   ALTER SYSTEM FLUSH BUFFER_CACHE

l   ALTER SYSTEM ENABLE RESTRICTED SESSION

l   ALTER SYSTEM DISABLE RESTRICTED SESSION

l   ALTER SYSTEM SET USE_STORED_OUTLINES

l   ALTER SYSTEM SUSPEND

l   ALTER SYSTEM RESUME

l   ALTER SYSTEM CHECKPOINT

l   ALTER SYSTEM CHECK DATAFILES

l   ALTER SYSTEM REGISTER

l   ALTER SYSTEM KILL SESSION

l   ALTER SYSTEM DISCONNECT SESSION

l   ALTER SYSTEM SET   initialization_parameter  (for a subset of initialization parameters)

 

# 查询 PDB 中可以修改的参数


SELECT NAME FROM V$SYSTEM_PARAMETER WHERE ISPDB_MODIFIABLE='TRUE' ORDER BY NAME;

当当前容器是PDB时,运行ALTER SYSTEM SET initialization_parameter语句来修改PDB。该语句不影响root或其他PDBs。下表描述了当您使用服务器参数文件(SPFILE)并在PDB上运行ALTER SYSTEM SET语句时,SCOPE子句的行为。

SCOPE Setting

Behavior

MEMORY

The initialization parameter setting is changed in memory and   takes effect immediately in the PDB. The new setting affects only the PDB.

The setting reverts to the value set in the root in the any of   the following cases:

·           An  ALTER   SYSTEM   SET  statement   sets the value of the parameter in the root with  SCOPE  equal   to  BOTH  or  MEMORY ,   and the PDB is closed and re-opened. The parameter value in the PDB is not   changed if  SCOPE  is   equal to  SPFILE , and the   PDB is closed and re-opened.

·           The PDB is closed and re-opened.

·           The CDB is shut down and   re-opened.

SPFILE

The initialization parameter setting is changed for the PDB   and stored persistently. The new setting takes effect in any of the following   cases:

·           The PDB is closed and re-opened.

·           The CDB is shut down and   re-opened.

In these cases, the new setting affects only the PDB.

BOTH

The initialization parameter setting is changed in memory, and   it is changed for the PDB and stored persistently. The new setting takes   effect immediately in the PDB and persists after the PDB is closed and   re-opened or the CDB is shut down and re-opened. The new setting affects only   the PDB.

 

12)             PDB 中的 service

在 PDB 中可以对 service 进行增、删、改、查;

# 增:创建 service

srvctl add service -db mycdb -service salesrep -pdb salespdb

或者

BEGIN

  DBMS_SERVICE.CREATE_SERVICE(

    service_name => 'salesrep',

    network_name => 'salesrep.example.com');

END;

/

 

# 改:修改 service

 


srvctl modify service -db mycdb -service salesrep -pdb hrpdb

不能通过DBMS_SERVICE包修改service,解决方法是删除再创建;

# 删:删除 service

srvctl remove service -db mycdb -service salesrep

BEGIN

  DBMS_SERVICE.DELETE_SERVICE(

    service_name => 'salesrep');

END;

/

 

# 查,视图 dba_services

 

在 Oracle RAC CDB 中的 PDB ,如果创建 service 时,指定了 -pdb 选项,启动 service 资源时,同时也会 open 对应的 pdb ;使用 ALTER PLUGGABLE DATABASE 命令关闭 pdb 时, crs 资源 service 会自动 offline ,但是使用 ALTER PLUGGABLE DATABASE 命令启动 pdb 时, service 资源不会随之 online 启动;


【参考】


您可能感兴趣的文档:

--结束END--

本文标题: Oracle 12c CDB&PDBs管理

本文链接: https://www.lsjlt.com/news/47508.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Oracle 12c CDB&PDBs管理
    本文摘取Database Administrator’s Guide(12.1.0.2)中40,42等章节部分内容,概括介绍管理CDB、PDBs任务。摘取翻译的内容侧重操作和实例,详细内容请参考官方文档:...
    99+
    2024-04-02
  • Oracle 12c如何查看CDB&PDBs信息
    这篇文章给大家分享的是有关Oracle 12c如何查看CDB&PDBs信息的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。查看CDB&PDBs信息(SQL*PLUS...
    99+
    2024-04-02
  • 如何理解Oracle 12c CDB的ADG
    这篇文章将为大家详细讲解有关如何理解Oracle 12c CDB的ADG,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。实验环境OS:oracle linux...
    99+
    2024-04-02
  • Oracle 12c nocdb怎么转换成cdb
    这篇文章主要介绍“Oracle 12c nocdb怎么转换成cdb”,在日常操作中,相信很多人在Oracle 12c nocdb怎么转换成cdb问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,...
    99+
    2024-04-02
  • Oracle 12C RAC CDB数据库部署
    Oracle中的12C新特性-容器数据库---12.1.0.2_GI_RAC_Create_CDB_Blog一、         安装前的准备安装两个节点的 1...
    99+
    2023-05-31
  • Oracle 12c中怎么手动创建CDB
    这期内容当中小编将会给大家带来有关Oracle 12c中怎么手动创建CDB,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。使用create database创建CDB的具体...
    99+
    2024-04-02
  • Oracle 12c Non CDB 数据库切换成PDB
    数据库从10.2(11g)升级到12c或者在12c中创建的,数据库就是NON CDB,和12c 之前的版本就没有什么区别,所以一般会把12cnoncdb转为pdb进行管理。 测试步骤如下: 一:源库 1. ...
    99+
    2024-04-02
  • Oracle 12c如何实现手工建库而非CDB及CDB创建
    这篇文章给大家分享的是有关Oracle 12c如何实现手工建库而非CDB及CDB创建的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。相信大家应该都知道,对于Oracle数据库的创建...
    99+
    2024-04-02
  • 如何设置Oracle 12c启动时PDBs自动打开
    如何设置Oracle 12c启动时PDBs自动打开,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。Pluggable Database(PDB)...
    99+
    2024-04-02
  • Oracle CDB管理实现多租户管理功能
    目录CDB的管理1.当前容器2.修改CDB的参数3.修改PDB的参数1.使用ALTER DATABASE 命令修改CDB的参数2.使用ALTER DATABASE命令修改CDB的UNDO模式4.CDB和PDB参数保存位置...
    99+
    2022-12-07
    Oracle CDB管理 Oracle多租户管理
  • Oracle 12c中怎么利用Non-CDB创建PDB
    本篇文章给大家分享的是有关Oracle 12c中怎么利用Non-CDB创建PDB,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。可以移动Non-...
    99+
    2024-04-02
  • Oracle CDB管理实现多租户管理功能
    目录CDB的管理1.当前容器2.修改CDB的参数3.修改PDB的参数1.使用ALTER DATABASE 命令修改CDB的参数2.使用ALTER DATABASE命令修改CDB的UN...
    99+
    2022-12-08
    Oracle CDB管理 Oracle多租户管理
  • Oracle 12C RMAN transport tablespace from PDB of RAC CDB to remote PDB
    这个例子是将Linux 平台上的RAC CDB数据库中PDB(jypdb)数据库中的tts,cs表空间(tts,cs用户的缺省永久表空间)传输到Linux 平台上的单实例CDB数据库中的PDB(jypd...
    99+
    2024-04-02
  • 12c 物理CDB是否支持PDB级别的切换
    这篇文章给大家介绍12c 物理CDB是否支持PDB级别的切换,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。 12c推出CDB后,在集中部署和运维方面有着独...
    99+
    2024-04-02
  • oracle 12c PDB随CDB启动以及链接PDB的方式是什么
    今天就跟大家聊聊有关oracle 12c PDB随CDB启动以及链接PDB的方式是什么,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。本来不知道有这个...
    99+
    2024-04-02
  • Oracle 12c多租户常用管理命令有哪些
    这篇文章给大家分享的是有关Oracle 12c多租户常用管理命令有哪些的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。--进入cdb  sqlplus /nolog &n...
    99+
    2024-04-02
  • oracle 12c pdb open restricted 处理
    在CDB下查询受限的PDB:select con_id, name,open_mode,restricted from v$pdbs;在PDB中查询相关受限的PDB:select ins...
    99+
    2024-04-02
  • 【C++】C&C++内存管理
    就是你被爱情困住了?Wake up bro! 文章目录 一、C/C++内存分布二、C语言中动态内存管理方式三、C++中内存管理方式1.new和delete操作内置类型2.new和delete操作自定义类型(仅限vs的底层实现机制,...
    99+
    2023-08-21
    c++ c语言 java 开发语言
  • Oracle 12C使用UNTIL SEQUENCE子句对Non-CDB中的表执行按时间点恢复
    Oracle 12C使用UNTIL SEQUENCE子句对Non-CDB中的表执行按时间点恢复执行操作如下 1.对整个Non-CDB(orcl)生成RMAN备份 RMAN> backup as...
    99+
    2024-04-02
  • Oracle 12c如何使用RMAN备份对Non-CDB中的表按时间点进行恢复
    小编给大家分享一下Oracle 12c如何使用RMAN备份对Non-CDB中的表按时间点进行恢复,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作