时间:2020-02-06 20:25作者:admin来源:未知人气:297我要评论(0)
在已经运行了2年多的SharePoint服务器上,发现SharePoint_Config的数据库文件越来越大,已经达到90几个GB,收缩可以减小20几个GB,但是一周以后又会恢复到90几个GB大小,甚是奇怪。
因为磁盘空间不足,一共只有200GB大小,还有大大小小网站若干,用来存放照片、视频、文档等,所以决定好好研究一下这个问题。
经过不懈的谷歌,发现了问题症结所在,现在分享给大家,希望对遇到类似的问题的人,有个参考。
对了,注意。。这里是指数据库文件,不是数据库的日志文件,如果是日志文件的话,在数据库管理工具中,修改备份模式为简单,直接收缩就好了!
1、在数据库服务器中打开Microsoft SQL Server Management Studio,找到SharePoint_Config数据库,然后执行下面的语句:
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
2、看到执行的结果,就是每个数据库表的大小,然后看到TimerJobHistory这个表的行数非常多,大小也非常的大。
3、谷歌有类似的解决方案,说是因为job-delete-job-history这个Job运行失败,造成了Job运行的历史记录不能被及时清理,造成了配置数据库越来越大。所以运行下面的脚本,会清理一年以来的积累,而这个Job默认每周运行一次,清理上周积累下来的历史记录。
$history = get-sptimerjob | where-object {$_.name -eq “job-delete-job-history”}
$history.daystokeephistory = 365
$history.update()
$history.runnow()
4、运行完毕以后,还要将daystokeephistory数值改回7天,如下图:
5、可以看到运行以后,确实有个Job再运行,不过我这里可能由于已经超过365天了,所以也没有起作用,Job依旧运行Failed。所以只能继续谷歌,寻找解决方案。
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,效果还是很明显的,整理出来很大一部分空间,不用经常做磁盘空间维护了。
相关阅读 SharePoint中Office文件无法打开的解决方案如何快速生成SharePoint测试大文件如何查询SharePoint Library中空文件夹?如何快速备份SharePoint Farm Solution如何解决Event Viewer中SharePoint Error - Event ID 8321SharePoint 2016 CU安装失败,"Exception: The upgraded database schema doesn't match the TargetSchema"的解决方案InfoPath Error “此文档库已经被重命名或删除,或者网络问题导致文件无法保存…” 的解决方案SharePoint 2013 App概述How to Shrink SharePoint Content Database Log File?Project Web App Feature无法开启的解决方案
热门文章 SharePoint 2016 图文安装教程 后面有激活序列号、密钥分享[SharePoint入门教程]一SharePoint发展、工具及术语如何用 SharePoint Online创建团队网站?SharePoint Iframe 报错“此内容不能显示在一个框架中”
最新文章
SharePoint中Office文件无法打开的解决方案如何快速生成SharePoint测试大文件
如何查询SharePoint Library中空文件夹?如何快速备份SharePoint Farm Solution如何解决Event Viewer中SharePoint Error - Event ID 8321SharePoint 2016 CU安装失败,"Exception: The upgraded database s
人气排行 SharePoint 2016 图文安装教程 后面有激活序列号、密钥分享[SharePoint入门教程]一SharePoint发展、工具及术语如何用 SharePoint Online创建团队网站?SharePoint Iframe 报错“此内容不能显示在一个框架中”SharePoint 2013 安装图解 SharePoint安装步骤图解教程SharePoint 如何开启访问请求[SharePoint入门教程]一SharePoint概述[SharePoint入门教程]一创建SharePoint母版页
盖楼回复X
(您的评论需要经过审核才能显示)
查看所有0条评论>>