[玩转系统] 使用 PowerShell 在 SharePoint 2016 多服务器场中创建搜索服务应用程序
作者:精品下载站 日期:2024-12-14 14:45:14 浏览:13 分类:玩电脑
使用 PowerShell 在 SharePoint 2016 多服务器场中创建搜索服务应用程序
顾名思义,SharePoint 中的搜索服务应用程序提供搜索功能。从 SharePoint 2013 开始,我们必须使用 PowerShell 脚本来配置搜索服务应用程序。尽管我们可以创建新的搜索服务应用程序实例,但没有用于从 SharePoint Central Admin 配置搜索拓扑的用户界面。
为多服务器场配置 SharePoint 2016 搜索服务应用程序:
虽然我之前的文章介绍了如何在 SharePoint 2013 中创建搜索服务应用程序 - 单服务器场,用于独立的 SharePoint 2013 或 SharePoint 2016 安装,但在生产环境中,我们可能必须将搜索组件分发到多服务器中的不同服务器并进行负载平衡。 -服务器群。
以下是建议的高级场搜索拓扑:
我的 SharePoint 2016 环境中有以下使用共享 MinRoles 的服务器:
- Web 前端 + 分布式缓存服务器 - 2
- 应用程序 + 搜索服务器 - 2
由于我们将在 SharePoint 场中使用多个服务器,因此我们可以通过拆分六个搜索组件(管理、爬网、内容处理、索引、分析和查询处理)来向搜索应用程序添加冗余、性能和可靠性。此外,我们将配置两个索引分区,以确保两台服务器都有搜索索引的副本。
在 SharePoint 2016 中配置搜索服务应用程序的 PowerShell:
对搜索拓扑的修改需要对 SharePoint 搜索拓扑和 PowerShell 有深入的了解。以下是用于在多服务器 SharePoint 2016 环境中创建搜索服务应用程序的 PowerShell 脚本。您可以根据您的环境添加或修改拓扑组件。让我们举个例子。就我而言,我们有两个 SharePoint 搜索应用服务器来托管所有搜索组件。为 SharePoint 2016 创建搜索服务应用程序涉及以下高级步骤:
- 为搜索服务应用程序创建托管帐户和应用程序池。
- 创建 SharePoint 搜索服务应用程序和代理
- 在参与搜索拓扑的所有服务器上启动搜索服务实例
- 创建搜索拓扑并添加搜索组件,然后激活搜索拓扑
使用 PowerShell 创建搜索服务应用程序:
以下是用于创建 SharePoint 2016 搜索服务应用程序的 PowerShell 脚本。
将此脚本复制粘贴到 PowerShell ISE 或任何其他 PowerShell 编辑器(PowerGUI?),根据您的环境设置配置参数并一次运行一步!在运行主脚本之前,在托管搜索拓扑索引组件的所有服务器上为索引位置和副本位置创建文件夹(如变量:$PrimaryIndexLocation 和 $ReplicaIndexLocation)!
#Set the primary and replica index locations
$PrimaryIndexLocation = "D:\SearchIndex"
$ReplicaIndexLocation = "E:\SearchIndexReplica"
#Prepare Index Locations
Remove-Item -Recurse -Force -LiteralPath $PrimaryIndexLocation -ErrorAction SilentlyContinue
MKDIR -Path $PrimaryIndexLocation -Force
Remove-Item -Recurse -Force -LiteralPath $ReplicaIndexLocation -ErrorAction SilentlyContinue
MKDIR -Path $ReplicaIndexLocation -Force
用于在 SharePoint 2016 中配置搜索服务应用程序的 PowerShell 脚本:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Region Config_Parameters
#Settings for Search Service Application
$SearchServiceApplicationName = "Search Service Application"
$SearchServiceApplicationProxyName = "Search Service Application Proxy"
$SearchAppPoolAccount = "Crescent\SP16_Services"
$SearchDatabaseServer = "SP16_SQL"
$SearchServiceApplicationDatabase = "Crescent_Search_ServiceApp"
$SearchAppPoolName = "Service Application App Pool"
#Farm Server topology: App with Search role: 2
$SearchAppServer1 = "SP16-APPSrv01"
$SearchAppServer2 = "SP16-APPSrv02"
#Set the primary and replica index locations
$PrimaryIndexLocation = "D:\SearchIndex"
$ReplicaIndexLocation = "E:\SearchIndexReplica"
#EndRegion
#*** Step 1: Create Managed Account, Service Application Pool for Search Service Application ****
#Check if Managed account is registered already
Write-Host -ForegroundColor Yellow "Checking if the Managed Accounts already exists..."
$SearchAppPoolAccount = Get-SPManagedAccount -Identity $SearchAppPoolAccount -ErrorAction SilentlyContinue
If ($SearchAppPoolAccount -eq $null)
{
Write-Host "Please Enter the password for the Service Account..."
$AppPoolCredentials = Get-Credential $SearchAppPoolAccount
$SearchAppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials
write-host "Managed Account has been Created!" -ForegroundColor Green
}
#Try to Get the existing Application Pool
Write-Host -ForegroundColor Yellow "Checking if the App Pool already exists..."
$SearchServiceAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue
#If Application pool Doesn't exists, Create it
if ($SearchServiceAppPool -eq $Null)
{
$SearchServiceAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccount
write-host "Created New Service Application Pool!" -ForegroundColor Green
}
#*** Step 2: Start Search Service Instances on required servers ***
Write-host "Starting Service Instances..." -ForegroundColor Green
#Search App Server 1
$SearchAppInstance1 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer1
if(-not($SearchAppInstance1.Status -eq "Online"))
{
Write-Host -ForegroundColor Yellow "Starting Search Service instance on $SearchAppServer1..." -NoNewline
$SearchAppInstance1 | Start-SPEnterpriseSearchServiceInstance
while ($SearchAppInstance1.Status -ne "Online")
{
Write-Host -ForegroundColor Green "." -NoNewline
Start-Sleep -Seconds 5
$SearchAppInstance1 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer1
}
Write-Host -ForegroundColor Green "Started Search Service instance on $SearchAppServer1"
}
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchAppServer1 -ErrorAction SilentlyContinue
#Search App Server 2
$SearchAppInstance2 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer2
if(-not($SearchAppInstance2.Status -eq "Online"))
{
Write-Host -ForegroundColor Yellow "Starting Search Service instance on $SearchAppServer2..." -NoNewline
$SearchAppInstance2 | Start-SPEnterpriseSearchServiceInstance
while ($SearchAppInstance2.Status -ne "Online")
{
Write-Host -ForegroundColor Green "." -NoNewline
Start-Sleep -Seconds 5
$SearchAppInstance2 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer2
}
Write-Host -ForegroundColor Green "Started Search Service instance on $SearchAppServer2"
}
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchAppServer2 -ErrorAction SilentlyContinue
#*** Step 3: Create Search Service Application and proxy****
Write-host "Creating Search Service Application..." -ForegroundColor Yellow
# Get the Search Service Application
$SearchServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceApplicationName -ErrorAction SilentlyContinue
# Create the Search Service Application, If it doesn't exist!
if(!$SearchServiceApplication)
{
$SearchServiceApplication = New-SPEnterpriseSearchServiceApplication -Name $SearchServiceApplicationName -ApplicationPool $SearchServiceAppPool -DatabaseServer $SearchDatabaseServer -DatabaseName $SearchServiceApplicationDatabase
write-host "Created New Search Service Application" -ForegroundColor Green
}
#Get the Search Service Application Proxy
$SearchServiceAppProxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceApplicationProxyName -ErrorAction SilentlyContinue
# Create the Proxy If it doesn't exist!
if(!$SearchServiceAppProxy)
{
$SearchServiceAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name $SearchServiceApplicationProxyName -SearchApplication $SearchServiceApplication
write-host "Created New Search Service Application Proxy" -ForegroundColor Green
}
#*** Step 4: Create New Search Topology and add components to it
Write-Host -ForegroundColor Yellow "Creating Search Service Topology..."
# Create New Search Topology
$SearchTopology = New-SPEnterpriseSearchTopology -SearchApplication $SearchServiceApplication
#Admin Component: App 01 and 02
New-SPEnterpriseSearchAdminComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1
New-SPEnterpriseSearchAdminComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2
#Content Processing: App 01 and 02
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2
#Analytics processing: App01 and 02
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2
#Crawl components: App 01 and 02
New-SPEnterpriseSearchCrawlComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1
New-SPEnterpriseSearchCrawlComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2
#Query processing: App 01 and 02
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2
#Create Index Components: App 01 and 02
#Two index partitions and replicas for each partition
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1 -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2 -RootDirectory $ReplicaIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance2 -RootDirectory $PrimaryIndexLocation -IndexPartition 1
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance1 -RootDirectory $ReplicaIndexLocation -IndexPartition 1
#Activate the Topology for Search Service
$SearchTopology.Activate() # Or Use: Set-SPEnterpriseSearchTopology -Identity $SearchTopology
#Remove all inactive topologies
$InactiveTopologies = Get-SPEnterpriseSearchTopology -SearchApplication $SearchServiceApplication | Where {$_.State -ne "Active"}
$InactiveTopologies | Remove-SPEnterpriseSearchTopology -Confirm:$false
Write-Host -ForegroundColor Green "Search Service Application has been created. Please start a Full Crawl!"
一切设置完毕后,您可以从 SharePoint 管理中心站点直观地看到搜索拓扑。
将 SharePoint 2016 搜索横向扩展至多个服务器:
上述脚本适用于具有两个“带搜索的应用程序”服务器的 SharePoint 场。如果您的 SharePoint 场有两个以上的应用程序服务器(例如四个)怎么办?
最佳实践:将查询和索引组件一起分配到同一服务器中,并将其余组件放置到其他搜索应用程序服务器上。另外,在脚本中,进行以下更改: Farm Topology 部分,包括另外两个服务器:Say,App03 和 App04
#Farm Server topology: App+Search: 4
$SearchAppServer1 = "Cre-SP16App01"
$SearchAppServer2 = "Cre-SP16App02"
$SearchAppServer3 = "Cre-SP16App03"
$SearchAppServer4 = "Cre-SP16App04"
在应用程序服务器 3 和 4 上启动服务实例:
#Search App Server 3
$SearchAppInstance3 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer3
if(-not($SearchAppInstance3.Status -eq "Online"))
{
Write-Host -ForegroundColor Yellow "Starting Search Service instance on $SearchAppServer3..." -NoNewline
$SearchAppInstance3 | Start-SPEnterpriseSearchServiceInstance
while ($SearchAppInstance3.Status -ne "Online")
{
Write-Host -ForegroundColor Green "." -NoNewline
Start-Sleep -Seconds 5
$SearchAppInstance3 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer3
}
Write-Host -ForegroundColor Green "Started Search Service instance on $SearchAppServer3"
}
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchAppServer3 -ErrorAction SilentlyContinue
#Search App Server 4
$SearchAppInstance4 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer4
if(-not($SearchAppInstance4.Status -eq "Online"))
{
Write-Host -ForegroundColor Yellow "Starting Search Service instance on $SearchAppServer4..." -NoNewline
$SearchAppInstance4 | Start-SPEnterpriseSearchServiceInstance
while ($SearchAppInstance4.Status -ne "Online")
{
Write-Host -ForegroundColor Green "." -NoNewline
Start-Sleep -Seconds 5
$SearchAppInstance4 = Get-SPEnterpriseSearchServiceInstance $SearchAppServer4
}
Write-Host -ForegroundColor Green "Started Search Service instance on $SearchAppServer4"
}
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchAppServer4 -ErrorAction SilentlyContinue
创建搜索拓扑时:将查询和索引角色分配给应用程序服务器 3 和 4
#Query processing: App 03 and 04
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance3
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance4
#Create Index Components: App 03 and 04
#Two index partitions and replicas for each partition
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance3 -RootDirectory $PrimaryIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance4 -RootDirectory $ReplicaIndexLocation -IndexPartition 0
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance4 -RootDirectory $PrimaryIndexLocation -IndexPartition 1
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchAppInstance3 -RootDirectory $ReplicaIndexLocation -IndexPartition 1
后续步骤:
- 创建内容源和时间表
- 创建搜索中心网站
- 为搜索服务应用程序配置抓取帐户和搜索中心 URL。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[影视] 黑道中人 Alto Knights(2025)剧情 犯罪 历史 电影
[古装剧] [七侠五义][全75集][WEB-MP4/76G][国语无字][1080P][焦恩俊经典]
[实用软件] 虚拟手机号 电话 验证码 注册
[电视剧] 安眠书店/你 第五季 You Season 5 (2025) 【全10集】
[电视剧] 棋士(2025) 4K 1080P【全22集】悬疑 犯罪 王宝强 陈明昊
[软件合集] 25年6月5日 精选软件22个
[软件合集] 25年6月4日 精选软件36个
[短剧] 2025年06月04日 精选+付费短剧推荐33部
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[实用软件] 虚拟手机号 电话 验证码 注册
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag