Use scripts to install Search Server 2008

Applies To: Microsoft Search Server 2008

 

Topic Last Modified: 2008-09-22

Using scripts to install Microsoft Search Server 2008 enables you to perform unattended installations of Search Server 2008, maintain consistency across installations, and position you for server recovery in the event of a system failure.

This article is based on the white paper written by Ben Curry, CISSP, Office SharePoint Server MVP. It is modified, with the author's permission, for publishing to Microsoft TechNet. The original white paper and accompanying scripts are available for download from the Mindsharp Web site.

Overview

This article describes how to create scripts that you can use to install and configure the basic functionality of Search Server 2008. For ease of creation, management, and portability, we will create three separate scripts. Each of these scripts will perform a different function in the installation.

Note

You could combine all the scripts into one master script. However, we have found that keeping them separate and calling them from a master script is the best practice.

This article describes how to change existing scripts available from http://www.mindsharp.com premium content area (free), or create new scripts that you can use to install Search Server 2008 in a farm environment. The basic process is as follows.

  1. Create a very simple configuration file that is named config.xml. This configuration file is used by setup.exe to determine what binaries have to be installed, the installation method, and product key information.

  2. Create three scripts.

    • bits.cmd   This script will install the binaries for the specific installation, and requires the configuration file config.xml.

    • farm-build.cmd   This script will build the initial configuration database, create and provision Central Administration, and start the required services in the farm.

    • farm-connect.cmd (optional)   If you will have multiple servers in the search farm you need this script to attach the additional servers to the previously created configuration database.

  3. Run the preceding scripts in the order they were created.

  4. Debug and fix any errors in the scripts — for example, typographical errors, user name and password errors, and server names.

    Continue testing the scripts until they complete without error.

    Important

    It is very important to get an error-free installation if you will be doing remote installations or using scripts for disaster recovery.

Before you begin

Before continuing to the script creation phase, you have to determine how the Search Server 2008 farm will be deployed. If you use a stand-alone installation, the installer will install Microsoft SQL Server 2005 Express Edition. Although this greatly simplifies installation, most administrators will not install with this method because you are limited to a single server. Instead, this article describes a Search Server 2008 installation that uses either SQL Server 2005 Standard Edition or SQL Server 2005 Enterprise Edition.

Note

These scripts have not been re-factored using variables because every farm installation is unique. You will have to edit the scripts to reflect the specific implementation. For reference, these scripts were designed for a computer that is running SQL Server named app1, and a computer that is running Search Server 2008 named app2. You will have to edit the server names, Active Directory domain, and user names as required.

Prerequisites and assumptions

Review the hardware and software requirements that are regularly updated at https://technet.microsoft.com/en-us/library/bb905370.aspx.

Because these scripts also need a basis for an Active Directory name, user names, password, and server names, we have used the following names that you will have to change for the deployment.

  • contoso.msft – Active Directory name

  • contoso\mossfarm - Farm Account (Central Admin App Pool Id)

  • contoso\mosscrawler - Search Crawler Account (default content access account for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0)

  • contoso\mossservice - Core Service Account

  • contoso\sspapid - Shared Services Host App Pool Identity

  • contoso\sspservice - SSP Services Account

  • contoso\portalapid - Search Portal App Pool Identity

The Farm Administrator account must be a member of the dbcreator and securityadmin fixed server roles in SQL Server. It must also be a member of the Administrators group on the local server during installation. All other permissions will be granted automatically during installation. You must log on as the Farm Administrator account for installation, or create another account to use as the installer account.

If you want additional service account isolation, you should change the script as needed. These scripts assume a common service account. If you want a single application pool and associated identity, you should change the script accordingly. These scripts create a separate application pool and associated identity for every Web application that is created.

The servers in the testing farm for the scripts are as follows.

  • App1 - Microsoft SQL Server 2005 Service Pack 2 (SP2) default install and part of the Active Directory contoso.msft domain.

  • App2 - Part of the contoso.msft Active Directory domain.

  • QueryN - Query servers that will use the farm-connect.cmd script. They should also be part of the Active Directory contoso.msft domain.

Modifying config.xml and installing the binaries

to start scripting a Search Server 2008 installation, you have to create a copy of the config.xml file that comes on the installation media. The config.xml file is used by setup.exe as instructions for the binaries installation. After you have modified a copy of this file, it will be used during setup and will affect what software is installed and how it is installed, automate entry of the product ID that is located on the installation media, and define if you will have a graphical representation of the installation process.

You can find several examples on the installation media under x86\Files\Setup<type> for 32-bit media, and x64\Files\Setup<type> for 64-bit media. If you are using the downloadable trial version of Search Server 2008, you have to first extract the contents by the running the following command at a command prompt:

searchservertrial.exe /extract:<drive>:\<folder>

where:

  • <drive> is the drive letter on which you want to extract the contents of the executable file.

  • <folder> is the name of the folder on which you want to extract the contents of the executable file.

In the <drive>:\<folder>\files\SetupFarmSilent directory, you will find a copy of config.xml. To completely automate the installation of Search Server 2008, you must edit this file. For script creation and testing, you should create a directory, such as c:\scripts, and copy the config.xml file to this location. We recommend that you do not use an XML editor, such as Microsoft Visual Studio, to edit this file. We recommend that you use notepad.exe so the formatting is not modified. The following is an example of the default config.xml file.

<Configuration>
<Package Id="sts">
<Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>
<Setting Id="REBOOT" Value="ReallySuppress"/>
<Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
</Package>

<Logging Type="verbose" Path="%temp%" Template="Search Server Setup(*).log"/>
<Display Level="none" CompletionNotice="no" />
<Setting Id="SERVERROLE" Value="APPLICATION"/>
<Setting Id="USINGUIINSTALLMODE" Value="0"/>
</Configuration>

Before you modify config.xml

Depending on which binaries and services that you have to install, you have two choices for the kind of installation to perform. The options are as follows:

  • SINGLESERVER   The SINGLESERVER option, set by modifying the 'SERVERROLE' parameter, will install Microsoft SQL Server 2005 Express Edition, together with the Search Server 2008 binaries. This article does not include instructions on how to use this option.

  • APPLICATION   The APPLICATION option will install all binaries required to support Search Server 2008, except SQL Server. You must already have an instance of SQL Server 2005 Standard or Enterprise edition installed that can be accessed by the server that will host Search Server 2008. This is the installation option that is used in this article.

Modifying config.xml

The "Display Level" setting should be set to "none" because setting it to "Basic" will keep the installation script from using custom parameters. You should also leave the setting "USINGUIINSTALLMODE" set to "0".

Next, you have to insert an entry for the product ID (PIDKEY Value) that is found on the installation media. The following example shows these settings.

<Configuration>
<Package Id="sts">
<Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>
<Setting Id="REBOOT" Value="ReallySuppress"/>
<Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
</Package>
<Logging Type="verbose" Path="%temp%" Template="Search Server Setup(*).log"/>
<Display Level="none" CompletionNotice="no" AcceptEULA="Yes" /> 
<PIDKEY Value="D2KBC-9JQ6T-4P6C2-F7BFF-BB96D" /> 
<Setting Id="SERVERROLE" Value="APPLICATION"/>
<Setting Id="USINGUIINSTALLMODE" Value="0"/>
</Configuration>

Note

The previous example uses a key for the trial version of Search Server 2008. You have to provide the key for a fully functional version of the product.

You will want robust logging if installing remotely. Therefore, make sure that you define a logging location that you can access from the remote location. The default logging location is in %temp%. This location is for the binary installs only, not for farm provisioning. Farm provisioning logs are in the 12 \Logs directory.

Create the bits.cmd script

The bits.cmd script is used to install the binaries. It uses setup.exe and references the config.xml file that you modified. Create this script using the following example.

:: Installs binaries
:: Requires .NET2, .NET3, and IIS. As an alternative run the prerequisite installer.
@echo off
c:\searchiso\setup.exe /config c:\scripts\config.xml

At this point, you have created the first script that installed the binaries on the first server in the farm. You still have to create the server farm (server farm = configuration database) and create the required Web applications.

Create the farm-build.cmd script

After the binaries are installed, you must continue provisioning the Search Server 2008 farm. Remember, a server "farm" = configuration database. A complete server farm typically has several servers. However, for the purposes of this article we are installing Search Server 2008 on one computer. Doing so will not prevent you from scaling out this farm in the future. We will not discuss how to build a multi-server farm in this article. For more information, see Plan for redundancy (Search Server 2008). Instead, we will focus on how to use psconfig.exe and stsadm.exe commands to build a script for provisioning a single server farm.

Note

There is a short sample script at the end of this article that shows how to connect additional servers to the farm.

After you installed the binaries with bits.cmd, you have access to psconfig.exe in the 12 hive, specifically, %COMMONPROGRAMFILES %\ Microsoft Shared\web server extensions\12\BIN\psconfig.exe. To create the server farm, define the instance of SQL Server and database name, as follows:

psconfig.exe -cmd configdb -create -server app1 -database ContosoSearch_SharePoint_ConfigDB -user contoso\mossfarm -password P@ssw0rd -admincontentdatabase Central_Admin_Content

The previous command creates a server farm on an instance of SQL Server named app1, with a configuration database named ContosoSearch_SharePoint_ConfigDB. It also created a content database and embedded site collection for Central Administration. This occurs when you are using the graphical user interface, you merely do not see it.

Note

We are using the contoso\mossfarm account as the installer account. This account only needs administrative permission during installation, and you can remove its local administrator permissions after installation is completed.

The next step is to provision Central Administration on at least one server in the farm. You have already created the Web application when you created the farm. However, you must still provision an Internet Information Services (IIS) server to render the content. For this example, we will install on app2, the first server in the farm by using the following command:

psconfig.exe -cmd adminvs -provision -port 12345 -windowsauthprovider onlyusentlm

After provisioning Central Administration, you must install all services associated with the installed server role. This is performed by the following command:

psconfig.exe -cmd services install

The next, and very important step, is setting the security on registry settings and the file system. If you do not do so, the installation will complete correctly. However, you will have miscellaneous errors.

psconfig.exe -cmd secureresources

After you have created the farm, provisioned Central Administration, installed services, and secured resources, you have to start required services, most notably, the search services. First, we start Search Server 2008 by using stsadm.exe, which is located in the 12 hive \Bin directory. You should define parameters, such as performance level and index location.

Note

Although the following script example shows c:\ as the index location, it is a best practice to put the index files on a volume other than the system drive.

stsadm.exe -o osearch -action start -role query -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd -propagationlocation c:\indexes

After starting the Search service, start Windows SharePoint Services 3.0 search by using the following command:

stsadm.exe -o spsearch -action start -farmserviceaccount contoso\mossservice -farmservicepassword P@ssw0rd -farmcontentaccessaccount contoso\mosscrawler -farmcontentaccesspassword P@ssw0rd -databaseserver app1 -databasename Contoso_WSS_App2_Search

At this point, verify that all the features have been installed correctly by using the following command:

psconfig.exe -cmd installfeatures

Now you must create a Web application to host the Shared Services Provider for Search Server 2008.

stsadm.exe -o extendvs -url http://ssp.contoso.msft -exclusivelyusentlm -databaseserver app1 -databasename Contoso_WSS_Content_SSP -donotcreatesite -description "Search Admin Host" -sethostheader -apidname SSP -apidtype configurableid -apidlogin contoso\sspapid -apidpwd P@ssw0rd

After you have created a Web application to host the Shared Services Administration Web site, you have to create a Shared Services Provider to manage Search, as shown in the following example:

stsadm.exe" -o createssp -title "Contoso Search" -url http://ssp.contoso.msft -ssplogin contoso\sspservice -indexserver app2 -indexlocation c:\indexes -ssppassword P@ssw0rd -sspdatabaseserver app1 -sspdatabasename Contoso_SSP_Config -searchdatabaseserver app1 -searchdatabasename Contoso_SSP_Search -ssl no

The final bit of code that is required is used to create the Search Provider Web application. This should be its own Web application to host the Search Center. The following example creates a Web application that has the URL http://search.contoso.msft.

stsadm.exe -o extendvs -url http://search.contoso.msft -ownerlogin "contoso\administrator" -owneremail "administrator@contoso.msft" -exclusivelyusentlm -ownername "Administrator" -databaseserver app1 -databasename Contoso_WSS_Content_Search_Center -sitetemplate srchcenterlite#1 -description "Contoso Search Center" -sethostheader -apidname PortalAppPool -apidtype configurableid -apidlogin contoso\portalapid -apidpwd P@ssw0rd

Some explanation is warranted on the previous command. First, we are using the extendvs parameter to created a new Web application (used to be virtual server, hence the vs in the command name). Next, we define the owner, contoso/administrator in our example. If you are using Kerberos authentication, refer to the stsadm.exe reference for more information about verbiage. We must also define the instance of SQL Server and database name. We used app1 as the name of the instance of SQL Server and Contoso_WSS_Content_Search_Center as the database name.

We must create a site collection in the root managed path. In our example, the URL would be http://search.contoso.msft/, with '/' hosting the Search Center. The correct site collection template is srchcenterlite#1. Finally, we configure an application pool named PortalAppPool and an identity using contoso/portalapid. The portal application pool identity should have already been created in the Active Directory directory service.

When you have finished adding all the necessary commands, save this file as farm-build.cmd.

The following code illustrates a complete farm-build.cmd script.

:: @Echo off
:: leaving echo ON for demonstration purposes
:: Farm_Build.cmd
:: Provisions configuration database and Central Administration
:: Creates http://ssp.contoso.msft, then creates SSP Admin in that Web app
:: Installer account requires DB Creator and Security Administrator on SQL Server
:: Pauses are for command verification and demonstration. you can remove if you want.
:: App1 is SQL Server
:: App2 is Search Server

:: Calling bits.cmd to install binaries
@call bits.cmd
Echo Ready to connect server to farm
pause
::Create Index Location on Index Server
@Echo Creating Index Location
mkdir \\app2\c$\indexes
@Echo Creating Farm
:: Creating Farm via populating the ConfigDB. Set SQL Servername, configDB name, Central Admin ContentDB, and Farm Account.
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd configdb -create -server app1 -database ContosoSearch_SharePoint_ConfigDB -user contoso\mossfarm -password P@ssw0rd -admincontentdatabase Central_Admin_Content
@Echo Provision Central Admin
::  Provision Central Admin Application on this server. Uses configDB and ContentDB above. Set port number to suit your requirements.
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd adminvs -provision -port 12345 -windowsauthprovider onlyusentlm
@Echo Install all Services
::  Install all services on the server
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd services install
@Echo Securing File System and Registry Keys
:: Set Security on File System and Registry Keys
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd secureresources
@Echo Starting MOSS Search
::  Start SharePoint Server Search Service with IndexQuery.Verify database and services names. Change role to Index if you are scaling out Search Server in the farm.Subsequent servers would only be Query.
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o osearch -action start -role IndexQuery -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd
@Echo Starting WSS Search
::  Start WSS Search. Verify database and service names.
"c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe" -o spsearch -action start -farmserviceaccount contoso\mossservice -farmservicepassword P@ssw0rd -farmcontentaccessaccount contoso\mosscrawler -farmcontentaccesspassword P@ssw0rd -databaseserver app1 -databasename Contoso_WSS_App2_Search
@Echo Installing all Features
::  Install all features on machine
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd installfeatures
@Echo Creating SSP Web
::  Create SSP Web application. Verify database and apid names. (APID = Application Pool Identity)
"c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe" -o extendvs -url http://ssp.contoso.msft -exclusivelyusentlm -databaseserver app1 -databasename Contoso_WSS_Content_SSP -donotcreatesite -description "SSP Admin Host" -sethostheader -apidname SSP -apidtype configurableid -apidlogin contoso\sspapid -apidpwd P@ssw0rd
::  We must reset IIS before building the SSP. If you are local on the box, you can check all services are created before creating SSP.
iisreset
@Echo Creating SSP
::  Create Search SSP. Verify all names and URLs.
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o createssp -title "Contoso Search" -url http://ssp.contoso.msft -ssplogin contoso\sspservice -indexserver app2 -indexlocation c:\indexes -ssppassword P@ssw0rd -sspdatabaseserver app1 -sspdatabasename Contoso_SSP_Config -searchdatabaseserver app1 -searchdatabasename Contoso_SSP_Search -ssl no
@Echo Creating Search Center
::  Creating Search Center. Change the URL if you will have a different URL than 'search'.
"c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe" -o extendvs -url http://search.contoso.msft -ownerlogin "contoso\administrator" -owneremail "administrator@contoso.msft" -exclusivelyusentlm -ownername "Administrator" -databaseserver app1 -databasename Contoso_WSS_Content_Search_Center -sitetemplate srchcenterlite#1 -description "Contoso Search Center" -sethostheader -apidname PortalAppPool -apidtype configurableid -apidlogin contoso\portalapid -apidpwd P@ssw0rd
:: If you receive an error during build, check that you have correctly modified the server :: names, database names, domain name, account names, and passwords for your specific 
:: implementation.

Create the farm-connect.cmd script

After you have finished configuring the first server in the farm, you have to connect from every other server that you add to the farm. This script, farm-connect.cmd, is executed on servers other than the first server in the farm. The following series of commands are used to build this script.

Connect to an existing farm by specifying the instance of SQL Server and configuration database, as shown in the following example:

psconfig.exe -cmd configdb -connect -server app1 -database ContosoSearch_SharePoint_ConfigDB -user contoso\mossfarm -password P@ssw0rd

Now you have to install services, features, secure resources, and start services as you did before. The following example starts all services, features, and starts/configures the query role.

Note

You must first start the search service on subsequent servers and then define the Search parameters.

psconfig.exe -cmd services install psconfig.exe -cmd installfeatures psconfig.exe -cmd secureresources

stsadm.exe -o osearch -action start -role query -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd

stsadm.exe-o osearch -action start -role query -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd -propagationlocation c:\indexes

Important

If you will have more than one query server in the farm, you must verify that the index server does not also host the query role.

The following code illustrates a complete farm-connect.cmd script.

:: Farm_Connect.cmd
:: Use on all WFE (query) Servers in Farm
:: Verify query role is not turned on for Index Server
:: @Echo On (off for demo)
:: Calling bits.cmd to install binaries
@call bits.cmd
Echo Ready to connect server to farm
pause
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd configdb -connect -server app1 -database ContosoSearch_SharePoint_ConfigDB -user contoso\mossfarm -password P@ssw0rd
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd services install
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd installfeatures
:: Setting Security on Registry and File System
@Echo Ready to Set Security on File System and Registry
"c:\program files\common files\microsoft shared\web server extensions\12\bin\psconfig.exe" -cmd secureresources
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o osearch -action start -role query -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o osearch -action start -role query -farmcontactemail administrator@contoso.msft -farmperformancelevel maximum -farmserviceaccount "contoso\mossservice" -farmservicepassword P@ssw0rd -propagationlocation c:\indexes
iisreset / noforce

Conclusion

Always test and debug farm installation scripts against a test server farm before you use them in a production environment. Scripts rarely work correctly the first time. It is an iterative process.

Fully tested and functional scripts are especially important if their intended use is for disaster recovery. You only get one try. Don’t depend on guesses as to where the script went wrong. As always, use these examples at your own risk. Test, test, and then test some more!