Sunday, July 22, 2012

Crawl Target Configuration using powershell


Hi,

Generally if user search any content in the site, due to network load balancing request may hit to any server.
That is why we can configure any one of the WFE so that any search requests can hit to crawl target server without disturbing other servers.

In SharePoint 2010 we can configure Crawl Target Server with the help of power shell.

I have run the below script on our application server to configure crawl target server.

//CrawlTargetScript.ps1
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{
Write-Host "Loading SharePoint Powershell Snap-in"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
[xml]$xmldata=Get-Content D:\Naga\CrawlTargetScript\CrawlTargetInputs.xml

$svc=[Microsoft.SharePoint.Administration.SPWebServiceInstance]::LocalContent
$svc.DisableLocalHttpThrottling
$svc.DisableLocalHttpThrottling=$true
$svc.Update()
$listOfUri = new-object System.Collections.Generic.List[System.Uri](1)
$zoneUrl = [Microsoft.SharePoint.Administration.SPUrlZone]'Default'

## This is your web application url(e.g. http://webappaurl, note crawl target configuration is
## per web application
$webAppUrl = $xmldata.CrawlTargetConfigurationInputs.WebApplicationUrl
$webApp = Get-SPWebApplication -Identity $webAppUrl
$webApp.SiteDataServers.Remove($zoneUrl) 

## This is your crawl target server
## You can use a server name e.g.  http://crawltargetname, or a URL e.g. ##http://webappurl
## you can also add multiple crawl target servers
## this assumes that the web application is provisioned on port 80, otherwise specify the port no
$URLOfDedicatedMachine = New-Object System.Uri($xmldata.CrawlTargetConfigurationInputs.DedicatedMachineUrl)

$listOfUri.Add($URLOfDedicatedMachine);
$webApp.SiteDataServers.Add($zoneUrl, $listOfUri);
$WebApp.Update()

##Verify the crawl target configuration, the following script will list the configured crawl target urls
$webAppUrl = $xmldata.CrawlTargetConfigurationInputs.WebApplicationUrl
$webApp = Get-SPWebApplication -Identity $webAppUrl
$webapp.SiteDataServers | fl

write-host $xmldata.CrawlTargetConfigurationInputs.DedicatedMachineName has been configured as crawl target server successfully -ForegroundColor Green

// CrawlTargetInputs.xml
<?xml version="1.0" encoding="utf-8" ?>
<CrawlTargetConfigurationInputs>
  <WebApplicationUrl>https://webappurl</WebApplicationUrl>
  <DedicatedMachineName>crawltargetservername</DedicatedMachineName>
  <DedicatedMachineUrl>http:// crawltargetservername</DedicatedMachineUrl>
</CrawlTargetConfigurationInputs>

Now after running the script, our challenge is to find out if requests is going to crawl target server or not.
For that I followed the below steps to get confirmation.

Step 1) In the central admin page, Start the crawlers 

Step 2) Verify the Crawl target servers logs/ CPU etc

·         You  will see CPU jump up in the crawl target servers
·         Wait for the crawling to complete and Check the IIS Logs (i.e. C:\inetpub\logs\LogFiles\W3SVC<SiteId>\) – in all WFE’s you will see requests coming in from the SEARCH(MS+Search) server to crawl target server as below.
Even there is NetMon tool to confirm if search requests is going to crawl target or not i.e.
1)Created Filter where i provided destination server as crawl target server, after that searched text in other WFE and came to the tool to monitor.
I saw the requests coming in with source and destination IP as below


No comments:

Post a Comment