[Guide]Starting Up and Shutting Down
Using SQL*Plus to Start Up a Database
Oracle locates your initialization parameter file by examining filenames in the following order:
1.spfile$ORACLE_SID.ora
2.spfile.ora (in a Real Application Clusters environment one server parameter file is used to store the initialization parameter settings for all instances)
3.init$ORACLE_SID.ora
You cannot start a database instance if you are connected to the database through a shared server process.
Starting an Instance and Mounting a Database
Mount 状态下可以做以下工作:
1.Renaming datafiles
2.Adding, dropping, or renaming redo log files
3.Enabling and disabling redo log archiving options
4.Performing full database recovery
Restricting Access to a Database at Startup
RESTRICT 状态下可以做的工作:
1.Perform an export or import of database data
2.Perform a data load (with SQL*Loader)
3.Temporarily prevent typical users from using data
4.During certain migration and upgrade operations
Forcing an Instance to Start
何时使用 STARTUP FORCE
1.You cannot shut down the current instance with the SHUTDOWN NORMAL, SHUTDOWN IMMEDIATE, or SHUTDOWN TRANSACTIONAL commands.
2.You experience problems when starting an instance.
If an instance is running, STARTUP FORCE shuts it down with mode ABORT before restarting it.
Altering Database Availability
Opening a Database in Read-Only Mode
While opening a database in read-only mode guarantees that datafile and redo log files are not written to, it does not restrict database recovery or operations that change the state of the database without generating redo.
If a query against a database in read-only mode uses temporary tablespace, for example to do disk sorts, then the issuer of the query must have a locally managed tablespace assigned as the default temporary tablespace. Otherwise, the query will fail.
Note:
You cannot use the RESETLOGS clause with a READ ONLY clause.
Quiescing a Database
This quiesced state allows you or other administrators to perform actions that cannot safely be done otherwise. These actions are categorized as follows:
1.Actions that can fail if concurrent user transactions access the same object.
2.Actions whose undesirable intermediate effect can be seen by concurrent user transactions.
Note:
For this release of Oracle9i, in the quiesce database context a DBA is defined as user SYS or SYSTEM. Other users, including those with the DBA role are not allowed to issue the ALTER SYSTEM QUIESCE DATABASE statement or proceed after the database is quiesced.
Placing a Database into a Quiesced State
ALTER SYSTEM QUIESCE RESTRICTED;
Any non-DBA active sessions will proceed until they become inactive. An active session is defined as a session that is currently inside of a transaction, a query, a fetch, or a PL/SQL statement; or a session that is currently holding any shared resources (for example, enqueues). No inactive sessions are allowed to become active. If a user, for example, issues a SQL query in an attempt to force an inactive session to become active, the query will appear to be hung. When the database is later unquiesced, the session is resumed, and the blocked action (for example, the previously mentioned SQL query) will be processed.
Once all non-DBA sessions become inactive, the ALTER SYSTEM QUIESCE RESTRICTED statement finishes, and the database is considered as in a quiesced state. In an Oracle Real Application Clusters environment, this statement affects all instances, not just the one that issues the statement.
Note:
You must have the Database Resource Manager feature activated, and it must have been activated since instance startup (all instances in an Oracle Real Application Clusters environment) to successfully issue the ALTER SYSTEM QUIESCE RESTRICTED statement. It is through the facilities of the Database Resource Manager that non-DBA sessions are prevented from becoming active. Also, while this statement is in effect, any attempt to change the current resource plan will be queued until after the system is unquiesced.
The ALTER SYSTEM QUIESCE RESTRICTED statement may wait a long time for active sessions to become inactive. If you interrupt the request, or if your session abnormally terminates for some reason before all active sessions are quiesced, Oracle will automatically undo any partial effects of the statement.
If a query is carried out by successive multiple Oracle Call Interface (OCI) fetches, the ALTER SYSTEM QUIESCE RESTRICTED statement does not wait for all fetches to finish; it only waits for the current fetch to finish.
For both dedicated and shared server connections, all non-DBA logins after this statement is issued are queued by the Database Resource Manager, and are not allowed to proceed. To the user, it appears as if the login is hung. The login will resume when the database is unquiesced.
The database remains in the quiesced state even if the session that issued the statement exits. A DBA must log in to the database to issue the statement that specifically unquiesces the database.
While in the quiesced state, you cannot use file system copy to backup the database's datafiles as cold backups, even if you do a checkpoint on every instance. The reason for this is that in the quiesced state the file headers of online datafiles continue to look like they are being accessed. They do not look the same as if a clean shutdown were done. Similarly, to perform a hot backup of the datafiles of any online tablespace while the database is in a quiesced state, you are still required to first place the tablespace into backup mode using the ALTER TABLESPACE... BEGIN BACKUP statement.
Restoring the System to Normal Operation
ALTER SYSTEM UNQUIESCE;
All non-DBA activity is allowed to proceed. In an Oracle Real Application Clusters environment, this statement is not required to be issued from the same session, or even the same instance, as that which imposed the quiesce state. If the session issuing the ALTER SYSTEM UNQUIESCE statement should terminate abnormally, the Oracle database server ensures that the unquiesce operation finishes.
Viewing the Quiesce State of an Instance
The V$INSTANCE view can be queried to see the current state of an instance. It contains a column named ACTIVE_STATE, whose values are shown in the following table:
ACTIVE_STATE Description
NORMAL Normal unquiesced state
QUIESCING Being quiesced, but there are still active non-DBA sessions running
QUIESCED Quiesced, no active non-DBA sessions are active or allowed
Suspending and Resuming a Database
The ALTER SYSTEM SUSPEND statement suspends a database by halting all input and output (I/O) to datafiles (file header and file data) and control files, thus allowing a database to be backed up without I/O interference. When the database is suspended all preexisting I/O operations are allowed to complete and any new database accesses are placed in a queued state.
In an Oracle Real Application Clusters environment, if the suspend command is entered on one system, all active instances in a given cluster are quiesced. However, do not start a new instance while you suspend another instance, since the new instance will not be suspended.
Use the ALTER SYSTEM RESUME statement to resume normal database operations. You can specify the SUSPEND and RESUME from different instances.
The suspend/resume feature is useful in systems that allow you to mirror a disk or file and then split the mirror, providing an alternative backup and restore solution. If you use a system that is unable to split a mirrored disk from an existing database while writes are occurring, then you can use the suspend/resume feature to facilitate the split.
The suspend/resume feature is not a suitable substitute for normal shutdown operations, however, since copies of a suspended database can contain uncommitted updates.
Caution:
Do not use the ALTER SYSTEM SUSPEND statement as a substitute for placing a tablespace in hot backup mode. Precede any database suspend operation by an ALTER TABLESPACE BEGIN BACKUP statement.
语法:
ALTER SYSTEM SUSPEND;
ALTER SYSTEM RESUME;
V$INSTANCE 中 DATABASE_STATUS 显示处于哪种状态:
DATABASE_STATUS
SUSPENDED
ACTIVE
Posted by Sky at 11:35 PM | Permalink | comments(0) | Edit | Database