Oracle database startup and shutdown various ways to organize

Source: Internet
Author: User
Tags terminates

Overview

Only users with SYSDBA and Sysoper system privileges can start and shut down the database.

You should start the listener before starting the database, or you will not be able to manage the database using command mode, including starting and shutting down the database.

Although the database is functioning correctly, the client cannot connect to the database if the listener is not started.

Under Oracle User: Start listener lsnrctl start shutdown listener lsnrctl stop

Querying Listener status Lsnrctl status

Startup

Support parameters

STARTUP Options | Upgrade_options

Options: [Force] [RESTRICT] [pfile=filename] [QUIET] [MOUNT [dbname]

| [OPEN [Open_options] [dbname]] | Nomount],

Nomount, MOUNT, open are the three stages of startup and cannot exist simultaneously in the command. Among them, Open_options is: READ {only

| WRITE [RECOVER]} | RECOVER.

Upgrade_options: [pfile=filename] {upgrade | Downgrade} [QUIET]

The complete boot process for the Oracle database consists of the following 3 steps:

To put it simply, start the instance -- load the database --and open the database .

--------------------------------------------------------------------------------------------------------------- ---

1. Create and launch an instance corresponding to the database.

When you launch an instance, a series of background processes and service processes are created for the instance, and memory structures such as the SGA area are created in memory. Only the initialization parameter file is used during instance startup, and the database is not affected by the startup of the instance. If the initial parameter is set incorrectly, the instance will not start.

2. Load the database for the instance.

When the database is loaded, the instance opens the control file for the database, obtains the database name from the control file, the location and name of the data file, and other information about the physical structure of the database, ready to open the database. If the control file is corrupted, the instance will not be able to load the database. During the load database phase, the instance does not open the physical files of the database----data files and redo log files.

3. Set the database to open.

When you open a database, the instance opens all of the data files and redo log files that are online. Any one of the data files or redo log files in the control file does not open properly, and the database returns an error message, which requires database recovery.

A normal user can access the database only when the database is set to open and the database is in a healthy state. In many cases, starting the database is not done directly by completing the 3 steps above, but by performing the necessary administrative actions before the database goes into normal operation. Therefore, a variety of different startup modes are used for different database maintenance operations.

Because different stages of the Oracle database startup process can perform different maintenance operations on the database, corresponding to our different requirements, we need different schemas to start the database.

Small white: Before launching the instance, you need to start Sql*plus and connect to Oracle as a user.

Start-Up mode detailed

1.NoMount mode (boot instance does not load database)

Command: Startup Nomount

Explanation: This startup mode only creates instances, does not load the database, Oracle creates a variety of memory structures and service processes for the instance, and does not open any data files. In Nomount mode, you can access only those data dictionary views related to the SGA area, including V$parameter, V$SGA, v$process, and V$session, all of which are obtained from the SGA area, regardless of the database. Non-installation boot, this way startup executable: Rebuild the control file, rebuild the database, read the Init.ora file, start instance, that is, start the SGA and background process, this boot only need Init.ora files.

Mode use:

(1) Create a new database;

(2) Rebuilding the control file.

2.Mount mode (load database without opening database)

Command: Startup Mount

Explanation: This startup mode will load the database for the instance, but keep the database off state. Because the database control file needs to be opened when the database is loaded, neither the data file nor the redo log file can read and write, so the user cannot manipulate the database. In Mount mode, you can access only those data dictionary views associated with the control file, including V$thread, V$controlfile, V$database, V$datafile, and V$logfile, which are all obtained from the control file.

Mode use:

(1) Renaming data files;

(2) Add, delete or rename redo log files;

(3) Perform the database Full recovery operation;

(4) Change the archive mode of the database.

3.Open mode (Open database normally)

Command: Startup [Open]

Explanation: Normal 3 steps to start a database.

Mode use: Usually do not do what the database maintenance, like only to do application development, with this model is good.

4. Forced Start mode

Command: Startup force

Usage & Explanation: In some cases, you can try to force startup mode when you cannot start the database successfully using the previous modes.

You can also switch between startup modes by using the ALTER DATABASE statement. Also, you can set different states for the database to use for different operations, such as the subject/non-restricted pumping state, read-only.

Use the ALTER DATABASE statement to switch between startup modes.

(1) switch from Nomount mode to mount mode (no switch from Mount to Nomount):

Command: ALTER DATABASE MOUNT;

(2) when the database status is off, switch to open mode

Command: ALTER DATABASE OPEN;

(3) in open mode, you can also choose to set the database to an unrestricted and restricted state.

Command:

When you start open mode, add the Restrict keyword: startup restrict

Set or cancel a restricted state: Alter system enable\disable restricted session;

Explain:

The non-restricted state is the state that we normally use for application development.

Restricted state , when the Open database is set to a restricted state, only create session and Restricted session system permissions or users with SYSDBA and Syspore system permissions can connect to the database. However, after entering the restricted state, there may still be active normal user sessions in the system.

Restricted state use:

(1) Perform data import or export operations;

(2) Temporarily deny access to the database for ordinary users;

(3) Perform a database migration or upgrade operation.

(4) Read-only status

Set read-only command: ALTER DATABASE open read only;

Cancel read-only command: ALTER DATABASE open read write;

Usage & Explanation: When a normally open database is set to read-only, the user can only query the data, but cannot modify the database object in any way. In a read-only state, it is possible to ensure that the contents of the data files and redo log files are not modified, but do not restrict operations that do not write to the data file and redo log files.

Close the database and instance

Starting with the database, shutting down the database and the instance is also divided into 3 steps: Close the database and instance unload the database ---> terminate the instance .

(1) Close the database, Oracle writes the contents of the Redo log cache to the redo log file, writes the changed data in the database cache to the data file, and then closes all the data files and redo log files, and the control file of the database is still open. However, because the database is turned off, users cannot access the database.

(2) Unload the database, after the database is closed, the routine can be uninstalled, the control file is closed at this time, but the routine still exists.

(3) Terminate the routine, the process terminates, and the memory SGA area allocated to the routine is recycled.

1.Nomal (normal shutdown mode)

Command: Shutdown nomal

Explanation: When the data is closed normally, Oracle performs the following actions:

(1) Prevent any user from establishing a new connection.

(2) Wait for all currently connected users to actively disconnect (in this way, Oracle does not immediately break the current user's connection, these users still operate related actions)

(3) Once all users are disconnected, shut down, unload the database immediately, and terminate the instance. (therefore, when you normally close the database in the normal way, you should notify all online users to disconnect as soon as possible)

2.Immediate (immediate close)

Command: Shutdown immediate

Explain:

(1) Prevent any user from establishing a new connection, while preventing the current connected user from starting any new transactions.

(2) Oracle does not wait for the online user to actively disconnect, forcing the user to terminate the current transaction and rollback any uncommitted transactions. (This method can take a long time to terminate and rollback transactions if there are too many uncommitted transactions)

(3) Directly shut down, unload the database, and terminate the instance.

3.Transactional (transaction shutdown mode)

Command: Shutdown transactional

Explanation: In this way between the normal shutdown mode and the immediate shutdown mode, the response time will be relatively fast, processing will be more appropriate. The execution process is as follows:

(1) Prevent any user from establishing a new connection, while preventing the current connected user from starting any new transactions.

(2) Wait for all uncommitted active transactions to complete and disconnect the user immediately.

(3) Directly shut down, unload the database, and terminate the instance.

4.Abort (end-off mode)

Command: Shutdown abort

Explanation: This is a rough way to close, and when the previous 3 ways cannot be closed, you can try to use the termination method to shut down the database. However, shutting down the database in this way will lose a portion of the data, and when the instance is restarted and the database is opened, the background process Smon performs an instance recovery operation. In general, you should avoid using this method to close the database as much as possible. The execution process is as follows:

(1) Prevent any user from establishing a new connection, while preventing the current connected user from starting any new transactions.

(2) immediately terminates the currently executing SQL statement.

(3) No uncommitted transactions are returned.

(4) Disconnect all users directly, shut down, unload the database, and terminate the instance.

Oracle database startup and shutdown various ways to organize

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.