SP 2013 Patching



  • Background
  • Pre-installation steps
  • Post Installation check
  • If Rollback required
  • Powershell script to run exe
  • Applying additional updates
    • AppFabric update
    • Office Web App patching

These Microsoft links have all the patch release details and numbers:

 

 
Background:
Patches with CU (cumulative update) will have all the past changes so you can skip any hot fixes prior to that CU. You can’t uninstall a cumulative update. Most CU will require installing the latest Service Pack (SP1/SP2). It’s not compulsory to install CU unless you are affected by any problems.  CU updates will automatically be rolled into the next service pack. Hotfix comes after CU updates that are missed to resolve in CU updates.
 
The SharePoint binary files are updated with the patch first but the databases are not automatically upgraded. This installation of binaries kills SharePoint processes. In the older versions (SP2010), SharePoint can run in compatibility mode that still allows the sites to function but not in SP2013.
 
Note: After installing hot fixes, it won’t change the configuration database version as it will remain the same as previous CU version.
 
  
 
Pre installation steps:
  • Check the existing CU version  by noting down the configuration database version
                 Central Admin > Under System settings, ‘Manage servers in this farm’
  • Determine the hotfix/CU that your organization need and read articles for prerequisites, issues that it fixes, known issues etc.
  • Download the installation files (approx... 1 hr) and copy to all SharePoint servers (C:\temp).
  • Check for orphan objects, otherwise installation may fails.
  • Make sure upgrade timer job is running. This timer job checks SharePoint environment to make sure newly added content databases are in the same version as others.
  • Take note of the Config server and config database name, versions by going into Central Admin/ System settings/ Manage servers because you need to confirm this details when running the psconfig wizard.
  • Permissions
Upgrades must be applied by an account which has the following permissions:
o   Member of Local Administrator on all servers (Computer mgmt. > Administrators)
o   Member of the SharePoint farm administrators group
o   SharePoint PowerShell admin rights
o   DB_owner of all SP databases in SQL server
 
  • Backup –
Request server team to take server snapshots or system state backups (can take 2 days before as long as no major changes happen to SharePoint core). If virtual snapshots are used, SP servers must be shut down while snapshots are performed.
 
Request DBA team to take full SQL database backups of all SP related databases. (Don’t take SQL snapshots as it cannot be supported as you will not have consistency between SP servers and/or SP <-> SQL Server with respect to timer jobs).
 
Optional: Backup farm (For PROD) - – via CA or Backup-SPFarm cmdlet. (To restore 30 mins). You must first stop all of the services in your farm before performing the backup. In the past, if the patching fails, uninstall SharePoint, install the older version and then restore from backup.
 
  • Request DBA team to disable SQL database mirroring (for SP2010 only, 2013 has always on high availability groups) and make sure mirroring is not enabled automatically as it will stop the install process. No action required if SQL always on high availability is used.
 
  • Communicate to users and/or create a maintenance page so that users won’t call for outages (create a simple html file with some description and the file size should be at least 512 bytes otherwise you will get 404 page not found error. Copy the html file under \inetpub\wwwroot\. Connect to the IIS server where the web site is hosted and stop the site. When users access this page, they will be routed to the maintenance page. You only need to do this if the site is totally unavailable. When patching, the sites won’t be unavailable totally as we have load balancing.)
 
  • Optional: Run the following powershell command against all content database to see all missing features, web parts, configurations otherwise configuration wizard will fail (Farm will still be upgraded):
Test-SPContentdatabase -name <Content database name>  -webapplication http://webapp url
 
 
 
Installation Process:
Two major steps:
Running the exe file on each server
Running the configuration wizard staring with central admin server and the rest
 
  • During the installation process, don’t stop World Wide Web Publishing Service on the installing server from services.msc as it will stop servers from communicating with each other during patching process.
 
  • Request networks team to remove the servers from load balancing
 
  • For SP2013, update may take 5 hours. To avoid this, you can run the powershell script (refer below) on each server instead of running the exe file (C:\temp on each server) manually. If you are running the script, click no at the end when prompting to restart the server as it needs to start the services back.
 
You can run the exe file/script on all servers at the same time to avoid downtime. If you are running the exe file manually, it is recommended to pause search service application so that it is not shut down while full/incremental/continuous crawl. Refer the scripts below to pause/resume search manually.
               
  • Restart each server at the end of install.
  
  • Run SharePoint Product Configuration wizard
Can use the GUI (C:\Program files\Common files\Microsoft Shared\Web Server Extensions\15\Bin) or powershell script.
 
First on Central admin server, then app servers then WFE servers. Can run only one at a time as it updates some local resources.
The following services will be stopped:
IIS service, SharePoint admin, Timer)
 
PSConfig.exe -cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources
 
Optional: To avoid downtime, you can also upgrade big content databases by using powershell
Upgrade-SPContentDatabase –ID xxxx.
Get all the content database ID’s by running get-spcontentdatabase >c:\text
Start content database upgrade one after the other after several minutes. Not more than 2. You do not upgrade more than 2 content databases on the same SQL Server at a time and stage the starting time for each content database that will occur in parallel by several minutes to prevent lock contention. The typical number of content databases that can be upgraded per Web or application server is 4 databases.
 
Configuration wizard may fail on some servers for missing features, web parts, etc. Complete configuration update on all servers and check the status of the databases under Central Admin > Upgrade and Migration > Review database status. If they all say ‘no action required’, your environment is upgraded. Check the upgrade error logs and correct the errors and may run the wizard again.

 
  • You must restart User Profile Synchronisation Service on the  server that was running before. Go to Central Admin / System settings / manage services, stop and start
 
  • Reset IIS on every server.
 
 
 
Post Installation Check:

-          Verify SharePoint services by going into service console (services.msc).
-          Make sure all the services applications have started (happens automatically anyway) by going into Central Admin /System settings /Manage services on this server.
-          Check the config database version. Central Admin > Under System settings, ‘Manage servers in this farm’
-          Under Central Admin /Upgrade and migration / Review database status, make sure all say no action required.
-          Perform random testing of your SharePoint Sites.
-          Check Central administration > health analyser for errors
-          Check server event viewer logs and upgrade logs ( C:\Program files\Common files\Microsoft Shared\Web Server Extensions\15\Logs\)
-       elete all the copied installation files from the servers.
 





If Rollback required:

The following steps outline a roll back procedure where virtual snapshots and full SQL database backups have been made:

1. Shutdown All SharePoint Servers

2. Restore all SharePoint databases

3. Apply virtual snapshot to SharePoint servers

4. Start all SharePoint servers in the following order:

Central Admin Servers, app servers then WFE servers










Powershell script to run instead of running the exe file on each server:
Tested with SP2013 and Windows 2012.
The below script is to stop IISAdmin, SPTimer service; search service.

<# ==============================================================
  //
  // Microsoft provides programming examples for illustration only,
  // without warranty either expressed or implied, including, but not
// limited to, the implied warranties of merchantability and/or
  // fitness for a particular purpose.
  //
  // This sample assumes that you are familiar with the programming
  // language being demonstrated and the tools used to create and debug
  // procedures. Microsoft support professionals can help explain the
  // functionality of a particular procedure, but they will not modify
  // these examples to provide added functionality or construct
  // procedures to meet your specific needs. If you have limited
  // programming experience, you may want to contact a Microsoft
  // Certified Partner or the Microsoft fee-based consulting line at
  //  (800) 936-5200 .
  //
  // For more information about Microsoft Certified Partners, please
  // visit the following Microsoft Web site:
  // https://partner.microsoft.com/global/30000104
  //
  // ———————————————————- #>

 
###########################
##Ensure Patch is Present##
###########################
$patchfile = Get-ChildItem | where{$_.Extension -eq ".exe"}
if($patchfile -eq $null)
{
  Write-Host "Unable to retrieve the file.  Exiting Script" -ForegroundColor Red
  Return
}


########################
##Stop Search Services##
########################
##Checking Search services##
$srchctr = 1
$srch4srvctr = 1
$srch5srvctr = 1

$srv4 = get-service "OSearch15"
$srv5 = get-service "SPSearchHostController"

If(($srv4.status -eq "Running") -or ($srv5.status-eq "Running"))
  {
    Write-Host "Choose 1 to Pause Search Service Application" -ForegroundColor Cyan
    Write-Host "Choose 2 to leave Search Service Application running" -ForegroundColor Cyan
    $searchappresult = Read-Host "Press 1 or 2 and hit enter" 
    Write-Host
   

   if($searchappresult -eq 1)
    {
        $srchctr = 2
        Write-Host "Pausing the Search Service Application" -foregroundcolor yellow
        Write-Host "This could take a few minutes" -ForegroundColor Yellow
        $ssa = get-spenterprisesearchserviceapplication
        $ssa.pause()
    }
   

    elseif($searchappresult -eq 2)
    {
        Write-Host "Continuing without pausing the Search Service Application"
    }
    else
    {
        Write-Host "Run the script again and choose option 1 or 2" -ForegroundColor Red
        Write-Host "Exiting Script" -ForegroundColor Red
        Return
    }
  }

Write-Host "Stopping Search Services if they are running" -foregroundcolor yellow
if($srv4.status -eq "Running")
  {
    $srch4srvctr = 2
    set-service -Name "OSearch15" -startuptype Disabled
    $srv4.stop()
  }

if($srv5.status -eq "Running")
  {
    $srch5srvctr = 2
    Set-service "SPSearchHostController" -startuptype Disabled
    $srv5.stop()
  }

do
  {
    $srv6 = get-service "SPSearchHostController"
    if($srv6.status -eq "Stopped")
    {
        $yes = 1
    }
    Start-Sleep -seconds 10
  }
  until ($yes -eq 1)

Write-Host "Search Services are stopped" -foregroundcolor Green
Write-Host

 

#######################
##Stop Other Services##
#######################
Set-Service -Name "IISADMIN" -startuptype Disabled
Set-Service -Name "SPTimerV4" -startuptype Disabled
Write-Host "Gracefully stopping IIS W3WP Processes" -foregroundcolor yellow
Write-Host
iisreset -stop -noforce
Write-Host "Stopping Services" -foregroundcolor yellow
Write-Host

$srv2 = get-service "SPTimerV4"
  if($srv2.status -eq "Running")
  {$srv2.stop()}

Write-Host "Services are Stopped" -ForegroundColor Green
Write-Host
Write-Host

 

##################
##Start patching##
##################
Write-Host "Patching now keep this PowerShell window open" -ForegroundColor Magenta
Write-Host
$starttime = Get-Date

$filename = $patchfile.basename    

Start-Process $filename

Start-Sleep -seconds 20
$proc = get-process $filename
$proc.WaitForExit()

$finishtime = get-date
Write-Host
Write-Host "Patch installation complete" -foregroundcolor green
Write-Host

 

##################
##Start Services##
##################
Write-Host "Starting Services Backup" -foregroundcolor yellow
Set-Service -Name "SPTimerV4" -startuptype Automatic
Set-Service -Name "IISADMIN" -startuptype Automatic

##Grabbing local server and starting services##
$servername = hostname
$server = get-spserver $servername

$srv2 = get-service "SPTimerV4"
$srv2.start()
$srv3 = get-service "IISADMIN"
$srv3.start()
$srv4 = get-service "OSearch15"
$srv5 = get-service "SPSearchHostController"

###Ensuring Search Services were stopped by script before Starting"
if($srch4srvctr -eq 2)
{
    set-service -Name "OSearch15" -startuptype Automatic
    $srv4.start()
}
if($srch5srvctr -eq 2)
{
    Set-service "SPSearchHostController" -startuptype Automatic
    $srv5.start()
}

###Resuming Search Service Application if paused###
if($srchctr -eq 2)
{
    Write-Host "Resuming the Search Service Application" -foregroundcolor yellow
    $ssa = get-spenterprisesearchserviceapplication
    $ssa.resume()
}
Write-Host "Services are Started" -foregroundcolor green
Write-Host
Write-Host
Write-Host "Script Duration" -foregroundcolor yellow
Write-Host "Started: " $starttime -foregroundcolor yellow
Write-Host "Finished: " $finishtime -foregroundcolor yellow
Write-Host "Script Complete" 









App Fabric Update:
This is a caching service installed in windows servers separately from SP install.
You can see this under server > services.msc.
Find the latest from http://www.jeremytaylor.net/tag/cumulative-updates+appfabric


How to patch:
http://www.jeremytaylor.net/2015/09/17/how-to-patch-sharepoint-distributed-cache-the-proper-way/





Office Web server Update:
https://technet.microsoft.com/en-us/library/jj966220.aspx  - patching Office Web App
Before updating, get the latest Office web app farm detail by running the following powershell command:
Get-OfficeWebAppsFarm


NOTE: When running windows PowerShell commands, open as administrator
  • Check existing version by typing the below PowerShell command:


(Invoke-WebRequest http://officewebappurl/m/met/participant.svc/jsonAnonymous/BroadcastPing).Headers["X-OfficeVersion"]
  • Download the update onto the servers
  •  


Applying update for a single Office web app server farm:
  • Remove office web app server from the farm:
             Remove-OfficeWebAppsMachine
  • Apply the software update and restart the server
  • Re-create office web app server farm with the following command
    New-OfficeWebAppsFarm –InternalURL http://officewebappservername –AlowHttp -EditingEnabled
     
     


Applying update for multiple Office web app server farm:
  • Remove one server from network load balancer and from the farm
  • Apply the software update and restart the server
  • Re-create an updated office web app server farm
  • Depending on how many servers in the farm, load balance traffic by adding the newly updated farm to load balancer
  • For the remaining servers, do the following:
    Remove from load balancer
    Install the update and restart server
    Add the server to the newly updated farm with the following command:
    New-OfficeWebAppsMachine –MachineToJoin “Server1.org.au”




No comments:

Post a Comment