Le service de recherche (Search Service Application) est l'un des composants les plus critiques et les plus gourmands en ressources d'une ferme SharePoint On-Premise. Depuis SharePoint 2013 (et cela reste vrai pour 2019 et SE), il n'existe plus d'interface graphique complète dans l'Administration Centrale pour configurer la topologie de recherche avancée. Tout doit passer par PowerShell.
Dans un environnement de production multi-serveurs, il est crucial de distribuer les six composants de recherche (Administration, Analyse, Traitement du contenu, Indexation, Traitement des requêtes et Analyse de recherche) sur plusieurs serveurs. Cela garantit non seulement de meilleures performances, mais surtout une haute disponibilité (Redondance) en cas de panne d'un nœud.
Voici un guide technique et un script PowerShell optimisé pour déployer votre topologie de recherche sur une ferme à plusieurs serveurs.
1. Comprendre la Topologie de Recherche
Dans une ferme SharePoint moderne (utilisant ou non les MinRoles), l'architecture recommandée pour la recherche consiste à dédier des serveurs spécifiques à ces tâches.
Prenons l'exemple d'une ferme avec deux serveurs d'application dédiés à la recherche : SP-APP01 et SP-APP02. Pour assurer la redondance :
-
Chaque serveur hébergera une instance de chaque composant (Admin, Crawl, Content, Analytics, Query).
-
Pour l'Index, nous allons créer deux partitions (Partition 0 et Partition 1). Chaque serveur aura le rôle principal pour une partition, et le rôle de réplique (Replica) pour l'autre. Ainsi, si un serveur tombe, l'index complet reste disponible.
2. Prérequis : Préparer l'infrastructure
Avant de lancer le script de création, vous devez préparer les disques qui accueilleront l'index. L'index de recherche effectue de nombreuses opérations d'entrée/sortie (I/O). Il est fortement recommandé d'utiliser des disques SSD dédiés.
Script de préparation des dossiers d'Index (à exécuter sur les serveurs de recherche) :
# Définition des emplacements (Adapter selon vos lettres de lecteur)
$PrimaryIndexLoc = "D:\SPIndex\Primary"
$ReplicaIndexLoc = "E:\SPIndex\Replica"
# Création des répertoires s'ils n'existent pas
New-Item -ItemType Directory -Force -Path $PrimaryIndexLoc
New-Item -ItemType Directory -Force -Path $ReplicaIndexLoc
Write-Host "Dossiers d'index préparés avec succès." -ForegroundColor Green
3. Le Script PowerShell de Déploiement (Optimisé)
Ce script automatise la création du compte de service, de la Service Application, le démarrage des instances sur les serveurs cibles, et la configuration de la topologie de recherche croisée.
Attention : Exécutez ce script depuis le SharePoint Management Shell en tant qu'administrateur de la ferme.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# 1. PARAMÈTRES DE CONFIGURATION
$SSA_Name = "Enterprise Search Service Application"
$SSA_ProxyName = "Enterprise Search Service Application Proxy"
$AppPoolName = "SharePoint_Search_AppPool"
$ManagedAccountName = "DOMAIN\svc_sp_search" # Compte de service dédié
$DatabaseServer = "SQL-PROD-01"
$DatabaseName = "SP_Search_AdminDB"
# Serveurs hébergeant la recherche
$SearchSrv1 = "SP-APP01"
$SearchSrv2 = "SP-APP02"
# Emplacements d'Index (Doivent exister physiquement sur les serveurs)
$PrimaryIndexLoc = "D:\SPIndex\Primary"
$ReplicaIndexLoc = "E:\SPIndex\Replica"
# 2. PRÉPARATION DU COMPTE ET DE L'APP POOL
Write-Host "Vérification du compte géré..." -ForegroundColor Cyan
$ManagedAccount = Get-SPManagedAccount -Identity $ManagedAccountName -ErrorAction SilentlyContinue
if (!$ManagedAccount) {
Write-Warning "Le compte $ManagedAccountName n'est pas enregistré dans SharePoint. Veuillez l'ajouter dans la sécurité de la ferme d'abord."
return
}
Write-Host "Création du Pool d'Application..." -ForegroundColor Cyan
$AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue
if (!$AppPool) {
$AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $ManagedAccount
}
# 3. CRÉATION DE LA SERVICE APPLICATION
Write-Host "Création de l'application de service de recherche..." -ForegroundColor Cyan
$SSA = Get-SPEnterpriseSearchServiceApplication -Identity $SSA_Name -ErrorAction SilentlyContinue
if (!$SSA) {
$SSA = New-SPEnterpriseSearchServiceApplication -Name $SSA_Name -ApplicationPool $AppPool -DatabaseServer $DatabaseServer -DatabaseName $DatabaseName
}
$SSAProxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SSA_ProxyName -ErrorAction SilentlyContinue
if (!$SSAProxy) {
$SSAProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name $SSA_ProxyName -SearchApplication $SSA
}
# 4. DÉMARRAGE DES INSTANCES SUR LES SERVEURS
Write-Host "Démarrage des services de recherche sur les serveurs (Cela peut prendre plusieurs minutes)..." -ForegroundColor Cyan
$Servers = @($SearchSrv1, $SearchSrv2)
foreach ($Srv in $Servers) {
$Instance = Get-SPEnterpriseSearchServiceInstance -Identity $Srv
if ($Instance.Status -ne "Online") {
Start-SPEnterpriseSearchServiceInstance -Identity $Srv
do {
Start-Sleep -Seconds 10
$Instance = Get-SPEnterpriseSearchServiceInstance -Identity $Srv
Write-Host "." -NoNewline
} while ($Instance.Status -ne "Online")
Write-Host "Service démarré sur $Srv" -ForegroundColor Green
}
}
# 5. CONFIGURATION DE LA TOPOLOGIE
Write-Host "Clonage et configuration de la nouvelle topologie..." -ForegroundColor Cyan
$InitialTopology = Get-SPEnterpriseSearchTopology -SearchApplication $SSA -Active
$NewTopology = New-SPEnterpriseSearchTopology -SearchApplication $SSA
$Srv1Instance = Get-SPEnterpriseSearchServiceInstance -Identity $SearchSrv1
$Srv2Instance = Get-SPEnterpriseSearchServiceInstance -Identity $SearchSrv2
# Ajout des composants sur Srv1
New-SPEnterpriseSearchAdminComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance
New-SPEnterpriseSearchCrawlComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance
# Ajout des composants sur Srv2
New-SPEnterpriseSearchAdminComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance
New-SPEnterpriseSearchCrawlComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance
# Configuration de l'Index croisé (Partition 0 et 1 avec répliques)
Write-Host "Configuration de l'Index croisé..." -ForegroundColor Cyan
New-SPEnterpriseSearchIndexComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance -IndexPartition 0 -RootDirectory $PrimaryIndexLoc
New-SPEnterpriseSearchIndexComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance -IndexPartition 0 -RootDirectory $ReplicaIndexLoc
New-SPEnterpriseSearchIndexComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv2Instance -IndexPartition 1 -RootDirectory $PrimaryIndexLoc
New-SPEnterpriseSearchIndexComponent -SearchTopology $NewTopology -SearchServiceInstance $Srv1Instance -IndexPartition 1 -RootDirectory $ReplicaIndexLoc
# Activation de la topologie
Write-Host "Activation de la topologie (Cette étape est longue)..." -ForegroundColor Yellow
Set-SPEnterpriseSearchTopology -Identity $NewTopology
# Nettoyage de l'ancienne topologie
Remove-SPEnterpriseSearchTopology -Identity $InitialTopology -Confirm:$false
Write-Host "Topologie de recherche configurée avec succès !" -ForegroundColor Green
4. Architectures plus larges (4 Serveurs ou plus)
Si votre ferme possède 4 serveurs dédiés à la recherche, la bonne pratique architecturale Microsoft (pour limiter les goulets d'étranglement) consiste à isoler les composants d'Index et de Requête (Query) sur des serveurs distincts des composants de Crawl et de Traitement du contenu.
-
Serveurs 1 & 2 : Admin, Crawl, Content Processing, Analytics.
-
Serveurs 3 & 4 : Index, Query Processing.
Pour adapter le script, il suffit d'ajouter les instances des serveurs 3 et 4 et d'attribuer les commandes New-SPEnterpriseSearchIndexComponent et New-SPEnterpriseSearchQueryProcessingComponent à ces nouvelles instances.
5. Références Microsoft
Pour aller plus loin dans l'optimisation et le redimensionnement de votre architecture de recherche :
Conclusion
Déployer la recherche SharePoint via PowerShell peut sembler complexe de prime abord, mais c'est la seule méthode permettant de garantir une architecture véritablement résiliente. En cas de montée en charge, cette approche scriptée vous permettra d'ajouter rapidement de nouveaux nœuds de crawl ou d'indexation sans perturber le service.