- How to Automate Startup/Shutdown of Oracle Database on Linux (Doc ID 222813.1)
- Purpose
- Scope
- Details
- To view full details, sign in with your My Oracle Support account.
- Don’t have a My Oracle Support account? Click to get started!
- Shutdown oracle on linux
- 2 Starting Up and Shutting Down
- Starting Up the Database
- Starting Up the Data base from the Desktop
- Starting Up the Databas e Using the SQL Command Line
- Shutting Down the Database
- Shut ting Down the Database from the Desktop
- Shutti ng Down the Database Using the SQL Command Line
How to Automate Startup/Shutdown of Oracle Database on Linux (Doc ID 222813.1)
Oracle Cloud Infrastructure — Version N/A and later
Oracle Database — Standard Edition — Version 12.1.0.2 to 12.1.0.2 [Release 12.1]
Linux OS
Oracle Database — Enterprise Edition — Version 8.0.3.0 and later
Oracle Database Cloud Schema Service — Version N/A and later
Linux x86
Linux x86-64
This document applies to:
SLES7, SLES8, SLES9, SLES10
RHAS 2.1, RHEL 3,4,5,6 OL 4,5,6
Purpose
This document aims to demonstrate the automatic startup and shutdown of Oracle databases on Linux.
Scope
The information in this document is useful for system administrators and database administrators trying to automate Oracle database startup and shutdown. The document describes the detailed steps for configuration on Red Hat Advanced Server 2.1, RedHat Enterprise Linux (RHEL) 3,4,5,6 SuSE SLES7, United Linux 1.0 (SuSE SLES8 Edition), SLES9, SLES10, Oracle Linux (OL) 4,5,6. The information may not apply to other Linux distributions. The main solution does not work on OL7. References provided at the end for Oracle Linux 7 and later.
The following configuration is done to allow Oracle database be up and running in runlevels 3 (character mode) and 5 (X-Window system) and the start / stop commands does not provide the exhaustive list of all possibilities and it presents an example. Therefore the exact scripts may not work with your configuration
Since the configuration is based on dbstart and dbshut scripts provided by the Oracle Server installation, please see
The configuration also facilitates automated startup shutdown of Intelligent Agent, Management Server and HTTP Server, which are available with Oracle Server.
The information in this document does not apply to Oracle Internet Application Server. Still the script can be configured to handle starting up and shutting down iAS processes.
As per Note:105957.1 and Note 1397813.1,
When using an 11.2 ASM or CRS managed database (using the 11.2 Grid Infrastructure), the startup/shutdown script may no longer be used. CRS manages automatic restarts/startups for RAC and single instance databases are managed with Oracle Restart. See the following for more information:
- How to setup Oracle to startup automatically if the system is restarted
- Oratab — # Line Added By Agent
Details
To view full details, sign in with your My Oracle Support account.
Don’t have a My Oracle Support account? Click to get started!
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.
Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. � Oracle | Contact and Chat | Support | Communities | Connect with us | | | | Legal Notices | Terms of Use
Shutdown oracle on linux
You can start and stop the database manually, set it to automatically after the system shuts down and starts, or using Enterprise Manager.
Shutting Down and Starting Up Using the Configuration Services Script
Execute these commands as root using sudo .
You can start and stop the database using the /etc/init.d/oracle-xe-18c script.
Run the following command to start the listener and database:
# /etc/init.d/oracle-xe-18c start
Run the following command to stop the database and the listener:
Run the following command to stop and start the listener and database:
# /etc/init.d/oracle-xe-18c restart
Run the following command to start the listener and database:
# systemctl start oracle-xe-18c
Run the following command to stop the database and the listener:
# systemctl stop oracle-xe-18c
Run the following command to stop and start the listener and database:
# systemctl restart oracle-xe-18c
Shutting Down and Starting Up Using SQL*Plus
You can shut down and start the database using SQL*Plus.
To shutdown the database, login to the oracle user with its environment variables set for access to the XE database, and issue the following SQL*Plus command:
$ sqlplus / as sysdba SQL> SHUTDOWN IMMEDIATE
To start the database, issue the commands:
SQL> STARTUP SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
- Oracle Database 2 Day DBA for general information about managing a database
- Oracle Multitenant Administration Guide for more information about shutting down and starting a PDB
Automating Shutdown and Startup
Oracle recommends that you configure the system to automatically start Oracle Database when the system starts, and to automatically shut it down when the system shuts down. Automating database shutdown guards against incorrect database shutdown.
To automate the startup and shutdown of the listener and database, execute the following commands as root :
For Oracle Linux 6, run these commands:
# /sbin/chkconfig oracle-xe-18c on # /sbin/service oracle-xe-18c start
# systemctl daemon-reload # systemctl enable oracle-xe-18c
2 Starting Up and Shutting Down
This section describes how to start up and shut down Oracle Database Express Edition. It contains the following topics:
Starting Up the Database
Oracle Database Express Edition (Oracle Database XE) starts up automatically immediately after installation and after each system restart. Thus, there is no need to start up the database unless you previously shut it down.
You can start up the database from the desktop or with the SQL Command Line (SQL*Plus). Each of these methods is described in the following sections:
Starting Up the Data base from the Desktop
This section explains how to start up the database from the desktop in Windows and in the following two Linux windowing managers: KDE and Gnome. If your Linux computer is not running a windowing manager, or is running a windowing manager other than KDE or Gnome, you must start the database with the SQL Command Line. See «Starting Up the Database Using the SQL Command Line» for instructions.
To start up the database using the desktop:
- Do one of the following:
- On Windows: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a Windows administrator—that is, as a user who is a member of the Administrator group.
- On Linux: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a user who is a member of the dba user group. This is typically the user oracle . See «Operating System Authentication» for more information.
- Do one of the following:
- On Windows: Click Start , point to Programs (or All Programs) , point to Oracle Database 11g Express Edition , and then select Start Database .
- On Linux with Gnome: In the Applications menu, point to Oracle Database 11g Express Edition , and then select Start Database .
- On Linux with KDE: Click the icon for the K Menu, point to Oracle Database 11g Express Edition , and then select Start Database .
Starting Up the Databas e Using the SQL Command Line
When you start up the database with the SQL Command Line, you must run the SQL Command Line on the same computer where you installed Oracle Database XE (the «Oracle Database XE host computer»).
To start up the database using the SQL Command Line:
- Do one of the following:
- On Windows: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a Windows administrator—that is, as a user who is a member of the Administrator group.
- On Linux: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a user who is a member of the dba user group. This is typically the user oracle . See «Operating System Authentication» for more information.
- If not already opened, open a terminal session or command window.
- Linux platform only: Ensure that environment variables are set properly. See «Setting Environment Variables on the Linux Platform» for details.
- At the operating system prompt, enter the following command to start the SQL Command Line and connect to the database:
If the command is successful, it displays output similar to the following. (System global area sizes will vary depending on the amount of physical memory in your Oracle Database XE host computer.)
ORACLE instance started. Total System Global Area 599785472 bytes Fixed Size 1220804 bytes Variable Size 180358972 bytes Database Buffers 415236096 bytes Redo Buffers 2969600 bytes Database mounted. Database opened.
SQL> select count(*) from hr.employees;
Shutting Down the Database
Oracle Database Express Edition (Oracle Database XE) shuts down automatically when you shut down the computer that hosts it. However, you can also shut Oracle Database XE down manually whenever you want, such as to reduce the overall system processing overhead when you do not need to use the database.
Before shutting down Oracle Database XE, it is best to ensure that all users and applications have completed their work and logged out. See «Monitoring Sessions» for information on how to view current database sessions.
If users or applications are still logged in when you begin a shutdown operation, the shutdown proceeds under the following conditions:
- No new connections are permitted, and no new transactions are allowed to be started.
- Any uncommitted transactions are rolled back.
- All users and applications are immediately disconnected.
You can shut down the database with the desktop or with the SQL Command Line (SQL*Plus). Each of these methods is described in the following sections:
Shut ting Down the Database from the Desktop
This section explains how to shut down the database from the desktop in Windows and in the following two Linux windowing managers: KDE and Gnome. If your Linux computer is not running a windowing manager, or is running a windowing manager other than KDE or Gnome, you must shut down the database with the SQL Command Line.
To shut down the database using the desktop:
- Do one of the following:
- On Windows: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a Windows administrator—that is, as a user who is a member of the Administrator group.
- On Linux: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a user who is a member of the dba user group. This is typically the user oracle . See «Operating System Authentication» for more information.
- Do one of the following:
- On Windows: Click Start , point to Programs (or All Programs) , point to Oracle Database 11g Express Edition , and then select Stop Database .
- On Linux with Gnome: In the Applications menu, point to Oracle Database 11g Express Edition , and then select Stop Database .
- On Linux with KDE: Click the icon for the K Menu, point to Oracle Database 11g Express Edition , and then select Stop Database .
Shutti ng Down the Database Using the SQL Command Line
When you shut down the database with the SQL Command Line, you must run the SQL Command Line on the same computer where you installed Oracle Database XE (the «Oracle Database XE host computer»).
To shut down the database using the SQL Command Line:
- Do one of the following:
- On Windows: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a Windows administrator—that is, as a user who is a member of the Administrator group.
- On Linux: Log in to the Oracle Database XE host computer as the user that installed Oracle Database XE or as a user who is a member of the dba user group. This is typically the user oracle . See «Operating System Authentication» for more information.
- If not already opened, open a terminal session or command window.
- Linux platform only: Ensure that environment variables are set properly. See «Setting Environment Variables on the Linux Platform» for details.
- At the operating system prompt, enter the following command to start the SQL Command Line and connect to the database:
Note that this command may take a short while to complete. If the command is successful, it displays the following output:
Database closed. Database dismounted. ORACLE instance shut down.
If the command displays no output after a number of minutes, indicating that the shutdown operation is not proceeding, you can press CTRL-C to interrupt the command, and then enter the following command:
The database must go through a recovery process when it starts up after a SHUTDOWN ABORT command. It is recommended that you enable the recovery process to take place immediately, after which you can shut down the database normally. To do this, enter the following commands when the SHUTDOWN ABORT completes:
SQL> STARTUP SQL> SHUTDOWN IMMEDIATE