19c pdb如何儲存啟動狀態

sjw1933發表於2021-01-03

我們要儲存pdb狀態,首先要了解檢視DBA_PDB_SAVED_STATES顯示了當前CDB中儲存的pdb狀態資訊。

This view is a data link, so the data is also available within the PDB.

Column Datatype NULL Description

CON_ID

NUMBER

NOT NULL

The ID of the PDB

CON_NAME

VARCHAR2(128)

NOT NULL

Name of the PDB

INSTANCE_NAME

VARCHAR2(128)

NOT NULL

Name of the instance for which the state is saved

CON_UID

NUMBER

NOT NULL

Unique ID assigned to the PDB at creation time

GUID

RAW(16)

Globally unique immutable ID assigned to the PDB at creation time

STATE

VARCHAR2(14)

Open state of the PDB

RESTRICTED

VARCHAR2(3)

Restricted mode of the PDB

預設情況,啟停CDB,觀察pdb狀態

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------         
    2 PDB$SEED                       READ ONLY  NO         
    3 PDB1                           READ WRITE NO         
    4 PDB2                           MOUNTED         
    5 PDB3                           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 PDB1                           READ WRITE NO         
    4 PDB2                           READ WRITE NO         
    5 PDB3                           READ WRITE NO

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup  
ORACLE instance started.

Total System Global Area 2348810240 bytes
Fixed Size                  8795376 bytes
Variable Size             855640848 bytes
Database Buffers         1476395008 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 PDB1                           MOUNTED         
    4 PDB2                           MOUNTED         
    5 PDB3                           MOUNTED

那如果我們想讓pdb3在cdb啟動後就是open狀態,需要如何設定?

首先檢視DBA_PDB_SAVED_STATES

SQL>  select * from dba_pdb_saved_states;
no rows selected

單獨開啟pdb3

SQL> alter pluggable database pdb3 open;
Pluggable database altered.


SQL>  show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------         
    2 PDB$SEED                       READ ONLY  NO         
    3 PDB1                           MOUNTED         
    4 PDB2                           MOUNTED         
    5 PDB3                           READ WRITE NO

接著儲存pdb3啟動狀態

SQL> alter pluggable database pdb3 save state;
Pluggable database altered.
SQL> select * from dba_pdb_saved_states;
    CON_ID----------CON_NAME--------------------------------------------------------------------------------INSTANCE_NAME--------------------------------------------------------------------------------   CON_UID GUID                             STATE          RES---------- -------------------------------- -------------- ---         5PDB3orcl11117920907 921B7939BC8C217CE053DDF0A8C04389 OPEN           NO

重啟cdb驗證:

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup
ORACLE instance started.

Total System Global Area 2348810240 bytes
Fixed Size                  8795376 bytes
Variable Size             855640848 bytes
Database Buffers         1476395008 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 PDB1                           MOUNTED         
    4 PDB2                           MOUNTED         
    5 PDB3                           READ WRITE NO



參考文件:

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

相關文章