前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【翻译mos文章】怎么startup/shutdown PDB?

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

作者头像
Yunjie Ge
发布2024-04-03 19:24:04
990
发布2024-04-03 19:24:04
举报
文章被收录于专栏:数据库与编程

怎么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 命令是:

  1. Shutdown Command
代码语言:javascript
复制
SHUTDOWN NORMAL
SHUTDOWN IMMEDIATE
SHUTDOWN ABORT

Startup Command

代码语言:javascript
复制
STARTUP
STARTUP NOMOUNT
STARTUP MOUNT

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

如果我们在container database (CDB)级别使用传统的shutdown命令,那么我们会把CDB和其下所有的PDB全部关闭。

代码语言:javascript
复制
$ 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?

代码语言:javascript
复制
$ 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

或者

代码语言:javascript
复制
$ 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

代码语言:javascript
复制
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

代码语言:javascript
复制
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

代码语言:javascript
复制
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

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-03-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 山东Oracle用户组 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档