亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > 綜合 > 正文

鏡像切換Logreader Agent報錯:分發數據庫中可能存在不一致的狀態

2024-07-21 02:49:35
字體:
來源:轉載
供稿:網友
鏡像切換Logreader Agent報錯:分發數據庫中可能存在不一致的狀態

軟件環境:Windows Server 2008 R2 sp1 SQL Server 2008 R2 sp2

架構:ServerA(主體)+ServerB(鏡像)+ServerSub(訂閱)+ServerDist(分發)

特別注意:ServerDist分發服務器為單機,故開啟了Sync_With_Backup選項。

關于Sync_With_Backup:

初衷:簡單來說,開啟該選項,使得單機分發庫在宕機時,利用最近的系統數據庫和用戶數據庫備份,還原到一臺新的服務器上,即可使復制繼續工作成為可能。

需要注意的是:在分發庫開啟該選項,意味著發布庫的日志只有在分發庫被備份后才會截斷。

查看該選項是否開啟:

     SELECT name,is_sync_with_backup FROM sys.databases WHERE name LIKE 'distribution%'

image

開啟該選項:

sp_replicationdboption 'distribution','sync with backup','true'

場景:

在生產環境中,分發庫備份為半小時一次。

將主體從ServerA切換至ServerB時,Logreader Agent報錯:

image

直觀上可以看到,Logreader 認為dist_backup_lsn和dist_last_sn不一致,導致其無法繼續工作。下面我們實際去看一下這兩者到底是否一致。

下面是Logreader、Distribution Agent工作的步驟列表,為了方便,我都貼出來:

Log Reader Agent (logread.exe) – Sequence of Steps1.Calls sp_MSadd_LogReader_History to write to MSLogReader_History – “Starting Agent”2.sp_MShelp_logreader_agentid – Obtain log reader agent specific information for that publication 3.sp_MShelp_PRofile – Obtains profile information for the Log Reader4.MSadd_logreader_history to write MSlogreader_history – “Initializing” 5.sp_MSget_last_transaction – determine where the log reader agent left off reading the log. 6.Read the transaction log – sp_replcmds 7.Processes the returned commands from the sp_replcmds in batches by calling sp_MSadd_repl_commands 8.Marks this transaction as committed in distribution database by using sp_repldone procedure 9.Adjusts the identity range if necessary and if you are using Automatic Identity Range Management y calling sp_MSpub_adjust_identity 10.Calls sp_MSget_last_transaction to check the last transaction read and stored in MSReplication_transactions table 11.When all transactions are read, LogRead.exe calls sp_MSAdd_logreader_history and writes message to MSLogReader_history “1 transactions with 9 commands were delivered”•Distribution Agent (distrib.exe) - Sequence of Steps1.master.db.sp_msget_jobstate – get the status of the job (if it is already started) 2.sp_Msadd_distribution_history – MSDistribution_history – Starting agent 3.sp_MSSubscription_Status – whether subscription has expired or the snapshot is ready 4.sp_server_info- determines the collation 5.sp_mshelp_subscriber_info – retrieve subscriber information 6.sp_mshelp_subscription_agentid – determine the name of the distribution agent 7.sp_Msadd_distribution_history – Initializing message – Msrepl_distribution_history 8.sp_Msadd_distribution_history – Connecting to Subscriber - Msrepl_distribution_history 9.so_datatype_info – to determine the data type mapping necessary to create the tracking table necessary for the Distribution agent 10.sp_MScheck_subscribe on subscription database – verifies that SQL Server Agent account is in sysadmin and db_owner role in subscription database 11.sp_mscreate_sub_tables on subscriber in subscription database – creates MSSusbcription_agents and MSreplication_subscriptions tables 12.Sp_MSinit_Subscription_agent – updates the Subscription agent information on subscription database 13.Retrieves transaction_timestamp and subscription_guid to determine what Distribution agent has already replicated to the Subscriber. Transaction_timestamp correlates to xact_seqno column in MSReplication_transactions table in distribution database. All values large than the xact_seqno will be replicated 14.If we are doing initial sync, Distribution Agent calls sp_MSupdatelastsyncinfo which updates MSreplication_susbcriptions and MSSusbcription_agents table 15.Starts to retrieve all transactions and their corresponding commands from MSReplication_transactions and MSreplication_commands table where transaction_timestamp column in subscription database < xact_seqno column in MSreplication_transactions table. Applies the transaction using sp_MS_get_repl_commands procedure 16.Issues dynamic SQL to update the MSreplication_subscriptions table with the last delivered transaction ID 17.sp_MSDistribution_history to write the MSrepl_distribution_history table with status message “nn transaction(S) with nn command(s) were delivered”

在步驟5中,我們得知,Logreader用存儲過程sp_Msget_last_transaction來定位發布庫日志中最后一個被寫入到分發庫中的事務,我們找到這個存儲過程的源碼:

CREATE PROCEDURE sys.sp_MSget_last_transaction(    @publisher_id int = NULL,    @publisher_db sysname,    @publisher sysname = NULL,    @max_xact_seqno varbinary(16) = NULL output    ,@for_truncate bit = 0)ASbegin    declare @publisher_database_id int    declare @max_xact_id varbinary(16)    declare @sync_bit int    declare @sync_with_backup bit    set nocount on        -- security check    -- only db_owner can execute this        if (is_member ('db_owner') != 1)    begin        raiserror(14260, 16, -1)        return (1)    end    SELECT @sync_bit = 32    if @publisher_id is NULL        select @publisher_id = srvid from master.dbo.sysservers where            UPPER(srvname) = UPPER(@publisher)    -- Get publisher database id.    SELECT @publisher_database_id = id from MSpublisher_databases where publisher_id = @publisher_id and        publisher_db = @publisher_db    if exists ( select * from master.dbo.sysdatabases where            name = db_name() and            category & @sync_bit = 0)        select @sync_with_backup = 0    else        select @sync_with_backup = 1    if @for_truncate = 0    begin        select top 1 @max_xact_id = rt.xact_id, @max_xact_seqno = rt.xact_seqno          from          MSrepl_transactions rt          where             rt.publisher_database_id = @publisher_database_id and             not xact_id = 0x0             order by xact_seqno desc    end    -- If (1) requesting truncate lsn (distbackuplsn), (2) sync with backup is set    -- query the values from MSrepl_backup_lsn    else if    @sync_with_backup = 1    begin        -- Get the last backed up lsn if available.        select top 1 @max_xact_id = valid_xact_id, @max_xact_seqno = valid_xact_seqno          from          MSrepl_backup_lsns          where             publisher_database_id = @publisher_database_id    end        -- If @publisher is not null, we are calling this sp from sp_replrestart    -- Don't return result set.    if @publisher is null        select @max_xact_id, @max_xact_seqno, @publisher_database_id            -- Don't return any result when requsting a truncate lsn and            -- the database is not in 'sync with backup' mode, which signal the            -- distribution agent to use last dist lsn to call sp_repldone.            where not (@sync_with_backup = 0 and @for_truncate = 1)end

存儲過程中,代碼

else if    @sync_with_backup = 1begin    -- Get the last backed up lsn if available.    select top 1 @max_xact_id = valid_xact_id, @max_xact_seqno = valid_xact_seqno      from      MSrepl_backup_lsns      where         publisher_database_id = @publisher_database_idend

可見,報錯中的dist_backup_lsn取自表MSrepl_backup_lsns

我們來查詢一下該表:

select * from MSrepl_backup_lsns

image

列valid_xact_id為最后備份的事務ID,valid_xact_seqno為該事務中的LSN,即valid_xact_seqno為報錯中顯示的dist_backup_lsn,(請勿與圖中貼出的錯誤進行對比,上圖僅為錯誤示例截圖)。

我們再去分發庫MSrepl_transactions表中找到當前已經被讀取到分發庫的最大事務的LSN

SELECT TOP 1 * from     [dbo].[MSrepl_transactions] as twhere t.publisher_database_id = 5ORDER BY t.entry_time DESC

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲第一视频网站| 久久久久免费精品国产| 久久影视三级福利片| 久热在线中文字幕色999舞| 欧美在线视频一区| 久久久精品一区二区| 色综合久久精品亚洲国产| 亚洲精品乱码久久久久久金桔影视| 亚洲成年网站在线观看| 亚洲深夜福利在线| 亚洲人午夜精品免费| 色狠狠久久aa北条麻妃| 97在线日本国产| 欧洲精品在线视频| 亚洲大尺度美女在线| 国产精品av免费在线观看| 搡老女人一区二区三区视频tv| 91精品国产高清| 日韩欧美中文第一页| 久久久久久久影视| 国产91精品久久久| 亚洲欧美一区二区三区在线| 亚洲激情视频网| 久久成年人免费电影| 日本一区二区在线播放| 亚洲欧美在线x视频| 亚洲新声在线观看| 欧美日韩国产黄| 久久99久久99精品免观看粉嫩| 另类少妇人与禽zozz0性伦| 日本精品视频网站| 精品久久久久人成| 国产成人精品电影久久久| 在线观看国产精品日韩av| 色综合导航网站| 精品国产一区二区三区久久久狼| 亚洲第一网站男人都懂| 另类天堂视频在线观看| 黑人狂躁日本妞一区二区三区| 欧美一级片免费在线| 色偷偷91综合久久噜噜| 亚洲视频电影图片偷拍一区| 亚洲直播在线一区| 欧美视频在线观看 亚洲欧| 2019av中文字幕| 亚洲国产精品大全| 97视频在线观看免费高清完整版在线观看| 久久亚洲一区二区三区四区五区高| 久久精品人人爽| 亚洲人成欧美中文字幕| 精品自拍视频在线观看| 疯狂做受xxxx高潮欧美日本| 国产亚洲精品高潮| 国产精品一区二区三区成人| 中文字幕欧美日韩在线| 亚洲成avwww人| 国产成人一区二| 欧美色道久久88综合亚洲精品| 欧美激情精品久久久久久变态| 欧美黑人巨大精品一区二区| zzijzzij亚洲日本成熟少妇| 亚洲丝袜在线视频| 久久精品这里热有精品| 欧美成人免费全部观看天天性色| 国产精品亚发布| 国产亚洲人成a一在线v站| 亚洲精选在线观看| 欧美成人激情视频| 精品一区二区三区电影| 国产黑人绿帽在线第一区| 亚洲黄色免费三级| 91视频国产高清| 欧美午夜精品久久久久久人妖| 久久综合九色九九| 一区二区三区精品99久久| 国产精品免费观看在线| 日韩在线视频一区| 91在线精品视频| 夜夜躁日日躁狠狠久久88av| 成人久久18免费网站图片| 草民午夜欧美限制a级福利片| 日韩精品免费在线视频| 中文字幕一精品亚洲无线一区| 欧美精品生活片| 亚洲电影免费观看高清| 国产精品视频公开费视频| 国产精品九九九| 日本韩国欧美精品大片卡二| 理论片在线不卡免费观看| 91香蕉国产在线观看| 欧美在线视频a| 中文字幕在线观看亚洲| 亚洲黄色成人网| 亚洲国产精品网站| 欧美精品在线免费播放| 日韩av高清不卡| 欧美另类xxx| 97人洗澡人人免费公开视频碰碰碰| 欧美一级视频免费在线观看| 国产精品黄视频| 亚洲激情视频在线观看| yellow中文字幕久久| 欧美国产欧美亚洲国产日韩mv天天看完整| 亚洲一区二区三区视频| 亚洲国产精品va在线看黑人动漫| 成人亚洲综合色就1024| 欧美日韩亚洲成人| 亚洲成av人片在线观看香蕉| 欧美高跟鞋交xxxxhd| 欧美劲爆第一页| 97精品一区二区三区| 亚洲男人天堂古典| 日韩av网站在线| 国产成+人+综合+亚洲欧美丁香花| 91久久精品国产| 最近2019中文字幕一页二页| 国产精品美乳在线观看| 成人国产精品免费视频| 国产主播喷水一区二区| 亚洲www视频| 久久久黄色av| 日韩专区在线播放| 九九热在线精品视频| 欧美黑人又粗大| 久久视频免费观看| 亚洲tv在线观看| 国产成人精品视频| 爱福利视频一区| 国产精品久久久久久久天堂| 国产精品ⅴa在线观看h| 欧美精品第一页在线播放| 国产精品国模在线| 久久精品影视伊人网| 国产精品xxx视频| 日韩欧美在线一区| 538国产精品视频一区二区| 国产精品久久久久久久久久久久久久| 国产精品久久在线观看| www日韩中文字幕在线看| 亚洲国产精品女人久久久| 亚洲精品小视频在线观看| 精品国产自在精品国产浪潮| 成人免费视频a| 国产精品96久久久久久| 主播福利视频一区| 日本一区二区三区在线播放| 欧美激情啊啊啊| 亚洲激情在线视频| 久久99久久99精品免观看粉嫩| 日韩电影中文字幕一区| 亚洲成人亚洲激情| 亚洲精品97久久| 一二美女精品欧洲| 91精品久久久久久久| 日韩精品免费综合视频在线播放| 一区二区三区亚洲| 色爱精品视频一区| 久久成人综合视频| 久久视频中文字幕| 亚洲视频在线观看免费| 亚洲欧美在线一区二区| 日韩中文字幕免费视频| 欧美性猛交xxxx免费看| 亚洲激情第一页|