標籤:rds 就會 server ice orm comm 支援 unity roc
SQL SERVER的事物記錄傳送(log shipping)功能,相信很多人都使用過或正在應用,這是MS SQL提供的一個非常強大的功能,一般需要一個主要資料庫伺服器(primary/production database server)和次要資料庫伺服器(standby server)來完成這個配置,預設情況下,主要資料庫和次要資料庫的版本應該是一致的,那麼如果這兩個資料庫版本不一致,會不會有什麼問題?還能做log shipping配置嗎?
那麼資料庫版本不一致分兩種情況:
1: 類似於MS SQL 2005 64 bit SP4 與MS SQL 2005 SP3 32 bit這樣的版本差別
2: 完全不同的版本,例如MS SQL SERVER 2005 和 MS SQL SERVER 2008.
可能有人就要吐槽了,為啥要搞成不同的版本呢,這不是自己沒事找事做嗎?出現這種情況,真是一言難盡,曆史的問題.....等等,你叫我怎麼吐槽呢?好了,咱們就不糾結這些雞毛蒜皮的事情了,現在回到上面的問題上來。
至於第一種情況,完全可以做log shipping,不存在什麼問題,我做了兩個這樣的案例,都配置成功,而且工作的好好的。
案例1的環境:
資料庫伺服器 |
版本資訊 |
主要資料庫伺服器 |
Microsoft SQL Server 2005 - 9.00.5000.00 (Intel X86) Dec 10 2010 10:56:29 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2) |
次要資料庫伺服器 |
Microsoft SQL Server 2005 - 9.00.5000.00 (X64) Dec 10 2010 10:38:40 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) |
案例2的環境:
資料庫伺服器 |
版本資訊 |
主要資料庫伺服器 |
Microsoft SQL Server 2005 - 9.00.4000.00 (Intel X86) Dec 10 2010 10:56:29 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2) |
次要資料庫伺服器 |
Microsoft SQL Server 2005 - 9.00.5000.00 (X64) Dec 10 2010 10:38:40 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) |
第二種版本不同的情況,也要細分多種不同情況:
1: 主要資料庫伺服器為SQL SERVER 2008, 次要資料庫伺服器為SQL SERVER 2005, 對於這種情況,這是完全行不通的,因為你在SQL SERVER 2008上的備份,不能在低版本SQL SERVER 2005上還原(當然更低的版本也是如此),以此類推,Primary Server is SQL 2012 Std and Secondary Server is SQL 2008 R2 Std 這種情況也是行不通的。
2:主要資料庫伺服器為SQL SERVER 2005, 次要資料庫伺服器為SQL SERVER 2008R2,對於這種情況,log shipping部署時,你選擇Standby Mode時,就會報錯:
相關出錯資訊:System.Data.SqlClient.SqlError: This backup cannot be restored using WITH STANDBY because a database upgrade is needed. Reissue the RESTORE without WITH STANDBY. (Microsoft.SqlServer.Smo)
所以你只能選擇No Recovery mode選項,至於這個就有點雞肋了。關於上面出錯的原因,下面這段解釋非常清晰,明了(出處請見下面參考資料):
Each version of SQL Server has a database version number; for SQL 2000 it is 8, SQL 2005: 9 and SQL 2008: 10. When a database backup that came from a lower SQL Server version is restored, SQL Server will run an upgrade process to bring that older database version up to the database version supported by the new instance. This process is run automatically as part of SQL Server’s recovery process. The recovery process itself is certain operations that need to happen to ensure the database is in a consistent state for user access (roll-forwards and roll-backs etc).
Placing a database in “Standby/Read Only” mode instructs SQL Server to recover the database after each restore, but also create a special standby file that contains information which will allow this recovery to be undone when it is time to do additional transaction logs restores.
However unfortunately, once a database has been upgraded it cannot be undone. This is why if you try and use the “Standby/Read Only” option when restoring a database of an older version SQL Server fails with
Msg 3180, Level 16, State 1, Line 1
This backup cannot be restored using WITH STANDBY because a database upgrade is needed. Reissue the RESTORE without WITH STANDBY.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
This error message essentially says you cannot bring an older database version online in “Standby/Read Only” mode.
But you can restore transaction logs and log shipping from an older database version to a newer database version when you keep the database offline. This is because the recovery (and upgrade process) for the database is deferred until the point you do actually bring the database online. This means you can log ship from an older version of SQL Server to a newer version until the point you bring that database online for user access.
翻譯如下(水平有限,僅供參考):
每一個版本的SQL Server資料庫都有相應版本號碼;例如SQL 2000是8,SQL 2005是9,SQL2008:10。當資料庫恢複一個從較低的SQL Server版本的備份時,SQL Server將執行一個升級過程,把那箇舊的資料庫版本升級到新執行個體支援的版本。這個過程是SQL Server的恢複過程中自動啟動並執行一部分。恢複過程本身就需要某些操作發生,以確保資料庫處於一致的狀態向前復原,向後復原等)。
把資料庫置於“待機/唯讀”模式不僅會指示SQL Server的每次還原後恢複操作,還會建立一個特殊的待命資料庫檔案,當它做其他交易記錄恢複時,包含的恢複撤銷時的資訊。
然而不幸的是,一旦資料庫已經升級,它不能被撤消。這就是為什麼如果你嘗試使用“待機/唯讀”選項時,舊版本的SQL Server資料庫恢複失敗的原因
Msg 3180, Level 16, State 1, Line 1
This backup cannot be restored using WITH STANDBY because a database upgrade is needed. Reissue the RESTORE without WITH STANDBY.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
這個錯誤訊息本質上是說,你不能把一箇舊的資料庫版本設定為聯機在“待機/唯讀”模式下。
但是你可以從一箇舊的資料庫版本還原交易記錄和記錄傳送到一個新的資料庫版本,當你保持資料庫離線。這是因為,為資料庫的恢複(升級過程中)被延遲,直到點你確實使資料庫聯機。這意味著您可以登入到一個新的版本,直到從舊版本的SQL Server使用者訪問您帶來的線上資料庫。
參考資料:
[http://connect.microsoft.com/SQLServer/feedback/details/362706/restore-of-2005-database-with-standby-doesnt-work]
[http://www.askthedbas.com/ask-the-dbas/2010/08/warm-standby-on-sql-server-2008-with-log-shipping-from-sql-server-2005.html]
[http://community.spiceworks.com/topic/316934-mirroring-and-log-shipping-with-different-sql-versions]
[http://technet.microsoft.com/zh-cn/library/bb895393(v=sql.105).aspx]
MS SQL 事物記錄傳送能否跨資料庫版本嗎?