最佳解答者
LOG SHIPPING問題請教

問題
-
您好:
我於網路上找到不用企業版的方式來做LOG SHIPPING
http://itknowledgeexchange.techtarget.com/sql-server/log-shipping-without-sql-server-enterprise-edition/
大致整理如下,不知是否可行?
1).PRIMARY SERVER:backup log
BACKUP SERVER:restore log WITH STANDYBY
準備要start shipping the transaction log.
Q1.可以直接restore log嗎,不需先restore database?
2).PRIMARY:設定一個job,定時備份LOG到 網芳
程式:
backup log Northwind to disk='\\backupsql\BackupFolder\northwind.log' with NOINIT, NOSKIP, NOFORMAT
go
3).backup server:於job中加入
osql -S BackupSQL -E -Q "msdb.dbo.sp_start_job 'Restore Northwind Log'"
4).backup server :Setup a restore job 『Restore Northwind Log』
The restore job will have four steps in it.
4-1). (T/SQL):確保沒人使用backup server
/*This first part of the code ensures that no one is using the database that we are about to restore.
If we don't do this then the restore will fail.*/
declare @spid as varchar(10)
declare @CMD as varchar(1000)
declare cur CURSOR for select spid from master.dbo.sysprocesses where dbid =
(select dbid from sysdatabases where name = 'Northwind')
open cur
fetch next from cur into @spid
while @@FETCH_STATUS = 0
BEGIN
set @CMD = 'kill ' + @spid
exec (@CMD)
fetch next from cur into @spid
END
close cur
deallocate cur
go
4-2).(OS Command):
del d:\RestoreFolder\Northwind.2.log
REM /*This removed the last file we processed.*/
4-3).(OS Command):
move d:\RestoreFolder\Northwind.log d:\RestoreFolder\Northwind.2.log
REM /*This moves the current file into place for processing.*/
4-4).(T/SQL):
declare @i int
declare @j int
set @j = 1
set @i = 0
restore headeronly from disk='d:\RestoreFolder\Northwind.2.log'
/*This tells us how many transaction log backups there are in the file that we need to restore.*/
set @i = @@ROWCOUNT
while @i+1 > (@j) /*This loop runs us through the file restoring the logs in order.*/
BEGIN
restore log Northwind from disk='d:\RestoreFolder\Northwind.2.log'
WITH FILE = @j,STANDBY = 'F:\MSSQL\Backup\RMDBArchive.sby'
/*This keeps the database in standby mode ready for more restores.*/
set @j = @j + 1
END
If your folders don’t exist between the two servers you’ll need to add the MOVE parameter to
the restore commands.
Q2.步驟(4)這應該是用CMD來做嗎?
Q3.若PRIMARY本機就有做完全+LOG備份,這再做
backup log ..... with NOINIT, NOSKIP, NOFORMAT
應該會有衝突吧?- 已移動 ricoismeModerator 2012年8月15日 上午 01:42 資料庫建置相關 (從:資料庫與程式開發(SQL Server Development))
解答
-
Log shipping is just log backup on source then restore it on target, the issue here is that express doesn't have sql agent. Therefore, have to schedule backup jobs in windows task scheduler.
- 已標示為解答 softballnow 2012年8月17日 上午 12:11
-
雖然我不是很建議這樣的作法,自己參考看看吧...
http://www.dotblogs.com.tw/ricochen/archive/2012/08/16/74091.aspx
保證解答-微軟技術支援服務
- 已標示為解答 softballnow 2012年8月17日 上午 12:11
所有回覆
-
1.一定要先還原 DB
2.你可以使用SSMS設定log shipping時,利用GUI來設定還原交易記錄檔案到次要資料庫
3.建立了Log Shipping就不需要額外建立備份交易記錄檔案
還有你的主要資料庫需要使用完整復原模式或大量紀錄才能使用該功能
保證解答-微軟技術支援服務
-
您好:
謝謝您.
跟您確認一下:
1.要先PRIMARY SERVER 先完整備份,all.bak
在將檔案all.bak resrore 到 backup server 嗎?
3.我目前是要將 2005EXPRESS(PRIMARY SERVER)的資料 備份到 2005 Enterprise (BACKUP SERVER)
所以可能需要用類似這樣的方式來做.
另外,比如原有 express2005 每天01:00做一次 完整備份,每小時做一次 LOG備份
這時候又要做,express2005的 log shipping: 第一次做完整備份,其他 每1或2小時 log 備份,其他時間應該都是做LOG 備份,不在做完整備份?
這樣ok嗎?
謝謝
-
- 已提議為解答 Daniel-Liang 2012年8月15日 上午 04:49
-
您好:
謝謝.
之前有看過 說要standard以上版本才有支援 log shipping
但,我於網站上找,他不是用ssms來做的
所以post出來,想請教 這樣的方式是否可行.
謝謝!
不行
保證解答-微軟技術支援服務
-
我前面就說過了 sql2005 express不支援 log shipping... 你要同步兩端資料庫,就請使用standard以上的版本
順便補充TSQL和SSMS的設定
http://msdn.microsoft.com/zh-tw/library/ms190640
- 已編輯 ricoismeModerator 2012年8月15日 上午 08:58 補充參考
-
Log shipping is just log backup on source then restore it on target, the issue here is that express doesn't have sql agent. Therefore, have to schedule backup jobs in windows task scheduler.
- 已標示為解答 softballnow 2012年8月17日 上午 12:11
-
您好:
謝謝.
目前應該是會用 win cmd來做 task schedular ,以達到 log shipping的功能測試.
不過想請問一下:
我於
1.primary Server :
BACKUP DATABASE E68
TO disk='c:\bk\E68.bak' with init2.於Bakcup Server 要先做 REstore ... Standy ,REPLACE.
卻無法成功.
RESTORE DATABASE S69
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE結果:
RESTORE DATABASE S69
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE
-------------------------------------------
我有參考
http://msdn.microsoft.com/zh-tw/library/ms178034%28v=sql.105%29.aspx
但不還是做不出來...
謝謝!
-
您好:
不能用standby 選項嗎?
我看上面範例說要先
PRIMARY SERVER:backup log
bACKUP SERVER:restore log WITH STANDYBY*****************錯誤訊息如下:
RESTORE DATABASE S69
結果:
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE
RESTORE DATABASE S69
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE****************
我用
RESTORE DATABASE GF_ERP
FROM DISK='F:\2003AD_SHARE\E68.bak' WITH RECOVERY,REPLACE或
RESTORE DATABASE GF_ERP
FROM DISK='F:\2003AD_SHARE\E68.bak' WITH noRECOVERY,REPLACE都可正常restoore回去.
-
雖然我不是很建議這樣的作法,自己參考看看吧...
http://www.dotblogs.com.tw/ricochen/archive/2012/08/16/74091.aspx
保證解答-微軟技術支援服務
- 已標示為解答 softballnow 2012年8月17日 上午 12:11
-
您好:
不能用standby 選項嗎?
我看上面範例說要先
PRIMARY SERVER:backup log
bACKUP SERVER:restore log WITH STANDYBY*****************錯誤訊息如下:
RESTORE DATABASE S69
結果:
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE
RESTORE DATABASE S69
FROM 'F:\2003AD_SHARE\E68.bak'
WITH STANDBY ='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\S69_log.ldf' ,REPLACE****************
我用
RESTORE DATABASE GF_ERP
FROM DISK='F:\2003AD_SHARE\E68.bak' WITH RECOVERY,REPLACE或
RESTORE DATABASE GF_ERP
FROM DISK='F:\2003AD_SHARE\E68.bak' WITH noRECOVERY,REPLACE都可正常restoore回去.
-
ricoisme您好:
我參考您的 http://www.dotblogs.com.tw/ricochen/archive/2012/08/16/74091.aspx 說明
目前 在 db2(backup server )上是 待命/唯獨的狀態
就無法執行 步驟五
CREATE PROCEDURE dbo.usp_GetRestoreCount
與
CREATE PROCEDURE dbo.usp_RestoreLog
的動作了?
謝謝.
我是建立在master............
USE [master]
GO
保證解答-微軟技術支援服務