สร้างแอปพลิเคชันบริการค้นหา SharePoint 2013 โดยใช้ PowerShell
แม้ว่าเราจะสามารถสร้างแอปพลิเคชันบริการการค้นหา SharePoint 2013 จากการดูแลจากศูนย์กลางได้ แต่ฉันชอบสร้างผ่าน PowerShell เนื่องจากทำให้สามารถกำจัด GUID ในชื่อฐานข้อมูลบริการการค้นหาได้ นอกจากนี้ จากการดูแลจากศูนย์กลางของ SharePoint 2013 ไม่สามารถปรับเปลี่ยนโทโพโลยีการค้นหาได้! ดังนั้น PowerShell จึงเป็นวิธีที่เหมาะที่สุดในการสร้าง/กำหนดค่าการค้นหาใน SharePoint 2013
การสร้างแอปพลิเคชันบริการค้นหาใน PowerShell ประกอบด้วย 7 ขั้นตอนเหล่านี้:
- สร้างกลุ่มแอปพลิเคชันสำหรับแอปพลิเคชันบริการการค้นหา
- เริ่มต้นอินสแตนซ์บริการการค้นหาบนเซิร์ฟเวอร์
- สร้างแอปพลิเคชันบริการการค้นหา
- สร้างพร็อกซีแอปพลิเคชันบริการการค้นหา
- สร้างโทโพโลยีบริการการค้นหาใหม่
- สร้างองค์ประกอบทั้งหกของการค้นหาและกำหนดให้กับโทโพโลยีการค้นหา
- เปิดใช้งานโทโพโลยีการค้นหา
สคริปต์ PowerShell เพื่อสร้างแอปพลิเคชันบริการค้นหาสำหรับ SharePoint 2013:
นี่คือสคริปต์ PowerShell เพื่อสร้างแอปพลิเคชันบริการการค้นหาใน SharePoint 2013
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Specify the Settings for the Search Service Application
$ServerName = (Get-ChildItem env:computername).value
$IndexLocation = "D:\Search Index"
$SearchServiceApplicationName = "Search Service Application"
$SearchServiceApplicationProxyName = "Search Service Application Proxy"
$SearchDatabaseServer = "G1SP2013"
$SearchServiceApplicationDatabase = "SP2013_Search_Service"
$SearchAppPoolName = "Search Service Application pool"
$SearchAppPoolAccount = Get-SPManagedAccount "Crescent\SP13_Search"
#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
}
#*** Step 1: Create Application Pool for Search Service Application ****
#Get the existing Application Pool
$SearchServiceAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue
#If Application pool Doesn't exists, Create it
if (!$SearchServiceAppPool)
{
$SearchServiceAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccount
write-host "Created New Application Pool" -ForegroundColor Green
}
#*** Step 2: Start Search Service Instances ***
Start-SPEnterpriseSearchServiceInstance $ServerName -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $ServerName -ErrorAction SilentlyContinue
#*** Step 3: Create Search Service Application ****
# Get the Search Service Application
$SearchServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceApplicationName -ErrorAction SilentlyContinue
# Create the Search Service Application, If it doesn't exists!
if(!$SearchServiceApplication)
{
$SearchServiceApplication = New-SPEnterpriseSearchServiceApplication -Name $SearchServiceApplicationName -ApplicationPool $SearchServiceAppPool -DatabaseServer $SearchDatabaseServer -DatabaseName $SearchServiceApplicationDatabase
write-host "Created New Search Service Application" -ForegroundColor Green
}
#*** Step 4: Create Search Service Application Proxy ****
#Get the Search Service Application Proxy
$SearchServiceAppProxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceApplicationProxyName -ErrorAction SilentlyContinue
# Create the Proxy, If it doesn't exists!
if(!$SearchServiceAppProxy)
{
$SearchServiceAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name $SearchServiceApplicationProxyName -SearchApplication $SearchServiceApplication
write-host "Created New Search Service Application Proxy" -ForegroundColor Green
}
#*** Step 5: Create New Search Topology
$SearchServiceInstance = Get-SPEnterpriseSearchServiceInstance -Local
#To Get Search Service Instance on Other Servers: use - $SearchServiceAppSrv1 = Get-SPEnterpriseSearchServiceInstance -Identity "<Server Name>"
# Create New Search Topology
$SearchTopology = New-SPEnterpriseSearchTopology -SearchApplication $SearchServiceApplication
#*** Step 6: Create Components of Search
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance
New-SPEnterpriseSearchCrawlComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance
New-SPEnterpriseSearchAdminComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance
#Prepare Index Location
Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue
MKDIR -Path $IndexLocation -Force
#Create Index and Query Components
New-SPEnterpriseSearchIndexComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance -RootDirectory $IndexLocation
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $SearchTopology -SearchServiceInstance $SearchServiceInstance
#*** Step 7: Activate the Toplogy for Search Service ***
$SearchTopology.Activate() # Or Use: Set-SPEnterpriseSearchTopology -Identity $SearchTopology
นี่คือโทโพโลยีของศูนย์การค้นหาที่สร้างขึ้น:
ดังที่คุณเห็นในหน้าจอด้านบน แอปพลิเคชันบริการค้นหาการจัดเตรียมจะสร้างฐานข้อมูล 4 รายการ: ฉันตั้งชื่อไว้ดังนี้:
- SP2013_Search_Service - ฐานข้อมูล Search Service Administration เก็บการกำหนดค่าและโทโพโลยี (อาจดีกว่า: SP2013_Search_Service_AdminDB”)
- SP2013_Search_Service_AnalyticReporting- เก็บผลลัพธ์ของรายงานการวิเคราะห์การใช้งาน
- SP2013_Search_Service_CrawlStore - ฐานข้อมูลการตระเวนประกอบด้วยการติดตามโดยละเอียดและข้อมูลประวัติเกี่ยวกับรายการที่ตระเวน
- SP2013_Search_Service_LinksStore - เชื่อมโยงฐานข้อมูล จัดเก็บข้อมูลที่แยกโดยส่วนประกอบการประมวลผลเนื้อหา & ข้อมูลการคลิกผ่านของรายการที่ค้นหา
สคริปต์ด้านบนสร้างแอปพลิเคชันบริการการค้นหาใน SharePoint 2013 โดยใช้ PowerShell สำหรับสภาพแวดล้อมแบบสแตนด์อโลน หากคุณกำลังมองหาการสร้างแอปพลิเคชันบริการการค้นหาของ SharePoint ในฟาร์มแบบหลายเซิร์ฟเวอร์ โปรดดูที่: สร้างและกำหนดค่าแอปพลิเคชันบริการการค้นหาในฟาร์มแบบหลายเซิร์ฟเวอร์ของ SharePoint 2016
