翻译自mos文章怎么startup/shutdown PDB?

Posted brucemengbm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了翻译自mos文章怎么startup/shutdown PDB?相关的知识,希望对你有一定的参考价值。

怎么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 Command
SHUTDOWN NORMAL
SHUTDOWN IMMEDIATE
SHUTDOWN ABORT

Startup Command
STARTUP
STARTUP NOMOUNT
STARTUP MOUNT

在CDB中运行SHUTDOWN IMMEDIATE 会发生什么?


假设我们在container database (CDB)级别使用传统的shutdown命令。那么我们会把CDB和其下所有的PDB所有关闭。
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Feb 13 03:45:42 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, OLAP, Advanced Analytics and Real Application Testing options

SQL> select instance_name from v$instance;


INSTANCE_NAME
----------------
orcl


SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> alter session set container=pn1;
alter session set container=pn1
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL> 

从上面我们能确认:在container database (CDB)级别使用SHUTDOWN IMMEDIATE命令会把CDB和其下所有的PDB所有关闭

怎么关闭个别的PDB?
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Feb 13 05:37:18 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, OLAP, Advanced Analytics and Real Application Testing options

SQL>  SELECT NAME,OPEN_MODE from v$PDBS;

NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PN1			       READ WRITE
PN2			       MOUNTED

SQL> ALTER SESSION SET CONTAINER=pn1; ------------->>>>关键点

Session altered.

SQL>  SHUTDOWN IMMEDIATE;
Pluggable Database closed.
SQL> SELECT NAME,OPEN_MODE from v$PDBS;

NAME			       OPEN_MODE
------------------------------ ----------
PN1			       MOUNTED

SQL> 

或者:
[[email protected] ~]$ sqlplus / as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Sat Feb 13 05:40:10 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, OLAP, Advanced Analytics and Real Application Testing options


SQL> SELECT NAME,OPEN_MODE from v$PDBS;


NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PN1			       READ WRITE
PN2			       MOUNTED


SQL> alter pluggable database pn1 close;---->>关键点


Pluggable database altered.


SQL> SELECT NAME,OPEN_MODE from v$PDBS;


NAME			       OPEN_MODE
------------------------------ ----------
PDB$SEED		       READ ONLY
PN1			       MOUNTED
PN2			       MOUNTED


SQL> 

也能够这么写: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 PN1				  MOUNTED
	 4 PN2				  MOUNTED


SQL> alter pluggable database pn1 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 PN1				  READ WRITE
	 4 PN2				  MOUNTED


SQL> select con_id, name, open_mode,RESTRICTED from v$PDBS;


    CON_ID NAME 			  OPEN_MODE  RES
---------- ------------------------------ ---------- ---
	 2 PDB$SEED			  READ ONLY  NO
	 3 PN1				  READ WRITE NO
	 4 PN2				  MOUNTED


SQL> 



Open PDB in restricted mode
SQL> alter pluggable database PN1 open restricted;


Pluggable database altered.


SQL> SELECT NAME,OPEN_MODE,RESTRICTED from v$PDBS;


NAME                           OPEN_MODE  RES
------------------------------ ---------- ---
PN1                        READ WRITE YES

Open PDB with force option
SQL> alter pluggable database PN1 open FORCE;


Pluggable database altered.


SQL> SELECT NAME,OPEN_MODE,RESTRICTED from v$PDBS;


NAME                           OPEN_MODE  RES
------------------------------ ---------- ---
PN1                        READ WRITE NO

也能够把PDB open到upgrade模式
SQL> alter pluggable database PN1 open UPGRADE;
注意。本文也适用于rac,仅仅须要把v$换成GV$









































以上是关于翻译自mos文章怎么startup/shutdown PDB?的主要内容,如果未能解决你的问题,请参考以下文章

翻译自mos文章怎么找到OGG Director Server使用的数据库和username?

翻译自mos文章在UNIX中,怎么确定一个特定的可执行程序link的是哪些Shared Libraries ?

[翻译自mos文章]不完全恢复之后,open resetlogs之前,怎么快速的检查数据库是否处于一致性的状态?

翻译自mos文章 在错误的从os级别remove掉 trace file 之后,怎么找到该trace file的内容?

翻译自mos文章job 不能自己主动执行--这是另外一个mos文章,本文章有13个解决方法

翻译自mos文章多租户中的service管理