Opening a pluggable database makes it available for current work. SAVE STATE preserves its intended open mode so Oracle reopens that PDB when the CDB starts.
Oracle DBA Lesson 27B — Keeping a PDB Open After Restart
The example continues with LABPDB open READ WRITE, with RESTRICTED equal to NO. The previous lesson covered choosing and changing that current mode. Here the task is to preserve the intended state, inspect the saved record, and verify the PDB after restart. Oracle PDB administration guide.
Current state and saved state
These two views answer different questions:
| Question | View | Useful columns |
|---|---|---|
| What is the PDB's mode now? | V$PDBS |
NAME, OPEN_MODE, RESTRICTED |
| What state is saved for restart? | DBA_PDB_SAVED_STATES |
CON_NAME, INSTANCE_NAME, STATE, RESTRICTED |
INSTANCE_NAME associates a saved record with an instance. In this single-instance example there is one relevant instance. Read the row for that instance. Oracle DBA_PDB_SAVED_STATES reference.
Save the intended open state
Check that the PDB is in the state you intend to preserve:
SELECT name, open_mode, restricted
FROM v$pdbs
WHERE name = 'LABPDB';
For the example, expect LABPDB, READ WRITE, NO. If the PDB is still in a temporary maintenance mode, set the intended mode before you save it.
Run the named command from CDB$ROOT:
ALTER PLUGGABLE DATABASE LABPDB SAVE STATE;
This records the PDB's open state and restricted-access setting for restart. Oracle uses that record when the CDB starts again. Oracle ALTER PLUGGABLE DATABASE reference.
Inspect the record:
SELECT con_name, instance_name, state, restricted
FROM dba_pdb_saved_states
WHERE con_name = 'LABPDB';
| CON_NAME | INSTANCE_NAME | STATE | RESTRICTED |
|---|---|---|---|
LABPDB |
CDB1 |
OPEN |
NO |
CDB1 is the example instance name. Yours may differ. OPEN is the saved-state value used for this read-write example. Oracle's 19c training material shows STATE = OPEN alongside a PDB that is READ WRITE before and after restart. Use V$PDBS.OPEN_MODE for the actual current mode. Oracle University Gold DBA startup example.
When the intended state changes later, apply the new mode and run SAVE STATE again. The saved record follows the setting you explicitly save. Oracle worked example.
Verify after the CDB restarts
Save the intended state, restart the CDB, then check the PDB's actual mode. In this example, Oracle restores LABPDB to READ WRITE with unrestricted access. Oracle PDB restart behavior.
After restart, repeat the current-state query. Confirm OPEN_MODE and RESTRICTED. Then connect through the application's service and check the destination:
SHOW CON_NAME
SELECT SYS_CONTEXT('USERENV', 'CON_NAME') AS container_name
FROM dual;
SHOW CON_NAME is a SQL*Plus command. The query is SQL. Both show whether the connected container is LABPDB. Using the application's connection path checks access as well as the reported mode.
PDB state and the application service are administered together during maintenance. Use the service's configured owner and startup policy. Oracle Restart or Clusterware-managed services use their own management tools. Oracle PDB services.
Restore the default restart setting
ALTER PLUGGABLE DATABASE LABPDB DISCARD STATE;
DISCARD STATE removes the saved restart record. A currently open PDB stays open. With no saved state, that PDB is MOUNTED after the next CDB restart. Query both views again: current mode in V$PDBS, and no saved row for that instance in DBA_PDB_SAVED_STATES. Oracle DISCARD STATE syntax.
Practice
Use Oracle Database 19c in an authorized disposable single-instance CDB. Run the named commands from CDB$ROOT with an approved account. This course uses AS SYSDBA. Reading the views needs catalog access. Oracle documents the save and discard operation from the root. Oracle PDB administration prerequisites.
- Record
LABPDB's current mode, restriction flag, and any existing saved row. - Confirm the intended open mode, save it, and inspect the row for this instance.
- In an agreed isolated outage, an authorized administrator can use
SHUTDOWN IMMEDIATEfollowed bySTARTUPfrom root. This stops and restarts the CDB instance and all of its PDBs. Applications disconnect during the outage. - Verify the current mode, restriction flag, and application-service connection.
- Restore the starting configuration. If there was no original saved record, discard the new one. If a record existed, restore its original intended mode and restriction, then save that state again. Restore any separately changed current mode as well.
Record the actual results and the difference between the current mode and the saved row. Startup triggers, service automation, or management policies can also change restart behavior. Identify those in the designated environment before the restart exercise.
No comments:
Post a Comment