zoukankan      html  css  js  c++  java
  • [翻译]当分发数据库增长到25G时如何解决

    有时候,分发数据库(Distribution Database)会增长得非常大,那么如何解决呢,请看Chris Skorlinski,  Microsoft SQL Server Escalation Services 的解决方案。

    原文地址:How to resolve when Distribution Database is growing huge (+25gig), 本人翻译水平有限,如果有什么地方翻译不当或不对的地方,请不吝指教!

    是的,我当然知道大数据库是相对的,但总体来说,如果你看到分发数据库越来越大增长到25G,这意味着清理进程很难删除复制事务,后面我将介绍如何以及为什么清理过程会这样。但是现在我想介绍一种我们经常用的技巧从分发数据清除数据行。这个解决方案包括修改SQL复制存储过程,以及增加每笔事务删除的行数,如果你对代码修改感到不舒服,直接跳到STEP 7吧。

    第一篇发布出来的是“保守”的方法,接下来,我会发表一些更“激进”的解决方案。

    1) 保存清理删除msrepl_commands对象的srepl_commands存储过程的原始脚本

                  sp_helptext  sp_MSdelete_publisherdb_trans

    2) 将CREATE改为ALTER

                  ALTER PROCEDURE sp_MSdelete_publisherdb_trans

    3)改变三处DELETE操作,从2000改为100000行

                  DELETE TOP(2000) MSrepl_commands . . .

    4) 保存msrepl_transaction 清理存储过程sp_MSdelete_dodelete的原始代码

                 sp_helptext sp_MSdelete_dodelete

    5)将CREATE关键字改为ALTER

                 ALTER PROCEDURE sp_MSdelete_dodelete

    6)改变两处删除MSrepl_transactions记录的地方,将5000改为100000行。

               delete TOP(5000) MSrepl_transactions . . .

    7) Determine oldest day containing transactions 决定保留事物多少天

    Code Snippet
    1. --(shows breakout by day, by hour.  Took 2 hours on 350million rows, 100gb distribtuion db)
    2. SELECT T.[publisher_database_id]
    3.     ,  datepart(mm,[entry_time]) 'month'
    4.     ,  datepart(dd,[entry_time]) 'day'
    5.     ,  datepart(hh,[entry_time]) 'hour'
    6.     ,  count(C.[xact_seqno]) 'count of commands'
    7. FROM [distribution].[dbo].[MSrepl_transactions](nolock) T
    8. JOIN [MSrepl_commands](nolock) C
    9. ON T.[xact_seqno] = C.[xact_seqno]
    10. GROUP BY T.[publisher_database_id]
    11.   ,datepart(mm,[entry_time])
    12.   , datepart(dd,[entry_time])
    13.   , datepart(hh,[entry_time])
    14. order by 1,2,3,4
    15.  
    16. --Or, just select oldest 10 rows and note the entry_time stamp.
    17. --(select took 5 minutes on 350million rows, 100gb distribtuion db)
    18. SELECT TOP 10 * FROM [distribution].[dbo].[MSrepl_transactions](nolock)

    8)通过SSMS或TSQL作业执行清理以前的事务(24小时*5天=120),然后继续执行减少@max_distretention的执行

    Code Snippet
    1. EXEC dbo.sp_MSdistribution_cleanup @min_distretention = 0, @max_distretention = 120
    2.  
    3. Example output: (4 hours to removed 340million rows)
    4.  
    5. Removed 3493 replicated transactions consisting of 343877158 statements in 15043 seconds (22859 rows/sec).

    Hope you found this helpful,

    希望这个对你有用。

    Chris Skorlinski,  Microsoft SQL Server Escalation Services

  • 相关阅读:
    Ubuntu 16 安装redis客户端
    crontab 参数详解
    PHP模拟登录发送闪存
    Nginx配置端口访问的网站
    Linux 增加对外开放的端口
    Linux 实用指令之查看端口开启情况
    无敌的极路由
    不同的域名可以指向同一个项目
    MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error
    Redis 创建多个端口
  • 原文地址:https://www.cnblogs.com/kerrycode/p/3378798.html
Copyright © 2011-2022 走看看