Deep understanding of Oracle database Startup and shutdown

Source: Internet
Author: User
Tags exit command line dba log connect sql rollback oracle database

The Oracle database provides several different ways to start and close the database, and this article will detail the differences between these startup and shutdown modes and their different capabilities.

first, start and close Oracle databases

for most Oracle DBAs, the most common way to start and close an Oracle database is server Manager at the command line. Since Oracle 8i, the system has concentrated all of Server Manager's functionality into Sql*plus, which means that the startup and shutdown of the database from 8i onwards can be done directly through sql*plus, without the additional need for Server Manager. However, the system retains the Server Manager tool to maintain backward compatibility. In addition, the system can be started and shut down through the graphical user tool (GUI) Oracle Enterprise Manager, and the graphical user interface instance Manager is very simple, no longer detailed here.

To start and shut down a database, you must log on as a user with Oracle administrator rights, usually by logging on to a user with sysdba privileges. Generally we use internal users to start and close the database (internal user is actually a synonym of the sys user to SYSDBA connections). A new version of the Oracle database will phase out internal this internal user, so it is best to set the DBA user to have SYSDBA permissions.

second, the database Startup (startup)

Starting a database requires three steps:

1. Create an Oracle instance (non-installation phase)
2. Install database by instance (Installation phase)
3, open the database (open phase)

In the startup command, you can control different startup steps for a database with different options.

1, STARTUP nomount

The Nonount option simply creates an Oracle instance. Reads the Init.ora initialization parameter file, starts the background process, initializes the system global area (SGA). The Init.ora file defines the configuration of the instance, including the size of the memory structure and the number and type of startup background processes. The instance name is set according to Oracle_sid and does not necessarily have to be the same as the name of the Open database. When the instance is open, the system displays a list of the SGA memory structure and size, as follows:

sql> startup Nomount ORACLE routines have started. Total System Global area 35431692 bytes Fixed Size 70924 bytes Variable Size 18505728 bytes Database buffers 16777216 b Ytes Redo buffers 77824 bytes

2. STARTUP MOUNT

This command creates an instance and installs the database, but does not open the database. The Oracle system reads the contents of the data file and the redo log file in the control file, but does not open the file. This open method is often used in database maintenance operations, such as renaming the data file, changing the redo log, and opening the archiving method. In this way, in addition to seeing the SGA system list, the system also gives a "database load complete" prompt.

3, STARTUP

This command completes all three steps to create an instance, install an instance, and open a database. At this point, the database makes the data files and redo log files online, and usually requests one or more rollback segments. In addition to the system can see the previous startup Mount method under all the prompts, but also give a "database has been opened" hint. At this point, the database system is in a normal working state and can accept user requests.

If you open a command by using the startup Nomount or the database on startup mount, you must use the ALTER DATABASE command to perform an open database operation. For example, if you open the database as a startup Nomount, that is, the instance has been created, but the database is not installed and opened. This is the following two commands that must be run for the database to start correctly.

ALTER DATABASE MOUNT; ALTER DATABASE OPEN;

If you start the database in startup mount, you can open the database by running only one of the following commands:

ALTER DATABASE OPEN;

4, other open mode

In addition to the three types of database open options described earlier, there are other options.

(1) STARTUP RESTRICT

In this way, the database will be opened successfully, but only some privileged users (users with DBA role) can use the database. This approach is commonly used to maintain databases, such as the data import/export operations, and do not want other users to connect to the database operation data.

(2) STARTUP FORCE

This command is actually a synthesis of forcibly shutting down the database (shutdown abort) and starting the database (startup) two commands. This command is used only if you have problems shutting down the database and you cannot close the database.

(3) ALTER DATABASE OPEN READ only

This command opens the database as read-only after the instance is created and the database is installed. A product database that only provides query functionality can be opened this way.

iii. Closure of the database (SHUTDOWN)

For the shutdown of the database, there are four different shutdown options, described below.

1. SHUTDOWN NORMAL

This is the database shutdown shutdown command indeed province option. That is to say, if you issue shutdown such an order, that is shutdown nornal meaning.

When this command is issued, any new connections will no longer be allowed to connect to the database. Before the database is closed, Oracle waits for all users currently connected to exit from the database before shutting down the database. Shutting down the database in this manner does not require any instance recovery at the next startup. But it's important to note that in this way, it may take days, maybe longer, to close a database.

2, SHUTDOWN IMMEDIATE

This is a common way to close a database, to close the database quickly, but to keep the database clean shut down, often in this way.

The SQL statement currently being processed by Oracle is immediately interrupted, and any transactions that are not committed in the system are rolled back. If there is a long uncommitted transaction in the system, it also takes a while to shut down the database in this way (the transaction rollback time). The system does not wait for all users connected to the database to exit the system, force the rollback of all current active transactions, and then disconnect all connected users.

3, SHUTDOWN transactional

This option is available only after Oracle 8i. This command is commonly used to schedule a shutdown of a database that is currently connected to the system and that the active transaction completes, and any new connections and transactions are not allowed after the command is run. After all active transactions have been completed, the database closes the database in the same way as shutdown immediate.

4, SHUTDOWN ABORT

This is the last move to close the database, but also in the absence of any way to close the database to be used in the way, generally do not use. You can consider shutting down the database in this way if the following conditions occur.

1, the database is in an abnormal working state, can not use shutdown normal or shutdown immediate such commands to close the database;

2, the need to immediately close the database;

3, when starting the database instance encountered problems;

All running SQL statements will be aborted immediately. Any uncommitted transactions will not be rolled back. Oracle also does not wait for users who are currently connected to the database to exit the system. The next time you start the database, an instance recovery is required, so the next boot may take more time than usual.

Table 1 can clearly see the differences and connections between the four different close databases.

Table 1 comparison tables for different ways of shutdown database

Off mode A I T N
Allow new connections X X X X
Wait until the current session is aborted X X X
Wait until the current transaction is aborted X X
Force checkpoint, close all files X

of which: A-abort i-immediate t-transaction

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.