12c多租户管理五(修改pdb打开模式)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了12c多租户管理五(修改pdb打开模式)相关的知识,希望对你有一定的参考价值。
一、执行语句修改的前提The current user must have SYSDBA , SYSOPER , SYSBACKUP , or SYSDG administrative
privilege, and the privilege must be either commonly granted or locally granted in
the PDB
二、 打开模式说明
2.1、ALTER PLUGGABLE DATABASE pdb 的打开模式
1、OPEN READ WRITE 读写模式,允许运行查询和用户事务,以及允许用户生成 redo log
2、OPEN READ ONLY 只读模式,只允许运行查询。
3、OPEN MIGRATE 该模式下可以运行 pdb 的升级脚本
4、MOUNTED 和 non-cdb 的挂载模式一样
2.2、STARTUP PLUGGABLE DATABASE pdb 打开模式
1、OPEN READ WRITE 读写模式
2、OPEN READ ONLY 只读模式,只允许运行查询。
3、OPEN MIGRATE 该模式下可以运行 pdb 的升级脚本
2.3、关闭模式
1、CLOSE IMMEDIATE 相当于 non-cdb 的 shutdown immediate
2、Close abort 相当于 non-cdb 的 shutdown abort
3、close 相当于non-cdb shutdwon normal
2.4、几个参数说明
1、open 后面不根参数,默认打开方式是 read write
2、When RESTRICTED is specified, the PDB is accessible only to users with RESTRICTED SESSION privilege in the PDB
3、FORCE keyword included, all PDBs are opened in read/write mode, including PDBs in read-only mode
4、While a PDB is in mounted or read-only mode, database administrators can create, modify, or drop common users and roles in the CDB. The CDB applies these changes
to the PDB when its open mode is changed to open in read/write mode
2.5、打开pdb 的语法
ALTER PLUGGABLE DATABASE 目标 pdb 打开模式
STARTUP PLUGGABLE DATABASE 目标 pdb 打开模式
语法说明如下:
? 指定目标 pdb 名字可以用逗号隔开 pdb 的名字以指定多个 pdb
? 指定 ALL 表示修改所有pdb
? Specify ALL EXCEPT to modify all of the PDBs, except for the PDBs listed
2.6、启动和停止可插拔数据库的例子
关闭所有 pdb 得例子如下
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Sat May 26 07:30:40 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC READ WRITE NO
4 CRMPDB2 READ WRITE NO
SQL> alter pluggable database all close;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC MOUNTED
4 CRMPDB2 MOUNTED
启动所有 pdb 得例子如下:
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC READ WRITE NO
4 CRMPDB2 READ WRITE NO
2.7、cdb重启后设置关所有相关pdb自动open
1、说明
? 默认 cdb 重启 pdb 处于 mount 状态
? Specify SAVE STATE to preserve the PDBs‘ mode when the CDB is restarted
? Specify DISCARD STATE to ignore the PDBs‘ open mode when the CDB is restarte
? You can specify which PDBs to modify in the following ways:
? List one or more PDBs.用逗号隔开
? Specify ALL to modify all of the PDBs.
? Specify ALL EXCEPT to modify all of the PDBs, except for the PDBs listed.
2、cdb 重启后pdb自动启动例子
SQL> startup force open;
ORACLE instance started.
Total System Global Area 2030043136 bytes
Fixed Size 8794504 bytes
Variable Size 1207963256 bytes
Database Buffers 805306368 bytes
Redo Buffers 7979008 bytes
Database mounted.
Database opened.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC MOUNTED
4 CRMPDB2 MOUNTED
SQL> alter pluggable database all open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC READ WRITE NO
4 CRMPDB2 READ WRITE NO
SQL> alter pluggable database all save state;
Pluggable database altered.
SQL> startup force open;
ORACLE instance started.
Total System Global Area 2030043136 bytes
Fixed Size 8794504 bytes
Variable Size 1174408824 bytes
Database Buffers 838860800 bytes
Redo Buffers 7979008 bytes
Database mounted.
Database opened.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC READ WRITE NO
4 CRMPDB2 READ WRITE NO
3、丢弃cdb重启后pdb自动重启得状态
SQL> alter pluggable database all discard state;
Pluggable database altered.
SQL> startup force open;
ORACLE instance started.
Total System Global Area 2030043136 bytes
Fixed Size 8794504 bytes
Variable Size 1174408824 bytes
Database Buffers 838860800 bytes
Redo Buffers 7979008 bytes
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
2 PDB$SEED READ ONLY NO
3 JXC MOUNTED
4 CRMPDB2 MOUNTED
以上是关于12c多租户管理五(修改pdb打开模式)的主要内容,如果未能解决你的问题,请参考以下文章
Oracle 12c 多租户家族(12c 18c 19c)如何在 PDB 中添加 HR 模式