It is recommended to configure the system to automatically start/stop Oracle Database 23ai and LISTENER when the system starts/stops. To automate the start up and shutdown of the listener and database, run the following commands by root user: #Ensure Database and Listener services are running on server. [oracle@orahost ~]$ id uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba) [oracle@orahost ~]$ ps -ef | grep pmon oracle 28848 2673 0 05:42 ? 00:00:00 db_pmon_FREE oracle 30150 30091 0 05:55 pts/0 00:00:00 grep --color=auto pmon [oracle@orahost ~]$ ps -ef | grep tns root 5 2 0 03:25 ? 00:00:00 [netns] oracle 26339 2673 0 05:31 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr LISTENER -inherit oracle 30155 30091 0 05:55 pts/0 00:00:00 grep --color=auto tns #After creation and configuration of Oracle Database 23ai, if you try to check the status of the Oracle Database 23ai service, you will not find any service since the service daemon has not yet been loaded. [root@orahost ~]# systemctl status oracle-free-23ai Unit oracle-free-23ai.service could not be found. #If you try to stop the Oracle Database 23ai service, you will not find any service since the service daemon has not yet been loaded. [root@orahost ~]# systemctl stop oracle-free-23ai Failed to stop oracle-free-23ai.service: Unit oracle-free-23ai.service not loaded. #If you try to start the Oracle Database 23ai service, you will not find any service since the service daemon has not yet been loaded. [root@orahost ~]# systemctl start oracle-free-23ai Failed to start oracle-free-23ai.service: Unit oracle-free-23ai.service not found. #Execute below command to reload the Oracle Database 23ai service. [root@orahost ~]# systemctl daemon-reload #Now you can see the Oracle Database 23ai service in status command. [root@orahost ~]# systemctl status oracle-free-23ai ● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services. Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) #Now enable the Oracle Database 23ai service [root@orahost ~]# systemctl enable oracle-free-23ai oracle-free-23ai.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable oracle-free-23ai #You can see that service is still not running even though you enabled the daemon. [root@orahost ~]# systemctl status oracle-free-23ai ● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services. Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) #Start the service by executing below command and check the status. [root@orahost ~]# systemctl start oracle-free-23ai #Start the service by executing below command and check the status. [root@orahost ~]# systemctl status oracle-free-23ai ● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services. Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated) Active: active (exited) since Thu 2024-05-16 06:14:23 EDT; 2s ago Docs: man:systemd-sysv-generator(8) Process: 32072 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS) May 16 06:14:23 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its> May 16 06:14:23 orahost.localdomain oracle-free-23ai[32072]: The Oracle Database instance FREE is already started. May 16 06:14:23 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its > #You can check the status of the service by executing below command as well. [root@orahost ~]# /etc/init.d/oracle-free-23ai status Status of the Oracle FREE 23ai service: LISTENER status: RUNNING FREE Database status: RUNNING Note: Once you configured the automatic startup and shutdown of the Oracle Database 23ai services then no need to execute START/STOP command manually. It will automatically start/stop services during server startup/shutdown. Let's see the demonstration of automatic startup/shutdown.... #Ensure Oracle Database 23ai service is running on server. [oracle@orahost ~]$ ps -ef | grep pmon oracle 3895 2849 0 09:49 ? 00:00:00 db_pmon_FREE oracle 4564 3711 0 10:05 pts/0 00:00:00 grep --color=auto pmon #Ensure LISTENER service is running on server. [oracle@orahost ~]$ ps -ef | grep tns root 5 2 0 09:16 ? 00:00:00 [netns] oracle 4294 2849 0 09:51 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr LISTENER -inherit oracle 4567 3711 0 10:05 pts/0 00:00:00 grep --color=auto tns #Verify service status using systemctl command. [root@orahost ~]# systemctl status oracle-free-23ai ● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services. Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated) Active: active (exited) since Thu 2024-05-16 09:18:00 EDT; 47min ago Docs: man:systemd-sysv-generator(8) Process: 774 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 16807) Memory: 0B CGroup: /system.slice/oracle-free-23ai.service May 16 09:16:45 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its> May 16 09:16:47 orahost.localdomain oracle-free-23ai[774]: Starting Oracle Net Listener. May 16 09:16:47 orahost.localdomain su[829]: (to oracle) root on none May 16 09:16:59 orahost.localdomain oracle-free-23ai[774]: Oracle Net Listener started. May 16 09:16:59 orahost.localdomain oracle-free-23ai[774]: Starting Oracle Database instance FREE. May 16 09:16:59 orahost.localdomain su[1733]: (to oracle) root on none May 16 09:16:59 orahost.localdomain su[1733]: pam_unix(su:session): session opened for user oracle by (uid=0) May 16 09:18:00 orahost.localdomain oracle-free-23ai[774]: Oracle Database instance FREE started. May 16 09:18:00 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its > #You can also verify services by executing below command as well. [root@orahost ~]# /etc/init.d/oracle-free-23ai status Status of the Oracle FREE 23ai service: LISTENER status: RUNNING FREE Database status: RUNNING #Execute below command to reload the service daemon. This will not show anything on command prompt. #Ignore below command since you have already loaded the service. [root@orahost ~]# systemctl daemon-reload [root@orahost ~]# #Execute below command to enable the Oracle Database 23ai service. #Ignore below command since you have already enabled the service. [root@orahost ~]# systemctl enable oracle-free-23ai oracle-free-23ai.service is not a native service, redirecting to systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable oracle-free-23ai To test the above case, you can execute "init 6" command on your server to take server reboot and see if both Oracle Database 23ai and LISTENER services come up with server start-up. [root@orahost ~]# id uid=0(root) gid=0(root) groups=0(root) [root@orahost ~]# uptime 10:11:04 up 2 min, 1 user, load average: 4.15, 1.64, 0.61 [root@orahost ~]# date Thu May 16 10:11:07 EDT 2024 [root@orahost ~]# ps -ef | grep pmon oracle 1750 1 0 10:09 ? 00:00:00 db_pmon_FREE root 3304 3196 0 10:11 pts/0 00:00:00 grep --color=auto pmon [root@orahost ~]# ps -ef | grep tns root 5 2 0 10:08 ? 00:00:00 [netns] oracle 1740 1 0 10:09 ? 00:00:00 /opt/oracle/product/23ai/dbhomeFree/bin/tnslsnr LISTENER -inherit root 3319 3196 0 10:11 pts/0 00:00:00 grep --color=auto tns #Verify service status using systemctl command. [root@orahost ~]# systemctl status oracle-free-23ai ● oracle-free-23ai.service - SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its associated services. Loaded: loaded (/etc/rc.d/init.d/oracle-free-23ai; generated) Active: active (exited) since Thu 2024-05-16 10:10:39 EDT; 1min 28s ago Docs: man:systemd-sysv-generator(8) Process: 792 ExecStart=/etc/rc.d/init.d/oracle-free-23ai start (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 16807) Memory: 0B CGroup: /system.slice/oracle-free-23ai.service May 16 10:09:31 orahost.localdomain systemd[1]: Starting SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its> May 16 10:09:32 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Net Listener. May 16 10:09:33 orahost.localdomain su[821]: (to oracle) root on none May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Oracle Net Listener started. May 16 10:09:45 orahost.localdomain oracle-free-23ai[792]: Starting Oracle Database instance FREE. May 16 10:09:45 orahost.localdomain su[1743]: (to oracle) root on none May 16 10:09:45 orahost.localdomain su[1743]: pam_unix(su:session): session opened for user oracle by (uid=0) May 16 10:10:39 orahost.localdomain oracle-free-23ai[792]: Oracle Database instance FREE started. May 16 10:10:39 orahost.localdomain systemd[1]: Started SYSV: This script is responsible for taking care of configuring the RPM Oracle FREE Database and its > [root@orahost ~]# /etc/init.d/oracle-free-23ai status Status of the Oracle FREE 23ai service: LISTENER status: RUNNING FREE Database status: RUNNING #Login as oracle user and verify the database startup time. [root@orahost ~]# su - oracle [oracle@orahost ~]$ . oraenv ORACLE_SID = [oracle] ? FREE The Oracle base has been set to /opt/oracle #Verify the database open mode and startup time. [oracle@orahost ~]$ sqlplus / as sysdba SQL*Plus: Release 23.0.0.0.0 - Production on Thu May 16 10:12:34 2024 Version 23.4.0.24.05 Copyright (c) 1982, 2024, Oracle. All rights reserved. Connected to: Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free Version 23.4.0.24.05 SQL> select name,open_mode from v$database; NAME OPEN_MODE --------- -------------------- FREE READ WRITE SQL> alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS'; Session altered. SQL> select sysdate from dual; SYSDATE -------------------- 16-MAY-2024 10:13:29 SQL> select instance_name,startup_time from v$instance; INSTANCE_NAME STARTUP_TIME ---------------- -------------------- FREE 16-MAY-2024 10:09:49 SQL> col open_time for a35 SQL> col name for a16 SQL> select con_id,name,open_mode,OPEN_TIME from v$pdbs; CON_ID NAME OPEN_MODE OPEN_TIME ---------- ---------------- ---------- ----------------------------------- 2 PDB$SEED READ ONLY 16-MAY-24 10.10.10.157 AM -04:00 3 FREEPDB1 READ WRITE 16-MAY-24 10.10.23.121 AM -04:00 #Verify the LISTENER status. oracle@orahost ~]$ lsnrctl status LSNRCTL for Linux: Version 23.0.0.0.0 - Production on 16-MAY-2024 10:29:07 Copyright (c) 1991, 2024, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orahost.localhost.localdomain)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 23.0.0.0.0 - Production Start Date 16-MAY-2024 10:09:44 Uptime 0 days 0 hr. 19 min. 23 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Default Service FREE Listener Parameter File /opt/oracle/product/23ai/dbhomeFree/network/admin/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/orahost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=orahost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "189011a1798d7228e0650a0027822869" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "FREE" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "FREEXDB" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "freepdb1" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... The command completed successfully You can see that the database and listener services are stopped and started automatically after server reboot. Thanks for reading this post ! Please comment if you like this post ! Click on FOLLOW to get next blog updates ! |
Automating Shutdown and Startup of Oracle 23ai Services
May 16, 2024
0
Thank you for your comment !