最近在配置SQL 2008的發布訂閱功能時,遇到了幾個小錯誤,順便歸納總結一下(以后碰到各類關於發布訂閱的錯誤都將收錄、更新到這篇文章),方便自己在以后碰到這類問題時,能夠迅速解決問題。畢竟人的記憶能力有時效性,時間久了,有可能有些東西就模糊了或忘了,好記性不如爛筆頭。
錯誤1:在數據庫服務器上新建本地發布服務時報錯。
(圖1)
報錯的具體細節如下所示:

TITLE: New Publication Wizard ------------------------------ Microsoft SQL Server Management Studio is unable to access replication components because replication is not installed on this instance of SQL Server. For information about installing replication, see the topic Installing Replication in SQL Server Books Online. For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1&EvtSrc=Microsoft.SqlServer.Management.UI.ReplUtilitiesErrorSR&EvtID=ReplicationNotInstalled&LinkId=20476 ------------------------------ ADDITIONAL INFORMATION: Replication components are not installed on this server. Run SQL Server Setup again and select the option to install replication. (Microsoft SQL Server, Error: 21028) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.4000&EvtSrc=MSSQLServer&EvtID=21028&LinkId=20476 ------------------------------ BUTTONS: OK ------------------------------
查看具體原因,是因為安裝數據庫實例時,沒有選擇安裝Replication components,需要添加Replication components,首先找到安裝光盤或安裝鏡像文件,掛載到光驅或拷貝到某個文件目錄,例如,我這邊掛載后的安裝介質位於Z盤,在運行里面輸入cmd命令,轉到Z盤,輸入下面命令:
setup.exe /q /Features=Replication /InstanceName=MSSQLSERVER /ACTION=INSTALL /IAcceptSQLServerLicenseTerms ,然后耐心等待安裝完成,從網上搜索的資料看,好像下面命令start /wait X:\Servers\setup.exe /qb INSTANCENAME=MSSQLSERVER ADDLOCAL=SQL_Replication也可,不過,這條命令我還沒有試驗過。不保證能夠順利執行。
錯誤2:The Process could not execute ‘sp_repcmd’ on ‘xxxx’
(圖2)
報錯的具體細節如下所示:
DESCRIPTION: Replication-Replication Transaction-Log Reader Subsystem: agent xxxxx failed. The process could not execute 'sp_replcmds' on 'xxxxxx'.
從網上查到的資料,只需修改數據庫的Owner設置為sa即可解決,但是本質原因是啥?我沒搞明白,后來查了一下資料:http://stackoverflow.com/questions/2723061/sql-server-2008-replication-failing-with-process-could-not-execute-sp-replcmds 顯然不一定要修改數據庫的Owner為sa也可。看來這應該是權限問題引起的。
(圖3)
錯誤3:Replication-Replication Distribution Subsystem agent xxxxxxx failed. The process could not read file 'xxxxxxx' due to OS error 3.
(圖4)
查看SQL SERVER日志文件,發現很多類似錯誤:
Date 6/28/2013 10:40:01 AM
Log SQL Server (Current - 6/28/2013 10:39:00 AM)
Source spid454
Message
Replication-Replication Distribution Subsystem: agent xxxxxxxxxx failed. The process could not read file 'xxxxxxxxxxxxxxxxxx' due to OS error 3.
Date 6/28/2013 10:40:01 AM
Log SQL Server (Current - 6/28/2013 10:39:00 AM)
Source spid454
Message
Error: 14151, Severity: 18, State: 1.
產生這個錯誤的原因是因為使用請求訂閱或遠程分發服務器時,您必須指定一個 UNC 網絡共享,例如 \\<computername>\snapshot,而不是為快照文件夾的本地路徑。單擊發布屬性,查看Snapshot屬性,發現快照文件位於G:\GEG_MESDB文件夾里,但是此時這里修改不了,只能去掉“Put files in the default folder"選項,勾選”Put Files in the following folder“選項,輸入網絡路徑,即可解決上面這個錯誤。
錯誤4:
Date 7/12/2013 1:20:38 PM
Log SQL Server (Current - 7/12/2013 1:10:00 PM)
Source spid326
Message
Replication-Replication Snapshot Subsystem: agent EGVNT02-MESDB-EGV_MESDB-1 failed. The replication agent had encountered an exception.
Source: Unknown
Exception Type: System.UnauthorizedAccessException
Exception Message: Access to the path '\\EGVNT02\EGV_MESDB_Replication\unc\EGVNT02_MESDB_EGV_MESDB\20130712132037\' is denied.
Messa
文件夾權限問題,我用NT 賬號T1登錄數據庫,但是配置過程中用的是NT賬號T2,共享文件夾沒有授權給NT賬號T2,所以報上面錯誤。
參考資料:
http://www.sqlserverclub.com/essentialguides/how-to-install-sql-server-2005-replication.aspx