SQL Server Maintenance für SharePoint


Was immer mal wieder gefragt wird ist, was man denn genau für SharePoint Datenbanken für Maintenance Tasks machen muss und welche Operationen auf SharePoint Datenbanken erlaubt sind und welche nicht.

Ich habe im Folgenden mal alles, was eigentlich auch im Technet bekannt aber verstreut oder unübersichtlich ist, zusammengefasst. Zusätzlich gibt es einen SQL Best Practice Skript, der die benötigten Aktionen automaisch erstellt. Viel Spass beim lesen

So long, Samuel

Inhalt

1       Database Maintenance Plan for SharePoint. 2

1.1        Databases in SharePoint 2013. 2

1.2        Database Maintenance. 4

1.3        Supported and Unsupported Chagnes on SharePoint DBs. 5

1.3.1         Unsupported Database Changes. 5

1.3.2         Supported database modifications. 6

1.3.3         Read operations addendum.. 7

2       SQL Maintenance Script7

 

 

 

 

1         Database Maintenance Plan for SharePoint

1.1         Databases in SharePoint 2013

Source: http://technet.microsoft.com/en-us/library/cc678868(v=office.15).aspx

Database Recommended Recovery Model Backup Method Size Characteristics Notes
Config Simple SP BackkupSQL Backup Small Read intensisve
  • Must be Co-Located with CA DB
  • Recovery Model must be full for Mirroring
  • Scale up, only one DB per Farm
Central Administration Content Full SP BackupSQL Backup Small Varies
  • Must be Co-Located with Config DB
  • Can grow over the period of 365 days if Power Pivot is used
  • Scale up, only one DB per Farm
Content Databases Full SP BackupSQL Backup Small to Big Varies by Usage
  • Limit Size to 200GB per Content DB
  • Scale out, Scale up (a Site Collection can sit in only 1 DB)
App Management Full SP BackupSQL Backup Small Write heavy
  • Only write heavy during App installation
  • Scale up, Scale out only on Office 365
Business data Connectivity Full SP BackupSQL Backup Small Read heavy
  • Scale up, only one DB per Farm
Search – Admin Simple SP BackupSQL Backup Medium Read Write
  • Scale up, Scale out only by creating additional Service Applications
Search – Analytics Simple SP BackupSQL Backup Medium to Large Write heavy
  • Nightly Analytics update
  • Scale out by Split Operation when DB becomes > 200GB
Search – Crawl Simple SP BackupSQL Backup Medium Read heavy
  • Scale out by creating new DBs for every 20mio Items crawled
Search – Link Simple SP BackupSQL Backup Medium to Large Write heavy
  • Affected by Content processing
  • Scale out by creating new DBs for 60mio Items crawled and for expected 100mio querys per year
Secure Store Full SP BackupSQL Backup Small Equal Read Write
  • Scale up, Scale out by creating new Service Applications
Usage Simple SQL Backup XLarge Write heavy
  • Scale up, only one DB per Farm
Subscription Settings Full SP BackupSQL Backup Small Read heavy
  • Scale up, Scale out by creating new Service Applications
User Profile – Profile Simple SP BackkupSQL Backup Medium to Large Read heavy
  • Scale up, Scale out by creating new Service Applications
User Profile – Sync Simple SP BackupSQL Backup Medium to Large Equal Read Write
  • Scale up, Scale out by creating new Service Applications
User Profile – Social Simple SP BackupSQL Backup Small to XLarge Read heavy
  • Scale up, Scale out by creating new Service Applications
Word Automation Full SP BackupSQL Backup Small Read heavy
  • Scale up, Scale out by creating new Service Applications
  • Traffic is Affected by Word Conversions only
Managed Metadata Full SP BackupSQL Backup Medium Read heavy
  • Scale up, Scale out by creating new Service Applications
Machine Translation Full SP BackupSQL Backup Small Read heavy
  • Scale up, Scale out by creating new Service Applications
Project Server Full SP BackupSQL Backup Small to Medium Read heavy
  • Scale up
  • One Database per Project WebApp
PowerPivot Full SP BackupSQL Backup Small Read heavy
  • Scale up
Performance Point Full SP BackupSQL Backup Small Read heavy
  • Scale up, Scale out by creating new Service Applications
State Service Full SP BackupSQL Backup Medium to Large Read heavy
  • Scale out by creating additional Databases
Master Simple SQL Backup Small Varies
Model Full SQL Backup Small Varies
Msdb Simple SQL Backup Small Varies
Tempdb Simple SQL Backup Medium Varies
  • Locate on fast Disks and split Database to several Datafiles
Report Server – Catalog Full SQL Backup Small Read heavy
  • Scale Up
Report Server – Temp Full SQL Backup Small to XLarge Read heavy
  • Scale Up
Report server – Alerting Full SQL Backup Small to XLarge Equal Read Write heavy
  • Scale Up
  • Must be on same Server as the Repprt Server – Catalog

1.2         Database Maintenance

Source: http://technet.microsoft.com/en-us/library/cc262731(v=office.14).aspx

These advices were published for SharePoint 2010 but mainly still apply for SharePoint 2013. Only the Timer Jobs might have changed that do automatic Index Maintenance. For all Databases that are used for SharePoint 2013 Content do regularly Database Maintenance.

Action Databases Frequency Notes
DBCC CHECKDB All SharePoint DBs Weekly of before each Full Backup
  • You cannot run DBCC CHECKDB WITH REPAIR_ALLOW_DATA_LOSS.
  • You can run DBCC_CHECKDB WITH REPAIR_FAST and REPAIR_REBUILD
Index Rebuilding All SharePoint DBs Depends on:-          If Database has a Timer Job

–          Fragmentation Level

 

Fragmentation methods

 

Fragmentation level Defragmenta-tion method
Up to 10% Reorganize (online)
10-75% Rebuild (online)
75% Rebuild (offline)
  • Online Index Rebuild only for SQL Enterprise
  • Fallback from Online to Offline Index Rebuild might occur on special occasions (e.g. for LOB Columns)
  • Many of the SP Indexes are rebuilt Offline because of LOB Content (like documents, Pictures etc.)
  • Offline and Online Index Rebuild result in Locks or inaccessibility of Indexes and should therefore be done in low activity times
  • Use “sys.dm_db_index_physical_stats” to measure Fragmentation. Values from 0 to 10 in Column “avg_fragmentation_in_percent” are acceptable
  • SharePoint Timer Jobs (Health Rules) are doing a part of Index defragmentation and Stats updates
  • Timer Jobs look for its associated databases and performs proc_DefragmentIndices stored procedure on int. Indexes with Fragmentation > 30% are considered for reindex
  • Not all Databases have Timer Jobs and should be monitored manually
  • Using DROP INDEX or CREATE INDEX Operations are NOT supported on SharePoint Databases
AutoShrink All SharePoint DBs Never
  • Better Solution is to create a new database, move the Site Collections and delete the old database
  • Only if there is definitely a very high amount of unused space and you do not plan to reuse it and only for Content Databases
  • EMPTYFILE Option is not supported
  • TRUNCATEONLY Option is not supported
Maintenance Cleanup All SharePoint DBs Weekly or with scheduled maintenance plans

 

1.3         Supported and Unsupported Chagnes on SharePoint DBs

The Microsoft Office server products store data in Microsoft SQL Server databases. These products use various stored procedures for regular processing. Therefore, the Microsoft SQL Server databases are important to the successful operation of these products.

SharePoint Products were tested by using a database structure as designed by the SharePoint Development Team and were approved for release based on that structure. Microsoft cannot reliably predict the effect to the operation of these products when parties other than the Microsoft SharePoint Development Team or Microsoft SharePoint Support agents make changes to the database schema, modify its data, or execute ad hoc queries against the SharePoint databases. Exceptions are described in the „Supported Database Modifications“ section.

1.3.1        Unsupported Database Changes

Examples of unsupported database changes include, but are not limited to, the following:

  • Adding database triggers
  • Adding new indexes or changing existing indexes within tables
  • Adding, changing, or deleting any primary or foreign key relationships
  • Changing or deleting existing stored procedures
  • Calling existing stored procedures directly, except as described in the SharePoint Protocols documentation
  • Adding new stored procedures
  • Adding, changing, or deleting any data in any table of any of the databases for SharePoint
  • Adding, changing, or deleting any columns in any table of any of the databases for SharePoint
  • Making any modification to the database schema
  • Adding tables to any of the databases for SharePoint
  • Changing the database collation
  • Running DBCC_CHECKDB WITH REPAIR_ALLOW_DATA_LOSS (However, running DBCC_CHECKDB WITH REPAIR_FAST and REPAIR_REBUILD is supported, as these commands only update the indexes of the associated database.)
  • Enabling SQL Server change data capture (CDC)
  • Enabling SQL Server transactional replication
  • Enabling SQL Server merge replication

If an unsupported database modification is discovered during a support call, the customer must perform one of the following procedures at a minimum:

  • Perform a database restoration from the last known good backup that did not include the database modifications
  • Roll back all the database modifications

 

If a previous version of the database that does not include the unsupported modifications is unavailable, or if the customer cannot roll back the database modifications, the customer must recover the data manually. The database must be restored to an unmodified state before Microsoft SharePoint Support can provide any data migration assistance.

If it is determined that a database change is necessary, a support case should be opened to determine whether a product defect exists and should be addressed.

1.3.2        Supported database modifications

Exceptions to the prohibition against database modifications are made for specific usage scenarios:

  • Operations that are initiated from the SharePoint administrative user interface
  • SharePoint specific tools and utilities that are provided directly by Microsoft (for example, Ststadm.exe)
  • Changes that are made programmatically through the SharePoint Object Model and that are in compliance with the SharePoint SDK documentation
  • Activities that are in compliance with the SharePoint Protocols documentation

Additionally, in rare circumstances during a support incident, Microsoft SharePoint Support agents may give customers scripts that modify the databases that are used by SharePoint. In these cases, all modifications are reviewed by the SharePoint Development Team to ensure that the operations being performed will not result in an unstable or unsupported database state. Database changes that are made with the guidance of a Microsoft SharePoint Support agent during the course of a support incident will not result in an unsupported database state. Customers may not reapply the scripts or changes provided by Microsoft SharePoint Support outside of a support incident.

1.3.3        Read operations addendum

Reading from the SharePoint databases programmatically, or manually, can cause unexpected locking within Microsoft SQL Server which can adversely affect performance. Any read operations against the SharePoint databases that originate from queries, scripts, .dll files (and so on) that are not provided by the Microsoft SharePoint Development Team or by Microsoft SharePoint Support will be considered unsupported if they are identified as a barrier to the resolution of a Microsoft support engagement.

If unsupported read operations are identified as a barrier to the resolution of support engagement, the database will be considered to be in an unsupported state. To return the database to a supported state, all unsupported read activities must stop.

2         SQL Maintenance Script

Source: http://ola.hallengren.com/scripts/MaintenanceSolution.sql

The SQL Server Maintenance Solution comprises scripts for running backups, integrity checks, and index and statistics maintenance on all editions of Microsoft SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Server 2014. The solution is based on stored procedures, the sqlcmd utility, and SQL Server Agent jobs. I designed the solution for the most mission-critical environments, and it is used in many organizations around the world. Numerous SQL Server community experts recommend the SQL Server Maintenance Solution, which has been a Gold winner in the 2013, 2012, 2011, and 2010 SQL Server Magazine Awards. The SQL Server Maintenance Solution is free.

 

Die Collaboration User Story – Warum braucht es ein Collaboration Tool?


Dieses Video richtet sich an Entscheidungsträger, Projektleiter aber auch Technische Verantworltiche, die ihren Kunden gerne erklären würden, warum SharePoint eine gute Wahl für ihr Unternehmen ist. Es entlarvt die gängigen Fallstricke in der Zusammenarbeit und zeigt die gröbsten Vorteile von SharePoint verständlich auf.

Viel Spass beim zuschauen und teilen

So Long, Samuel

Best Practices Setup von SharePoint 2013, mit Web Apps 2013 und Workflow Manager 1.0


Hier mal noch das neuste Werk von mir, wo ich zeige, wie man SharePoint 2013 mit SQL, WebApps und Workflow Manager installiert. Inklusive aller Powershell Scripts für das Setup. Alles nach bisher bekannten Best Practices, auch für die SharePoint Topologie etc.

So long, Samuel

Collaboration beginnt im Kopf – nicht bei der Technik


Schon vor einiger Zeit habe ich mal in einer schlaflosen Nacht eine Präsentation über die Voraussetzungen von Kollaboration erstellt. Es geht dabei darum, dass Kollaboration nicht mit Technik beginnt, sondern in den Köpfen der Menschen. In der Art und Weise wie wir miteinander umgehen.

Wie sollen die Mitarbeiter zusammenarbeiten, einander helfen, sich gegenseitig unterstützen, wenn wir doch in einem System der Selbstbezogenheit, der Gewinnmaximierung und ROI Wahnsinn leben? Wenn es fast nur noch darum geht, was für mich drin ist? Wir es gewohnt sind, dass man uns alles zuträgt? Sit back and kick the TV on…

In dieser Präsentation habe ich mir über diese Themen Gedanken gemacht. Was müssen wir in unserer Zusammenarbeitskultur tun, damit wir auch mit den uns zur Verfügung stehenden Systemen zusammenarbeiten? Natürlich gebe ich die Präsentation auch mal gerne in euren Teammeetings oder auf Tagungen.

So Long, Samuel

 

Aufsetzen von SharePoint 2013 mit Powershell


So, endlich hab ich mir mal die Zeit genommen, die ganze Setup Geschichte von SharePoint 2013 mit Powershell anzuschauen. Mit ein paar bereits vorhandenen Scripts (ich will ja das Rad nicht neu erfinden) habe ich ein neues, bereinigtes, durchgängig strukturiertes und funktionierendes Zwinkerndes Smiley script zusammengestellt. Mittels dem Bereich “Definition of Variables and basic prep” könnt ihr alle Variablen angeben, und bei den $Create… Variablen mit 0 (nein) oder 1 (ja) angeben, ob ihr die entsprechende Service Application erstellen wollt oder nicht.

Der Script macht:

  1. SQL Server Aliases
  2. Managed Accounts
  3. Configuration Wizzard Tasks
  4. Farm Configuration Tasks

Benutzung auf eigene Gefahr. Vorgehen wie folgt:

  1. SharePoint 2013 Prep Tool laufen lassen
  2. SharePoint Installation laufen lassen
  3. den Haken am Ende der Installation raus nehmen
  4. Powerhsell laufen lassen (braucht erhöhte Rechte im SQL Server)

und gut ist.

So long, Samuel

 

############################################################
# Configures a SharePoint 2013 Farm                        #
# Samuel Zuercher, Experts Inside GmbH                     #
# @sharepointszu, szu@expertsinside.com                    #
#                                                          #
# Special Thanks to: Jason Warren, Zach and @sharepointeng #
# for basic scripts I started with                         #
#                                                          #
# Last modified 27.02.2013                                 #
#                                                          #
############################################################



############################################################
#                                                          #
# Farm Setup Section                                       #
# Definition of variables and basic prep                   #
#                                                          #
############################################################

# Domain
$DOMAIN = "DEMO"

# Application Pool for Services
$SaAppPoolName = "SharePoint Web Services Default"

# Basic Accountcredentials
$accounts = @{}
$accounts.Add("SPFarm", @{"username" = "sp-farm"; "password" = "Test12345"})
$accounts.Add("SPWebApp", @{"username" = "sp-portal"; "password" = "Test12345"})
$accounts.Add("SPSvcApp", @{"username" = "sp-services"; "password" = "Test12345"})

# SQL Alias
$SQLAliasName = "SharePointDB_Prod" #NoSpaces, make sure you know the name is selfexplaining, as it will stay as long the farm lives. No Years or Versions!!
$SQLServerName = "SQL\SHAREPOINT"   #Include Instance Name
$x86 = "HKLM:\Software\Microsoft\MSSQLServer\Client\ConnectTo"
$x64 = "HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo"

# Security Passphrase for SharePoint Setup
$ConfigPassphrase = "MySharePointIs2013"

# Giving the Names for Databases
$dbConfig = "TBD_DEMO_SharePoint_Config"
$dbCentralAdmin = "TBD_DEMO_SharePoint_CentralAdmin"

# Central Admin Port and Authentication Method
$CaPort = 11111
$CaAuthProvider = "NTLM"

# If you do not want to create a particular SA, set the Create...SA Flag to 0
# Usage and Health Data Collection Service Application
$CreateUsageAndHealth = 1
$UsageSAName = "Usage and Health Data Collection”
$dbUsageService = "TBD_DEMO_Usage_and_Health_Data"
$UsageLogLocation = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS”
$MaxUsageLogSpace = 5     #in GB

# State Service Application
$CreateStateSA = 1
$StateSAName = "State Service”
$dbStateService = "TBD_DEMO_State”

# Managed Metadata Service Application
$CreateManagedMetadataSA = 1
$ManagedMetadataSAName = "Managed Metadata Service”
$dbManagedMetadata = "TBD_DEMO_Managed_Metadata"

# Search Service Application and Topology
$CreateSearchService = 1
$SearchMachines = @("SP2013-V2")
$SearchQueryMachines = @("SP2013-V2")
$SearchCrawlerMachines = @("SP2013-V2")
$SearchAdminComponentMachine = "SP2013-V2"
$SearchSAName = "Search Service”
$dbSearchDatabase = "TBD_DEMO_Search”
$IndexLocation = "C:\SPIndex”

# Word Conversion Service Application
$CreateWordAutomation = 1
$WordSAName = "Word Automation Service"
$dbWordAutomation = "TBD_DEMO_WordAutomation"

# BCS Service Application
$CreateBcsSA = 1
$BcsSAName = "Business Connectivity Service"
$dbBcs = "TBD_DEMO_BusinessConnectivity"

# Secure store Service Application
$CreateSecureStore = 1
$SecureStoreSAName = "Secure Store Service"
$dbSecureStore = "TBD_DEMO_Secure_Store"

# Performance Point Service Application
$CreatePerformancePoint = 1
$PerformancePointSAName = "Performance Point Services"
$dbPerformancePoint = "TBD_DEMO_PerformancePoint"

# Visio Service Application
$CreateVisioService = 1
$VisioSAName = "Visio Services"

# User Profile Service Application
$CreateUserProfile = 1
$UserProfileSAName = "User Profile Service"
$dbUserProfile = "TBD_DEMO_UserProfile_Profiles"
$dbUserSocial ="TBD_DEMO_UserProfile_Social"
$dbUserSync ="TBD_DEMO_UserProfile_Sync"

# Subscription Settings Service Application
$CreateSubscription = 1
$SubscriptionSAName = “Subscription Settings Service”
$dbSubscription = "TBD_DEMO_Subscription_Settings"

# App management Service Application
$CreateAppMgmt = 1
$AppManagementSAName = "App Management Service"
$dbAppManagement = "TBD_DEMO_App_Management"

# Machine Translation Service Application
$CreateTranslationSA = 1
$TranslationSAName = “Machine Translation Service”
$dbTranslation = “TBD_DEMO_Machine_Translation”

# Work Management Service Application
$CreateWorkMgmtSA = 1
$WorkMgmtSAName = "Work Management Service"


############################################################
#                                                          #
# Prepare the Machine before configuring SharePoint        #
#                                                          #
############################################################

# Create the basic Accounts for Setup 
Foreach ($account in $accounts.keys) {
    $accounts.$account.Add(`
    "credential", `
    (New-Object System.Management.Automation.PSCredential ($DOMAIN + "\" + $accounts.$account.username), `
    (ConvertTo-SecureString -String $accounts.$account.password -AsPlainText -Force)))
}
  
# Check if Registry Key Paths for SQL-Alias already exist, create them if not
if ((test-path -path $x86) -ne $True)
{
    write-host "$x86 doesn't exist"
    New-Item $x86
}
if ((test-path -path $x64) -ne $True)
{
    write-host "$x64 doesn't exist"
    New-Item $x64
}
  
# Creating String to add TCP/IP Alias
$TCPAlias = ("DBMSSOCN," + $SQLServerName)
  
#Creating our TCP/IP Aliases
New-ItemProperty -Path $x86 -Name $SQLAliasName -PropertyType String -Value $TCPAlias
New-ItemProperty -Path $x64 -Name $SQLAliasName -PropertyType String -Value $TCPAlias
 
# Open cliconfig to verify the aliases
Start-Process C:\Windows\System32\cliconfg.exe
Start-Process C:\Windows\SysWOW64\cliconfg.exe

# Farm Passphrase
$s_configPassphrase = (ConvertTo-SecureString -String $ConfigPassphrase -AsPlainText -force)

 

############################################################
#                                                          #
# SharePoint 2013 Product Configuration Wizzard Steps      #
# No need to run the Wizzard within the GUI!!              #
#                                                          #
############################################################

# Make SharePoint PowerShell Availlable
Add-PSSnapin Microsoft.SharePoint.PowerShell

# Creating SharePoint Configuration Database
Write-Output "Creating the configuration database $dbConfig"
New-SPConfigurationDatabase -DatabaseName $dbConfig -DatabaseServer $SQLAliasName -AdministrationContentDatabaseName $dbCentralAdmin -Passphrase  $s_configPassphrase -FarmCredentials $accounts.SPFarm.credential
 
# Check to make sure the farm exists and is running. if not, end the script
$Farm = Get-SPFarm
if (!$Farm -or $Farm.Status -ne "Online") {
    Write-Output "Farm was not created or is not running"
    exit
}
 
Write-Output "Create the Central Administration site on port $CaPort"
New-SPCentralAdministration -Port $CaPort -WindowsAuthProvider $CaAuthProvider
 
# Perform the config wizard tasks
 
Write-Output "Install Help Collections"
Install-SPHelpCollection -All
 
Write-Output "Initialize security"
Initialize-SPResourceSecurity
 
Write-Output "Install services"
Install-SPService
 
Write-Output "Register features"
Install-SPFeature -AllExistingFeatures
 
Write-Output "Install Application Content"
Install-SPApplicationContent
 
 
# Add managed accounts
Write-Output "Creating managed accounts ..."
New-SPManagedAccount -credential $accounts.SPWebApp.credential
New-SPManagedAccount -credential $accounts.SPSvcApp.credential
 
#Start Central Administration
Write-Output "Starting Central Administration"
& 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN\psconfigui.exe' -cmd showcentraladmin
 
Write-Output "Farm build complete."



############################################################
#                                                          #
# Functions to create Service Applications                 #
#                                                          #
############################################################

# Usage and Health Data Collection
function UsageAndHealthSA {
    Write-Host "Creating Usage and Health Data Collection..."
    Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation $UsageLogLocation -UsageLogMaxSpaceGB $MaxUsageLogSpace
    $UsageService = Get-SPUsageService
    New-SPUsageApplication -Name $UsageSAName -DatabaseServer $SQLAliasName -DatabaseName $dbUsageService -UsageService $UsageService > $null
    }

# State Service
function StateServiceSA {
    Write-Host "Creating State Service..."
    New-SPStateServiceDatabase -Name $dbStateService
    $StateSAPipe = New-SPStateServiceApplication -Name $StateSAName -Database $dbStateService
    New-SPStateServiceApplicationProxy -Name "$StateSAName Proxy” -ServiceApplication $StateSAPipe -DefaultProxyGroup
    }

# Managed Metadata Service Application
function ManagedMetadataSA {
    Write-Host "Creating Managed Metadata Service..."
    New-SPMetadataServiceApplication -Name $ManagedMetadataSAName –ApplicationPool $SaAppPoolName -DatabaseServer $SQLAliasName -DatabaseName $dbManagedMetadata > $null
    New-SPMetadataServiceApplicationProxy -Name "$ManagedMetadataSAName Proxy” -ServiceApplication $ManagedMetadataSAName -DefaultProxyGroup > $null
    Get-SPServiceInstance | where-object {$_.TypeName -eq $ManagedMetadataSAName} | Start-SPServiceInstance > $null
}

# Enterprise Search SA and Topology
function EnterpriseSearchSA {
    Write-Host "Creating Search Service Application…”
    Write-Host "Starting Services…”
    foreach ($Machine in $SearchMachines) {
        Write-Host ” Starting Search Services on $Machine”
        Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $Machine -ErrorAction SilentlyContinue
        Start-SPEnterpriseSearchServiceInstance $Machine -ErrorAction SilentlyContinue
    }
    Write-Host "Creating Search Service Application…”
    $SearchSA = New-SPEnterpriseSearchServiceApplication -Name $SearchSAName -ApplicationPool $SaAppPoolName -DatabaseServer $SQLAliasName -DatabaseName $dbSearchDatabase
    $SearchInstance = Get-SPEnterpriseSearchServiceInstance -Local
    Write-Host "Defining the Search Topology…”
    $InitialSearchTopology = $SearchSA | Get-SPEnterpriseSearchTopology -Active
    $NewSearchTopology = $SearchSA | New-SPEnterpriseSearchTopology
    Write-Host "Creating Admin Component…”
    New-SPEnterpriseSearchAdminComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance
    Write-Host "Creating Analytics Component…”
    New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance
    Write-Host "Creating Content Processing Component…”
    New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance
    Write-Host "Creating Query Processing Component…”
    New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance
    Write-Host "Creating Crawl Component…”
    New-SPEnterpriseSearchCrawlComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance
    Write-Host "Creating Index Component…”
    if (!(Test-Path -path $Indexlocation)) {New-Item $Indexlocation -Type Directory}
    New-SPEnterpriseSearchIndexComponent -SearchTopology $NewSearchTopology -SearchServiceInstance $SearchInstance -RootDirectory $IndexLocation
    Write-Host "Activating the new topology…”
    $NewSearchTopology.Activate()
    Write-Host "Creating Search Application Proxy…”
    $SearchProxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity "$SearchSAName Proxy” -ErrorAction SilentlyContinue
    if (!$searchProxy) {
        New-SPEnterpriseSearchServiceApplicationProxy -Name "$SearchSAName Proxy” -SearchApplication $SearchSA
    }
}

function WordAutomationSA {
    Write-Host "Creating Word Automation Service..."
    New-SPWordConversionServiceApplication -Name $WordSAName -ApplicationPool $SaAppPoolName -DatabaseName $dbWordAutomation -DatabaseServer $SQLAliasName -Default
}

function BcsSA {
    Write-Host "Creating Business Connectivity Service..."
    $BcsSAPipe = New-SPBusinessDataCatalogServiceApplication –ApplicationPool $SaAppPoolName –DatabaseName $dbBcs –DatabaseServer $SQLAliasName –Name $BcsSAName
    #New-SPBusinessDataCatalogServiceApplicationProxy -Name “$BcsSAName Proxy“ -ServiceApplication $BcsSAPipe -DefaultProxyGroup
}

function SecureStoreSA {
    Write-Host "Creating Secure Store Service..."
    $SecureStoreSAPipe = New-SPSecureStoreServiceApplication –ApplicationPool $SaAppPoolName –AuditingEnabled:$false –DatabaseServer $SQLAliasName –DatabaseName $dbSecureStore –Name $SecureStoreSAName
    New-SPSecureStoreServiceApplicationProxy –Name “$SecureStoreSAName Proxy ” –ServiceApplication $SecureStoreSAPipe -DefaultProxyGroup
}

function PerformancePointSA {
    Write-Host "Creating PerformancePoint Service..."
    $PerformancePointSAPipe = New-SPPerformancePointServiceApplication -Name $PerformancePointSAName -ApplicationPool $SaAppPoolName -DatabaseName $dbPerformancePoint
    New-SPPerformancePointServiceApplicationProxy -Name "$PerformancePointSAName Proxy" -ServiceApplication $PerformancePointSAPipe -Default
}

function VisioSA {
#    Write-Host "Creating Visio Service..."
#    $VisioSAPipe = New-SPVisioServiceApplication -Identity "Visio Services" -ServiceApplicationPool $SaAppPoolName
#    New-SPVisioServiceApplicationProxy -Name "$VisioSAName Proxy" -ServiceApplication $VisioSAPipe
}

function UserProfileSA {
    Write-Host "Creating User Profile Service..."
    $UserProfileSAPipe = New-SPProfileServiceApplication -Name $UserProfileSAName -ApplicationPool $SaAppPoolName -ProfileDBServer $SQLAliasName -ProfileDBName $dbUserProfile -SocialDBServer $SQLAliasName -SocialDBName $dbUserSocial -ProfileSyncDBServer $SQLAliasName -ProfileSyncDBName $dbUserSync
    New-SPProfileServiceApplicationProxy -Name “$UserProfileSAName Proxy” -ServiceApplication $UserProfileSAPipe -DefaultProxyGroup > $null
    Get-SPServiceInstance | where-object {$_.TypeName -eq $UserProfileSAName} | Start-SPServiceInstance > $null
}

function SubscriptionSA {
    Write-Host “Creating Subscription Settings Service…”
    $SubscriptionSAPipe = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $SaAppPoolName –Name $SubscriptionSAName –DatabaseName $dbSubscription
    New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $SubscriptionSAPipe
    Get-SPServiceInstance | where-object {$_.TypeName -eq $SubscriptionSAName} | Start-SPServiceInstance > $null
}

function AppManagementSA {
    Write-Host “Creating App Management Service…”
    $AppManagementSAPipe = New-SPAppManagementServiceApplication -Name $AppManagementSAName -DatabaseServer $SQLAliasName -DatabaseName $dbAppManagement –ApplicationPool $SaAppPoolName
    New-SPAppManagementServiceApplicationProxy -Name “$AppManagementSAName Proxy” -ServiceApplication $AppManagementSAPipe
    Get-SPServiceInstance | where-object {$_.TypeName -eq $AppManagementSAName} | Start-SPServiceInstance > $null
}

function MachineTranslationSA {
    Write-Host "Creating Machine Translation Service..."
    Get-SPServiceInstance | ? {$_.GetType().Name -eq $TranslationSAName} | Start-SPServiceInstance
    $MachineTranlsationSAPipe = New-SPTranslationServiceApplication -Name $TranslationSAName -ApplicationPool $SaAppPoolName -DatabaseName $dbTranslation
    #New-SPTranslationServiceApplicationProxy –Name “$TranslationSAName Proxy” –ServiceApplication $MachineTranlsationSAPipe –DefaultProxyGroup
}

function WorkManagementSA {
    Write-Host "Creating Work Management Service..."
    $WorkManagementSAPipe = New-SPWorkManagementServiceApplication –Name $WorkMgmtSAName –ApplicationPool $SaAppPoolName
    New-SPWorkManagementServiceApplicationProxy -name “$WorkMgmtSAName Proxy” -ServiceApplication $WorkManagementSAPipe
}



############################################################
#                                                          #
# Do SharePoint Farm Configuration                         #
# No need to run the Wizzard within the GUI!!              #
#                                                          #
############################################################

# Make sure, Admin wants to go on Configuring the Farm with this Script
$DoConfig = Read-Host "Do you want to go on Configuring your Farm? (Y/N) Standard is Y"
if ($DoConfig -eq "N")
{
    exit
}

# Creating App Pool for Service Applications
New-SPServiceApplicationPool -Name $SaAppPoolName -Account (Get-SPManagedAccount -Identity "demo\sp-services")

# Calling Functions to create
# Create Usage and Health Data Collection Service Applications
if ($CreateUsageAndHealth -eq 1) {
    UsageAndHealthSA
}

# Create State Service Application
if ($CreateUsageAndHealth -eq 1) {
    StateServiceSA
}

# Create Manage Metadata Service Application
if ($CreateManagedMetadataSA -eq 1) {
    ManagedMetadataSA
}

# Create Enterprise Search Service Application
if ($CreateSearchService -eq 1) {
    EnterpriseSearchSA
}

# Create Word Automation Service Application
if ($CreateWordAutomation -eq 1) {
    WordAutomationSA
}

# Create BCS Service Application
if ($CreateBcsSA -eq 1) {
    BcsSA
}

# Create Secure Store Service Application
if ($CreateSecureStore -eq 1) {
    SecureStoreSA
}

# Create Performance Point Service Application
if ($CreatePerformancePoint -eq 1) {
    PerformancePointSA
}

# Create Visio Service Application
if ($CreateVisioService -eq 1) {
    VisioSA
}

# User Profile Service Application
if ($CreateUserProfile -eq 1) {
    UserProfileSA
}

# Subscription Settings Service Application
if ($CreateSubscription -eq 1) {
    SubscriptionSA
}

# App Management Service Application
if ($CreateAppMgmt -eq 1) {
    AppManagementSA
}

# Machine Translation Service Application
if ($CreateTranslationSA -eq 1) {
    MachineTranslationSA
}

# Work Management Service Application
if ($CreateWorkMgmtSA -eq 1) {
    WorkManagementSA
}

SQL Script für die Erstellung von Best Practice SharePoint Datenbanken


Na dass wird aber auch Zeit. Endlich poste ich auch hier zur Vollständigkeit den Post, welchen ich im SharePointAdvent gepostet habe. Er ist die Fortsetzung vom Post Best Practice SQL Setup.

Wie in meinem letzten Post erläutert, macht es durchaus Sinn, sich im Bereich SharePoint auch über das Backend Gedanken zu machen. Ein Teil davon ist die Erstellung der Datenbanken. Eigentlich sollte es den Button "Add new Content Database" in SharePoint gar nicht geben.

addcontentdb1

Warum? Hier sind die Gründe:

SharePoint erstellt eine neue Datenbank ab der Model und diese ist von Natur aus so konfiguriert:

  • 2MB gross (oder besser gesagt klein)
  • Ein einzelnes File in der Primary Filegroup
  • Growth ist auf 1 MB Unlimited Growth
  • Logfile ist 1MB gross
  • Growth ist 10%

model

Nach dem Erstellen einer leeren SharePoint Datenbank ist diese 2o MB gross, das heisst, sie ist bereits 18x gewachsen. Durch das Wachstum einer DB wird sie fragmentiert und wie man weiss, ist alles was fragmentiert ist langsamer, da die Datenstücke nicht aneinander hängen, sondern verteilt sind. Diese Verteilung muss vom DB Management System aufgefangen werden. Dieser Reibungsverlust schlägt sich in der Performance nieder.

DiskSpaceGrowth

Wenn ich nun die DB Stats abfrage, bekomme ich den Fragmentierungslevel der neuen Datenbank mitgeteilt, ACHTUNG: Es handelt sich notabene um eine leere SharePoint Datenbank, die noch überhaupt keinen Content enthält. SELECT * FROM sys.dm_db_index_physical_stats (DB_ID(‚DB Name‘), Null, Null, Null, Null);

DBStats

Ich erhalte hier 230 Rows, jede Row enthält den Hinweis auf einen Index. Meine Datenbank ist also schon sehr stark fragmentiert, obwohl sie leer ist. Da kann man sich vorstellen, dass dies an der Performance nagt.

Ein weiterer Punkt ist, dass allea auf einem Datenfile abgeht. Heute haben Prozessoren mehrere Kerne, und jeder hackt auf dem armen File rum. Viel besser ist es, wenn jeder Kern sich auf ein anderes File konzentrieren kann. Wenn eine DB in mehrere Files unterteilt ist, so wird abwechselnd auf die Files eingedroschen, was sich wiederum positiv auf die Performance auswirkt. Die Fausregel sagt, dass pro Prozessorkern 0.25 bis 0.5 Files angelegt werden sollten, mindestens aber 4. Bei mehr als 8 Files ist dann kein grosser Unterschied mehr spürbar. Beachten Sie folgendes:

  • Berechnen Sie vorab, wie viel Content später mal in die DB rein soll
  • Erstellen Sie die initiale DB Grösse entsprechend ein (wir sprechen von GB nicht von BYTES)
  • Stellen Sie das Wachstum auf eine vernünftige Grösse ein
  • Stellen Sie das LOG auch auf 1GB oder teilbar durch 8GB

Hier kommt der Script vorher noch im SQL Mgmt Studio unter "Query" den "SQL CMD Mode" aktivieren, alles was rot ist muss von euch noch customized werden (auch der User ganz am Ende, da kommt der Farm Admin rein:

/*—————————————————————————————
  Disclaimer – Thoroughly test this script, execute at your own risk.
  —————————————————————————————
 
  set variables (Filesizes in MB)*/
:setvar DBName MyAdventDB
:setvar LoginitialMB 1024
:setvar LoggrowMB 1024
:setvar DatainitialMBperFile 341
:setvar DatagrowMBperFile 341
:setvar DataPath “C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA”
:setvar LogPath “C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA”
 
CREATE DATABASE [$(DBName)] ON  PRIMARY
/*no grow on Primary-File (its only for sys tables and Service Broker Queues)*/
( NAME = N’$(DBName)Data01′, FILENAME = N’$(DataPath)\$(DBName)Data01.mdf‘ , SIZE = 128MB , FILEGROWTH = 0),
/* 0.25-1 file per cpu core (each with same initial and grow size)*/
( NAME = N’$(DBName)_Data02′, FILENAME = N’$(DataPath)\$(DBName)_Data02.ndf‘ , SIZE = $(DatainitialMBperFile)MB , FILEGROWTH = $(DatagrowMBperFile)MB ),
( NAME = N’$(DBName)_Data03′, FILENAME = N’$(DataPath)\$(DBName)_Data03.ndf‘ , SIZE = $(DatainitialMBperFile)MB , FILEGROWTH = $(DatagrowMBperFile)MB ),
( NAME = N’$(DBName)_Data04′, FILENAME = N’$(DataPath)\$(DBName)_Data04.ndf‘ , SIZE = $(DatainitialMBperFile)MB , FILEGROWTH = $(DatagrowMBperFile)MB ),
( NAME = N’$(DBName)_Data05′, FILENAME = N’$(DataPath)\$(DBName)_Data05.ndf‘ , SIZE = $(DatainitialMBperFile)MB , FILEGROWTH = $(DatagrowMBperFile)MB )
LOG ON
/* place tlog on another diskarray, use best practice size for optimal vlf handling (1GB/8GB)*/
( NAME = N’$(DBName)_log‘, FILENAME = N’$(LogPath)\$(DBName)_log.ldf‘ , SIZE = $(LoginitialMB)MB , FILEGROWTH = $(LoggrowMB)MB )
/* collation for database */
COLLATE Latin1_General_CI_AS_KS_WS
GO
/* 90=2005/100=2008*/
ALTER DATABASE [$(DBName)] SET COMPATIBILITY_LEVEL = 100
GO
ALTER DATABASE [$(DBName)] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [$(DBName)] SET ANSI_NULLS OFF
GO
/* set ANSI_PADDING True, refer to BOL for more information, not default setting*/
ALTER DATABASE [$(DBName)] SET ANSI_PADDING ON
GO
ALTER DATABASE [$(DBName)] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [$(DBName)] SET ARITHABORT OFF
GO
ALTER DATABASE [$(DBName)] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [$(DBName)] SET AUTO_CREATE_STATISTICS ON
GO
/* never use AUTO_SHRINK on a production DB*/
ALTER DATABASE [$(DBName)] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [$(DBName)] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [$(DBName)] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [$(DBName)] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [$(DBName)] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [$(DBName)] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [$(DBName)] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [$(DBName)] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [$(DBName)] SET  DISABLE_BROKER
GO
ALTER DATABASE [$(DBName)] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [$(DBName)] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [$(DBName)] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [$(DBName)] SET  READ_WRITE
GO
/* use same recovery model for each db in an instance (exceptions in olap environments)*/
ALTER DATABASE [$(DBName)] SET RECOVERY FULL
GO
ALTER DATABASE [$(DBName)] SET  MULTI_USER
GO
/* change all dbs to checksum since 2005*/
ALTER DATABASE [$(DBName)] SET PAGE_VERIFY CHECKSUM
GO
 
/* change db owner*/
USE [$(DBName)]
GO
EXEC dbo.sp_changedbowner @loginame = N’domain\user‘, @map = false
GO

 

Am Ende noch mit Powershell an SharePoint anhängen und gut ist.

New-SPContentDatabase -Name <ContentDbName> -WebApplication <WebApplicationName>

So long, Samuel