shutting down a database
共有四种模式的关机:
1.normal
2.immediate
3.abort
4.tranacatsion
一.shutting down with the normal mode
When you shut down a database with the normal mode, the database waits for all connected users to disconnect before shutting down. Normal mode is the default mode of shutdown.
shutdown normal
srvctl stop database -db db_unique_name -stopoption normal
1.No new connections are allowed after the statement is issued.
2.Before the database is shut down, the database waits for all currently connected users to disconnect from the database.
The next startup of the database will not require any instance recovery procedures.
二.shutting down with the immediate mode
When you shut down a database with the immediate mode, Oracle Database terminates any executing SQL statements and disconnects users. Active transactions are terminated and uncommitted changes are rolled back.
shutdown immediate
srvctl stop database -db db_unique_name -stopoption immediate
-
No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
-
Any uncommitted transactions are rolled back. (If long uncommitted transactions exist, this method of shutdown might not complete quickly, despite its name.)
-
Oracle Database does not wait for users currently connected to the database to disconnect. The database implicitly rolls back active transactions and disconnects all connected users.
The next startup of the database will not require any instance recovery procedures.
三.shutting down with the transactional mode
shutdown transactional
srvctl stop database -db db_unique_name -stopoption transactional
When you shut down a database with transactional mode, the database prevents users from starting new transactions, but waits for all current transactions to complete before shutting down. This mode can take a significant amount of time depending on the nature of the current transactions.
-
No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
-
After all transactions have completed, any client still connected to the instance is disconnected.
-
At this point, the instance shuts down just as it would when a
SHUTDOWN IMMEDIATE
statement is submitted.
The next startup of the database will not require any instance recovery procedures.
A transactional shutdown prevents clients from losing work, and at the same time, does not require all users to log off.
四.shutting down with the abort mode
You can shut down a database instantaneously by aborting the database instance.
-
No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
-
Current client SQL statements being processed by Oracle Database are immediately terminated.
-
Uncommitted transactions are not rolled back.
-
Oracle Database does not wait for users currently connected to the database to disconnect. The database implicitly disconnects all connected users.
The next startup of the database will require automatic instance recovery procedures.
五.shutdown timeout
Shutdown modes that wait for users to disconnect or for transactions to complete have a limit on the amount of time that they wait.
If all events blocking the shutdown do not occur within one hour, the shutdown operation aborts with the following message: ORA-01013: user requested cancel of current operation
. This message is also displayed if you interrupt the shutdown process, for example by pressing CTRL-C
. Oracle recommends that you do not attempt to interrupt an instance shutdown. Instead, allow the shutdown process to complete, and then restart the instance.
After ORA-01013
occurs, you must consider the instance to be in an unpredictable state. You must therefore continue the shutdown process by resubmitting a SHUTDOWN
command. If subsequent SHUTDOWN
commands continue to fail, you must submit a SHUTDOWN
ABORT
command to bring down the instance. You can then restart the instance.
总结:
shutdown normal 正常关闭
不允许新的连接,等待当前会话断开连接。
shutdown immediate 立即关闭
不允许新的连接,回滚未完成的会话,断开所有的连接。 ---我们进程用的关闭方式,但是如果有长时间未提交打的会话,回滚会需要很多时间。甚至无法完成。
shutdown transcational
不允许新的连接,等待所有会话完成之后断开所有连接。
shutdown abort
不允许新的连接,回滚为提交的会话。
ocp考题: