Introduction
You have deployed a new SharePoint Server 2013 farm. You now wish to provision the farm's Search Service Application and to do so via PowerShell so as to be able to define simple custom search database names. This posting shows you how. This posting assumes a five-server farm, including: one database server, one application server, two web front end servers and one Office Web Apps server. All servers are VMs hosted on Microsoft Hyper-V. And it assumes two service accounts will be used: a content access account and an account used to run the Admin and query services. The search topology that will be deployed will be the following:
SSL is not used to connect to the primary web application content source.
Procedure
SharePoint 2013 Deployment Series |
How to setup a database server alias |
How to configure cache |
How to deploy a search service application using PowerShell |
Procedure
- Remove Existing Search
- Remove the existing Search Service Application (if it exists):
- In Central Administration, navigate to Manage Service Applications.
- Select the row corresponding to the search service application.
- Select the SERVICE APPLICATIONS tab, and then click the Delete button.
- At the prompt, enable the option to remove all data as well.
- Check the Manage Service Applications page to verify that all three of these have been removed:
- Search Administration Web Service for Search Service
- Search Service
- Search Service Application Proxy
- Check SQL Server to verify that all the search content and associated transaction log databases have been removed.
- Remove Search Application Pools
- In the SharePoint Management Shell, execute Get-SPServiceApplicationPool.
- Verify that no search application pools are listed.
- If any are, remove them using Remove-SPServiceApplicationPool.
- Preparation
- Verify setup user administrator account (eg, spAdmin) is member of local Administrator group on all farm servers.
- Identify service accounts and passwords:
- Content Access service account
- Administration and query service account
- Map the Admin service account to diagnostic logging database as dbo.
- Identify the web front end server names
- WFE1
- WFE2
- Identify the drive on the servers where you want to store indexes. This drive must be the same on all farm servers hosting SharePoint.
- (eg) D:\SPIndex
- Verify that any application pools created for previous installations (if any) of the Search Service Application have been removed.
- (eg) Search Service AppPool
- Execution
- Instantiate Search Services
- Remote into the application server as the setup user administrator account.
- Open the SharePoint 2013 Management Shell as administrator.
- Download this script: Enterprise Search Deployment Script.
- Edit variable as appropriate to your farm.
- Run the script.
- After completion of the script, navigate to the Search Service Administration page and verify that the search service topology is similar to what is presented above.
- Verify that the default content access service account is set as the crawl account.
- Configure Content Sources
- In CA, navigate to Content Sources, and then click on Local SharePoint sites (it will be the only item in the list at present).
- Note the sources (URLs) present.
- Create individual content sources for each of these URLs so that they can be crawl scheduled individually. So, for example, configure the following entries:
- Local SharePoint sites: point it to your primary web application. If your farm has more than one web application supporting user websites, creating individual entries for each.
- My Sites Content: point this to your farm's My Site web application.
- User Profile Content: point this to the URL for crawling user profiles. It will have the form like: sps3://MySites.com (non-SSL).
- Configure crawl schedules for each content source as appropriate. Create full and incremental schedules.
- Configure Global Search Center
- Create a Search Center. Deploy this within the primary web application or in a new web application as appropriate to your needs. I recommend adding it to your existing primary web application.
- In CA, navigate to the Search Service Administration page, and then set the Global Search Center URL to the Search Center you have created for your web application.
- Configure SSL Content sources
- If your search service needs to use SSL to crawl certain content sources, you will need to configure the service to ignore SSL warnings.
- In CA, go to: General Application Settings > Search > Farm Search Administration.
- In the Farm-Level Search Settings group, look for Ignore SSL warnings.
- Click No.
- Enable Ignore SSL certificate name warnings.
- Click OK.
- Miscellaneous
- If you plan to perform farm backups through Central Administration or PowerShell, be sure to grant the Search service account read and write permissions to the backup folder. Otherwise, farm backups will fail on backup of the Search service configuration and data. This is new from 2010.
- Manage search components in SharePoint Server 2013
- SharePoint 2013 Unable to change topology when Generation controller is not active
- Manage the index component in SharePoint Server 2013
- Get-SPEnterpriseSearchStatus
- Manage the search topology in SharePoint Server 2013
- Remove-SPServiceApplicationPool
- Get-SPServiceApplicationPool
- Configure a service application by using a Windows PowerShell script (SharePoint Server 2010)
- Service application cmdlets in SharePoint 2013
- Deploy people search in SharePoint Server 2013
- SharePoint 2013: FatalError: Object Search Service failed in event OnBackup
- Enterprise Search Deployment Script
- Remove-SPServiceApplication
- Delete a service application in SharePoint 2013
- Farm topology: This procedure was executed on a five-server farm (including OWA and SQL), Windows Server 2012 VMs.
- Deleting the Search Service Application through Central Administration does not remove the application pools that were created for the Search Service Application. Thus, to completely remove all artifacts associated with the Search Service Application, and thus be able to start over from scratch, you must also manually remove those application pools that were created for it.
- Default Content Sources: After deploying the Search Service Application, you will need to configure content sources. Your farm content sources (aside from CA) will automatically have their URLs added to the Local SharePoint sites group - including My Sites. I recommend separating content sources, so as to be able to implement separate crawl schedules for them. Not all content sources require as frequent crawling as your primary web applications.
- User profile content: if you want to enable searches of user profiles, you will need to add the URL for this manually.
- Search Service Account access to backup folder: I don't know how or why, but in SharePoint 2013, the Search Service Account plays a role in the farm backup process when it comes to backup of Search. This was not the case in SharePoint 2010, where I only had to grant the farm and sql server service accounts this access. I discovered this new wrinkle while actually trying to perform a full farm backup for the first time and then troubleshooting and resolving its initial failure.
- Removing Search via PowerShell. First, get the Identity of the application. Then run the command to remove:
Get-SPServiceApplication | ?{$_.name -like "*Search*"}
If you don't use the "-RemoveData" switch parameter, the search databases and their associated transaction logs will remain; and then you'll see "A databases exception occurred..." error appear in the shell window when you try to execute New-SPEnterpriseSearchServiceApplication.
$spapp = Get-SPServiceApplication -identity [
Remove-SPServiceApplication $spapp -RemoveData