Updating the AppFabric is a pain. Any mistakes and you will end up with a broken farm. After wrecking a farm I decided to write a script.
This script installs CU7, and makes the recommended config file changes to take advantage of improved garbage collection.
In this example, we stop the Distributed Cache (this is critical!!!!), install App fabric CU7, update the app configs, repeat on all servers, wait a few minutes, start Distributed Cache on servers.
Sometimes it will take many minutes to stop the DC...
Import-Module Servermanager
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Add-PSSnapin Microsoft.sharepoint.powershell
function Patch-Configure-AppFabric-For-SharePoint()
{
#VVVVVNB!!!
Stop-SPDistributedCacheServiceInstance -Graceful
#edit file for updated values
$webConfig = "C:\Program Files\AppFabric 1.1 for Windows Server\DistributedCacheService.exe.config"
$doc = (gc $webConfig) -as [xml]
#might not have appsettings node
$appSettingsnode = $doc.SelectSingleNode('configuration/appSettings')
if($appSettingsnode -eq $null)
{
#$configurationnode = $doc.SelectSingleNode('configuration')
$appSettingsnode = $doc.CreateElement('appSettings')
$doc.configuration.AppendChild($appSettingsnode)
}
$newPropertyNode = $doc.SelectSingleNode('configuration/appSettings/add')
if($newPropertyNode -eq $null)
{
$newPropertyNode = $doc.CreateNode("element", "add","")
$newPropertyNode.SetAttribute("key", "backgroundGC")
$newPropertyNode.SetAttribute("value", "true")
$bypassPSShortcomings = $doc.SelectSingleNode('configuration/appSettings')
$bypassPSShortcomings.AppendChild($newPropertyNode)
$doc.Save($webConfig)
}
#Install the CU
$scriptpath = $MyInvocation.MyCommand.Path
if($scriptpath -eq $null) #if running fomr ISE
{
$dir = "\\your-server-here\c$\Package\"
}
else
{
$dir = Split-Path $scriptpath
}
$AppFabric = "$dir\AppFabric-KB3092423-x64-ENU.exe"
$setup=Start-Process $AppFabric -ArgumentList "/S" -Wait
Start-Sleep 120 #just in case...
}
Patch-Configure-AppFabric-For-SharePoint
Run this after repeating above ps1 on the servers
Do not run this till its all finished. I also leave it to you to determine where Distributed Cache is intended to be running.
$instance = Get-SPServiceInstance | ? {$_.TypeName -eq "Distributed Cache" -and $_.Server.Name -eq $env:computername}
$instance.Provision()
No comments:
Post a Comment