When to Use Startup / Shutdown DB and Alter Database Command in 12c_1582453.1

rongshiyuan發表於2015-01-19

When to Use Startup / Shutdown Database and Alter Database Command in 12c (文件 ID 1582453.1)


In this Document

Goal
Solution

Applies to:

Oracle Database - Enterprise Edition - Version 12.1.0.1 to 12.1.0.1 [Release 12.1]
Information in this document applies to any platform.

Goal

This document provides information about how to startup / shutdown pdf

Solution

Before 12c there are only few commands available for startup and shutdown but if we follow that we end up starting and stopping only cdb and you will come to know from below list of command.

shutdown normal

shutdown immediate

shutdown abort

startup

startup nomount

startup mount

If we use one of these traditional shutdown methods at the container database (CDB) layer, we will bring down the CDB and the associated PDBs under it. This is something to be aware of when looking to reboot a container databases. 

Lets take a look at bringing down a CDB.

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

Now, that we established that SHUTDOWN IMMEDIATE at the CDB level will close the CDB and all other PDBs

How can we shutdown just a single PDB if needed? 

There are two different ways to shutdown a PDB.

1. The first of which is from the CDB layer.

We use this method for maintenance purpose without affecting other pdb. We can shutdown a PDB from the CDB level using the ALTER PLUGGABLE DATABASE command.

alter pluggable database open read write

alter pluggable database open read only

alter pluggable database open upgrade

alter pluggable database close

 e.g.

First find out current state of pdb’s

SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE

---------- ------------------------------ ----------

 2         PDB$SEED                       READ ONLY

 3         PDB1                           MOUNTED

 4         PDBTEST                        MOUNTED

 5         PDB2                           MOUNTED

How to open these pdb’s

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

 4         PDBTEST                        MOUNTED

 5         PDB2                           MOUNTED

Open command in pdb is alter pluggable database but not startup

2. The second of which of from the PDB layer

We can use the normal SHUTDOWN commands as we would with a traditional database.  In order to do this, we have to be in that PDB container first. 

Here is an example of closing PDB1 with the SHUTDOWN command.

e.g.

SQL> alter session set container=PDB1;

Session altered.

SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE

---------- ------------------------------ ----------

 3         PDB1                           READ WRITE

SQL> shutdown immediate;

Pluggable Database closed.

SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE

---------- ------------------------------ ----------

 3         PDB1                           MOUNTED

 

相關內容

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17252115/viewspace-1406992/,如需轉載,請註明出處,否則將追究法律責任。

相關文章