When using the Oracle database, sometimes you need to shut it down. This may be for maintenance, backup, or other operations. Regardless of the reason, shutting down an Oracle database is not a simple task and requires certain understanding and skills. In this article, we will explain how to shut down an Oracle database.
Before closing the Oracle database, you need to close the background process first. The background process is created when the Oracle instance starts and is used to manage the running of the database instance. You need to log in to the Oracle server using an operating system account and run the following command to shut down the background process:
$ sqlplus / as sysdba SQL> shutdown immediate;
This command will shut down the Oracle database, including currently ongoing transactions. Before shutting down the database, Oracle stores all data on disk so that it can be reloaded the next time it is started.
Before closing the Oracle database, you need to close the listener first. A listener is a process that receives client connection requests. You need to log in to the Oracle server using an operating system account and run the following command to close the listener:
$ lsnrctl stop;
This command will close the currently running listener. With this command, the Oracle database can no longer access connection requests from the client.
Before closing the database instance, you need to stop the currently running instance. You need to log in to the Oracle server using an operating system account and run the following command to shut down the instance:
$ sqlplus / as sysdba SQL> shutdown immediate;
This command will stop each database instance and all processes in it. After the instance is shut down, the Oracle database will no longer provide services.
In Oracle Real Application Clusters (RAC) environment, you need to shut down the database instance on each node. You need to use the command line tool or any GUI tool to log in to each node in the Oracle RAC cluster as an administrator, and use the following command to shut down the Oracle database instance and listener:
$ srvctl stop instance -d dbname -i instance_name $ srvctl stop listener -l listener_name
In the above command, dbname represents the database Name, instance_name represents the database instance name in the RAC environment, and listener_name represents the listener name. After executing the above command, the Oracle database will no longer provide external services. This needs to be done on every node.
Summary
With the above steps, you can easily shut down the Oracle database. Please make sure you back up your database before doing this, just in case something unexpected happens. Shutting down an Oracle database will suspend all its operations until the next startup. If you need to perform operations on the Oracle database, make sure to back up before shutting down and restore immediately after shutting down.
The above is the detailed content of oracle close database. For more information, please follow other related articles on the PHP Chinese website!