SQL Server同步複製問題排查方法,sqlserver

來源:互聯網
上載者:User

SQL Server同步複製問題排查方法,sqlserver

1、應用複製的命令時在訂閱伺服器上找不到該行


解決方案:用系統預存程序sp_browsereplcmds(返回散發資料庫中儲存的可讀版本複製命令的結果集,並將其用作診斷工具。 此預存程序在散發者上對散發資料庫執行)

sp_browsereplcmds [ [ @xact_seqno_start = ] 'xact_seqno_start' ]    [ , [ @xact_seqno_end = ] 'xact_seqno_end' ]     [ , [ @originator_id = ] 'originator_id' ]    [ , [ @publisher_database_id = ] 'publisher_database_id' ]    [ , [ @article_id = ] 'article_id' ]    [ , [ @command_id= ] command_id ]    [ , [ @agent_id = ] agent_id ]    [ , [ @compatibility_level = ] compatibility_level ]
排查方法:在散發者—分發DB(distribution)

Use [distribution] go--a、通常事務序號,查到command_id=1的執行語句EXEC sp_browsereplcmds @xact_seqno_start='0x00044ED500008F3E00AB00000000',@xact_seqno_end='0x00044ED500008F3E00AB00000000' --查看同步對象表(在以上結果集中找到article_id欄位值)select *From MSarticles where article_id=344 


--第1個語句會出現以下兩種情況(a/b)

--a、更新時找不到該行

{CALL [dbo].[sp_MSupd_dbo表名] (.....)}

--b、刪除時找不到該行

{CALL [dbo].[sp_MSdel_dbo表名] (......}

瞭解同步預存程序:


解決方案(a、更新、b、刪除):在訂閱端把缺少的資料行新增(根據以上出錯ID加一條記錄)或用匯入匯出方法(SQL語句同步指定以上ID).(原因:訂閱端缺少資料行造成刪除或更新找不到資料行而出錯)

--c、新增時出錯

{CALL [dbo].[sp_MSins_dbo表] 


解決方案(c、新增時出錯):新增時出錯,解決方案根據提示可能是標識值或主健ID已在(刪除訂閱端該行資料)或表結構不值造成的


相關文章

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.