怎么startup/shutdown PDB? 来源于: 12c: How to Startup/Shutdown PDB's? (文档 ID 1592247.1) 适用于: Oracle Database - Enterprise Edition - Version 12.1.0.1 and later Information in this document applies to any platform. 目标: startup/shutdown PDB的方法。 解决方案: 在12c之前,传统的startup/shutdown 命令是:
SHUTDOWN NORMAL
SHUTDOWN IMMEDIATE
SHUTDOWN ABORT
Startup Command
STARTUP
STARTUP NOMOUNT
STARTUP MOUNT
在CDB中执行SHUTDOWN IMMEDIATE 会发生什么?
如果我们在container database (CDB)级别使用传统的shutdown命令,那么我们会把CDB和其下所有的PDB全部关闭。
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Oct 15 21:42:53 2013
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 Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
ora12c
SQL> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> alter session set container=PDB1;
alter session set container=PDB1
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
从上面我们能确认:在container database (CDB)级别使用SHUTDOWN IMMEDIATE命令会把CDB和其下所有的PDB全部关闭 怎么关闭个别的PDB?
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Oct 15 21:42:53 2013
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 Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> SELECT NAME,OPEN_MODE from v$PDBS;
NAME OPEN_MODE
--------------- ---------------
PDB$SEED READ ONLY
PDB1 READ WRITE
SQL> ALTER SESSION SET CONTAINER=PDB1;
Session altered.
SQL> SHUTDOWN IMMEDIATE;
Pluggable Database closed.
SQL> SELECT NAME,OPEN_MODE from v$PDBS;
NAME OPEN_MODE
--------------- ---------------
PDB$SEED READ ONLY
PDB1 MOUNT
或者
$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Oct 15 21:42:53 2013
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 Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> SELECT NAME,OPEN_MODE from v$PDBS;
NAME OPEN_MODE
--------------- ---------------
PDB$SEED READ ONLY
PDB1 READ WRITE
SQL> alter pluggable database PDB1 close;
Pluggable database altered.
SQL> SELECT NAME,OPEN_MODE from v$PDBS;
NAME OPEN_MODE
--------------- ---------------
PDB$SEED READ ONLY
PDB1 MOUNT
也可以这么写:SQL> alter pluggable database pn1 close immediate; 一旦我们执行了shutdown命令,pdb总是停留在mount状态
怎么根据需要启动某一个PDB? 有两种不同的方式来启动PDB
SQL> select con_id, name, open_mode from v$pdbs;
CON_ID NAME OPEN_MODE
---------- ------------------------------ ----------
2 PDB$SEED READ ONLY
3 PDB1 MOUNTED
How do we bring PDB online in READ WRITE mode?
SQL> alter pluggable database PDB1 open;
Pluggable database altered.
SQL> select con_id, name, open_mode from v$pdbs;
CON_ID NAME OPEN_MODE
---------- ------------------------------ ----------
2 PDB$SEED READ ONLY
3 PDB1 READ WRITE =>>>>>
Open PDB in restricted mode
SQL> alter pluggable database PDB1 open restricted;
Pluggable database altered.
SQL> SELECT NAME,OPEN_MODE,RESTRICTED from v$PDBS;
NAME OPEN_MODE RES
------------------------------ ---------- ---
PDB1 READ WRITE YES
Open PDB with force option
SQL> alter pluggable database PDB1 open FORCE;
Pluggable database altered.
SQL> SELECT NAME,OPEN_MODE,RESTRICTED from v$PDBS;
NAME OPEN_MODE RES
------------------------------ ---------- ---
PDB1 READ WRITE NO
也可以把PDB open到upgrade模式SQL> alter pluggable database PN1 open UPGRADE;注意,本文也适用于rac,只需要把v