How to shutdown a Single Instance Database in Oracle 19c
export ORACLE_SID=ORADEV
export PATH=$ORACLE_HOME/bin:$PATH
Tip#1 :- It is always a best practice to view the alert log of instance in another session, to understand what is happening in the background, as well as errors and warnings that helps in troubleshooting a problem.
Verify the name of the Database which needs to be brought down.
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- --------------------
db_name string oradev
I have a user connected to the Database.
SQL> conn oradevuser/oradevuser
Connected.
SQL> show user
USER is "ORADEVUSER"
Let's ISSUE the command SHUTDOWN NORMAL
SQL> shutdown normal;
From the Alert Log we can see that the option used to shutdown the Database is "Normal". Hence it is waiting for the user to disconnect their session.
Shutting down ORACLE instance (normal) (OS id: 17575)
2023-10-12T14:45:33.890232+00:00
Shutdown is initiated by sqlplus@oradevserver (TNS V1-V.
2023-10-12T14:45:36.639475+00:00
Stopping background process SMCO
Shutting down instance: further logons disabled
2023-10-12T14:45:36.975817+00:00
Stopping background process CJQ0
Stopping background process MMNL
2023-10-12T14:45:37.016289+00:00
Process termination requested for pid 15883 [source = rdbms], [info = 2] [request issued by pid: 15877, uid: 502]
Active process 16600 user 'oracle' program 'oracle@oradevserver (TNS V1-V)', waiting for 'SQL*Net message from client'
SHUTDOWN: waiting for logins to complete.
I am disconnecting the user session to check if the Database shuts down. I disconnected the user's session, and the shutdown operation is successful.
ALTER DATABASE CLOSE NORMAL
2023-10-12T14:51:23.709564+00:00
Stopping Emon pool
Stopping background process AQPC
2023-10-12T14:51:24.765515+00:00
IM on ADG: Start of Empty Journal
IM on ADG: End of Empty Journal
Stopping Emon pool
Closing sequence subsystem (2197549537874).
Stopping change tracking
2023-10-12T14:51:25.182951+00:00
Shutting down archive processes
2023-10-12T14:51:25.184724+00:00
TT00 (PID:15310): Gap Manager exiting
Archiving is disabled
2023-10-12T14:51:25.291783+00:00
Thread 1 closed at log sequence 2
Successful close of redo thread 1
Completed: ALTER DATABASE CLOSE NORMAL
ALTER DATABASE DISMOUNT
Shutting down archive processes
Archiving is disabled
Completed: ALTER DATABASE DISMOUNT
2023-10-12T14:51:26.506849+00:00
.... (PID:17575): Archival disabled due to shutdown: 1090
Shutting down archive processes
Archiving is disabled
2023-10-12T14:51:27.512214+00:00
JIT: pid 17575 requesting stop
.... (PID:17575): Archival disabled due to shutdown: 1090
Shutting down archive processes
Archiving is disabled
JIT: pid 17575 requesting stop
2023-10-12T14:51:27.520671+00:00
Stopping background process VKTM
2023-10-12T14:51:32.898974+00:00
freeing rdom 0
freeing the fusion rht of pdb 0
2023-10-12T14:51:50.492443+00:00
Instance shutdown complete (OS id: 17575)
2) SHUTDOWN IMMEDIATE
I have a user connected to the database.
SQL> conn oradevuser/oradevuser
Connected.
SQL> show user
USER is "ORADEVUSER"
Let's issue a shutdown command with the option "IMMEDIATE" and see what happens.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
As expected the SHUTDOWN operation did not wait for the user to disconnect, and the shutdown was successful as we can see in the below Alert Log section of this operation
Shutting down ORACLE instance (immediate) (OS id: 26628)
2023-10-12T15:02:55.382473+00:00
Shutdown is initiated by sqlplus@oradevserver (TNS V1-V.
Stopping background process SMCO
Shutting down instance: further logons disabled
2023-10-12T15:02:55.745228+00:00
Stopping background process CJQ0
Stopping background process MMNL
2023-10-12T15:02:55.787095+00:00
Process termination requested for pid 27284 [source = rdbms], [info = 2] [request issued by pid: 27278, uid: 502]
Stopping background process MMON
2023-10-12T15:02:57.893472+00:00
License high water mark = 5
2023-10-12T15:02:57.968163+00:00
Dispatchers and shared servers shutdown
Data Pump shutdown on PDB: 0 in progress
2023-10-12T15:02:57.974480+00:00
Process termination requested for pid 29001 [source = rdbms], [info = 2] [request issued by pid: 26628, uid: 502]
2023-10-12T15:02:59.988045+00:00
ALTER DATABASE CLOSE NORMAL
2023-10-12T15:03:00.029012+00:00
Stopping Emon pool
2023-10-12T15:03:01.032269+00:00
IM on ADG: Start of Empty Journal
IM on ADG: End of Empty Journal
Stopping Emon pool
Closing sequence subsystem (2198245798838).
Stopping change tracking
2023-10-12T15:03:01.506252+00:00
Shutting down archive processes
2023-10-12T15:03:01.508299+00:00
TT00 (PID:26641): Gap Manager exiting
Archiving is disabled
2023-10-12T15:03:01.612067+00:00
Thread 1 closed at log sequence 2
Successful close of redo thread 1
Completed: ALTER DATABASE CLOSE NORMAL
ALTER DATABASE DISMOUNT
Shutting down archive processes
Archiving is disabled
Completed: ALTER DATABASE DISMOUNT
2023-10-12T15:03:02.883102+00:00
.... (PID:26628): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
2023-10-12T15:03:03.888795+00:00
JIT: pid 26628 requesting stop
.... (PID:26628): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
JIT: pid 26628 requesting stop
2023-10-12T15:03:03.942920+00:00
Stopping background process VKTM
2023-10-12T15:03:09.036053+00:00
freeing rdom 0
freeing the fusion rht of pdb 0
2023-10-12T15:03:28.196073+00:00
Instance shutdown complete (OS id: 26628)
Note:- This is the most preferred way to shutdown a Database.
3) SHUTDOWN TRANSACTIONAL
To test this scenario, I have a user connected to the Database.
SQL> conn oradevuser/oradevuser
Connected.
Let's try to create a table and insert some rows.
SQL> create table SalesAdmin(Name Varchar(20),Age Number(2));
Table created.
SQL> insert into SalesAdmin values('James',25);
1 row created.
Let's issue SHUTDOWN TRANSACTIONAL now.
SQL> shutdown transactional;
All transactions complete. Performing immediate shutdown
License high water mark = 7
2023-10-12T15:23:28.788893+00:00
Dispatchers and shared servers shutdown
Data Pump shutdown on PDB: 0 in progress
2023-10-12T15:23:28.793882+00:00
Process termination requested for pid 10316 [source = rdbms], [info = 2] [request issued by pid: 4834, uid: 502]
2023-10-12T15:23:30.798805+00:00
ALTER DATABASE CLOSE NORMAL
2023-10-12T15:23:30.868313+00:00
Stopping Emon pool
2023-10-12T15:23:31.872050+00:00
IM on ADG: Start of Empty Journal
IM on ADG: End of Empty Journal
Stopping Emon pool
Closing sequence subsystem (2199476639132).
Stopping change tracking
2023-10-12T15:23:32.273237+00:00
Shutting down archive processes
2023-10-12T15:23:32.274880+00:00
TT00 (PID:4847): Gap Manager exiting
Archiving is disabled
2023-10-12T15:23:32.378864+00:00
Thread 1 closed at log sequence 2
Successful close of redo thread 1
Completed: ALTER DATABASE CLOSE NORMAL
ALTER DATABASE DISMOUNT
Shutting down archive processes
Archiving is disabled
Completed: ALTER DATABASE DISMOUNT
2023-10-12T15:23:33.658119+00:00
.... (PID:4834): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
2023-10-12T15:23:34.664160+00:00
JIT: pid 4834 requesting stop
.... (PID:4834): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
JIT: pid 4834 requesting stop
2023-10-12T15:23:34.756986+00:00
Stopping background process VKTM
2023-10-12T15:23:40.014552+00:00
freeing rdom 0
freeing the fusion rht of pdb 0
2023-10-12T15:23:58.677330+00:00
Instance shutdown complete (OS id: 4834)
4) SHUTDOWN ABORT
As you can see in the above section of the Alert Log, the instance was recovered during the very next startup.