如何收缩超大的SharePoint_Config数据库

发表于:2016-2-23 10:42

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:霖雨    来源:51Testing软件测试网采编

分享:
  6、经过不懈的查找,发现了一个ps脚本,把下面脚本,存成一个ps1文件,执行一下,会起作用(至少我这里已经起作用了,会删掉多余的历史记录);
Add-PSSnapin Microsoft.SharePoint.PowerShell
Write-Host "Clearing Down Timer Job History"
$daysToKeep = 300
$daysToPurgeInOneLoop = 5
while ($daysToKeep -gt 0)
{
$history = get-sptimerjob | where-object {$_.name -eq “job-delete-job-history”}
Write-Host " "
Write-Host -NoNewLine "Setting Days to Keep:"
Write-Host -ForegroundColor Green $daysToKeep
$history.DaysToKeepHistory = $daysToKeep
$history.update()
Write-Host -ForegroundColor Green "Starting Purge Job"
$lastTimeJobRan = $history.LastRunTime
$history.runnow()
Write-Host -NoNewLine -ForegroundColor Green "Waiting For Purge Job to Complete"
$jobFinished = $false
while ($jobFinished -eq $false)
{
Start-Sleep -Seconds 2
$runningJob = Get-SPTimerJob $history.Name
Write-Host -NoNewLine -ForegroundColor Yellow "."
if ($lastTimeJobRan -ne $runningJob.LastRunTime)
{
$jobFinished = $true
}
}
Write-Host " "
Write-Host -ForegroundColor Green "Ending Purge Job"
$daysToKeep = $daysToKeep - $daysToPurgeInOneLoop
}
Write-Host -ForegroundColor Green "Setting Final Job History Retention to 3 days, and schedule to run daily @ 5am"
$history.DaysToKeepHistory = 3
$history.update()
$history.runnow()
Set-SPTimerJob -Identity $history -Schedule "Daily at 05:00"
Write-Host -ForegroundColor Yellow "Please check row counts on dbo.TimerJobHistory Table in Config DB to ensure run complete"
  结束语
  当然,执行PowerShell的命令需要很长时间,我这里用了大概1天时间,将90多个GB的SharePoint_Config收缩到了15个GB,效果还是很明显的,整理出来很大一部分空间,不用经常做磁盘空间维护了。
22/2<12
精选软件测试好文,快来阅读吧~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号