因host命令導致無法正常SHUTDOWN的實驗,hostshutdown

來源:互聯網
上載者:User

因host命令導致無法正常SHUTDOWN的實驗,hostshutdown

SHUTDOWN有幾個參數可以使用:

SHUTDOWN NORMAL:NORMAL也是預設的子句,執行的條件是

No new connections are allowed after the statement is issued.

Before the database is shut down, the database waits for all currently connectedusers to disconnect from the database.

下次啟動時不需要任何執行個體恢複過程。

SHUTDOWN IMMEDIATE:執行的情境是

To initiate an automated and unattended backup.

When a power shutdown is going to occur soon.

When the database or one of its applications is functioning irregularly and youcannot contact users to ask them to log off or they are unable to log off.

執行的條件是

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 transactionsexist, this method of shutdown might not complete quickly, despite its name.)

Oracle Database does not wait for users currently connected to the database todisconnect. The database implicitly rolls back active transactions and disconnectsall connected users.

同樣地,下次啟動時不需要任何執行個體恢複過程。

SHUTDOWN TRANSACTIONAL:執行的情境是需要進行例行的執行個體停止,但首先允許所有活動的交易完成,執行的條件是

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 isdisconnected.

At this point, the instance shuts down just as it would when a SHUTDOWNIMMEDIATE statement is submitted.

下次啟動時不需要任何執行個體恢複過程。

這種關閉操作不會讓用戶端丟失任務,同時不要求所有使用者退出。

SHUTDOWN ABORT:執行的情境是

You need to shut down the database instantaneously (for example, if you know apower shutdown is going to occur in one minute).

You experience problems when starting a 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 areimmediately terminated.

Uncommitted transactions are not rolled back.

Oracle Database does not wait for users currently connected to the database todisconnect. The database implicitly disconnects all connected users.

下次啟動時將需要執行個體恢複過程。


可以看出ABORT是一種暴力的關閉,不會隱式地復原交易,由於仍存在髒塊,所以下次啟動時需要進行執行個體恢複。


實驗:

1. 執行shutdown normal命令關閉資料庫

SQL> shutdown normal

發現提示SHUTDOWN: waiting for logins to complete.

從上面的介紹看,使用shutdown normal的方式關閉資料庫,不允許新串連接入,同時需要所有已串連的用戶端斷開後,才能繼續正常關閉。懷疑此處可能存在仍未斷開的串連。

使用kill -9 7255仍不起作用。


2. 執行shutdown immediate命令關閉資料庫

於是直接CTRL+C中斷shutdown normal,然後使用shutdown immediate命令關閉資料庫

SQL>shutdown immediate


此時提示SHUTDOWN: Active processes prevent shutdown operation

MOS上有篇文章(416658.1)專門介紹了immediate出現這種報錯的問題,給出的原因是:

“If the DB Control repository is running on the database target against which shutdown immediate was attempted then an incorrect order of events seems used.You should stop DB Control first to get rid of all connections between DB Control and the repository database and then shutdown the database with 'shutdown immediate'.”

意思是說可能DB Control庫正在執行一些事件,需要停止DB Control避免所有DB Control和庫之間的串連,然後才能執行shutdown immediate關閉,但這裡我沒有這樣可能的操作,應該是沒有普通使用者未執行exit的情境,想一想,原來之前使用SYS登入後用過host切換到OS下,但並未切回退出,因此可能由於這樣的問題,導致shutdown immediate出現hang的情況


3. 執行shutdown abort命令關閉資料庫

按照MOS的說法,使用

SQL> shutdown abort   直接關閉

SQL> startup restrict     允許具有restrict session許可權的使用者才能登陸,換句話,避免使用者再登陸導致無法正常關閉

SQL> shutdown normal 執行normal正常關閉


此時一切都安靜了。


總結

1. 非到萬不得已盡量不要使用ABORT,誰知道會出現什麼詭異的事情。

2. 執行關閉前,建議斷開所有使用SYS串連的會話,特別是使用host切換OS的串連,可能會不注意,這點是教訓。

相關文章

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.