Cet article présente l'installation silencieuse d'une instance SQL Server 2008 R2. Le contexte de la version cluster n'est pas abordé.
Rien de réellement nouveau dans la méthode - l'opération consiste simplement à donner en argument au binaire setup.exe un fichier de configuration contenant les options souhaitées.
Principale évolution avec SQL Server 2008 R2 : la surcharge de toutes les valeurs stockées dans le fichier de configuration est désormais possible par passage de paramètres. Chaque déploiement peut dès lors être personnalisé et d'un point de vue sécurité, cette nouveauté évite de stocker des mots de passe sensibles dans le fichier de configuration.
Hommage est rendu dans cette note à Majed Bouabda, auteur du shell original utilisé ici, réalisé dans le cadre d'une installation SQL 2005.
Allons à l'essentiel, l'installation est réalisée avec la ligne de commande suivante :
start /wait SQL_2008_ENT_R2\setup.exe /configurationfile=install.ini _
/q _
/IACCEPTSQLSERVERLICENSETERMS _
/SAPWD="motdepasse" _
/SQLSVCPASSWORD="motdepasse" _
/AGTSVCPASSWORD="motdepasse"
avec un fichier install.ini ressemblant à ceci :
type install.ini
;SQLSERVER2008 Configuration File [SQLSERVER2008] ; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance. INSTANCEID="MSSQLSERVER" ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter. ACTION="Install" ; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components. FEATURES=SQLENGINE,FULLTEXT,CONN,BC,SSMS,ADV_SSMS ; Specifies a Windows collation or an SQL collation to use for the Database Engine. SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" ; Startup type for the SQL Server service. SQLSVCSTARTUPTYPE="Automatic" ; Default directory for the Database Engine backup files. SQLBACKUPDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Backup" ; Default directory for the Database Engine user databases. SQLUSERDBDIR="E:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ; Default directory for the Database Engine user database logs. SQLUSERDBLOGDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ; Directory for Database Engine TempDB files. SQLTEMPDBDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ...
Le fichier de configuration est un format INI classique de type TAG=VALEUR.
Toutes les entrées spécifiées ici peuvent être passées en paramètre au setup.exe. La ligne de commande surcharge le fichier ini. Cela signifie que si une valeur est définie à la fois dans l'INI et passée en paramètre, c'est la valeur passée en paramètre qui est prise en compte.
Le binaire setup.exe peut être utilisé aussi bien pour une installation que pour une mise à jour ou même une désinstallation. Ici est traitée uniquement le mode installation d'une instance simple.
Le tableau ci-dessous précise quelques paramètres importants de la ligne de commande et/ou du fichier de configuration. La liste complète est disponible en ligne (cf liens)
| Parametre | Valeurs | Obligatoire |
|---|---|---|
| /ACTION | INSTALL | oui |
| /IACCEPT ... SQLSERVERLICENSETERMS |
Obligatoire en paramètre de la ligne de commande si l'option /Q ou /QS est spécifiée | oui |
| FEATURES | Séparées par une virgule, indique les composants à installer
SQLENGINE : Database REPLICATION : composants Repli FULLTEXT : composants Fulltext SQL : SQLENGINE+REPLICATION+FULLTEXT AS : Analysis Services RS : Reporting Services IS : integration Services BC : Composants Compatibilité BOL : Aide en ligne BIDS : Business Intelligence Development Studio. CONN : Connectivité SSMS : Management Studio pour SQL ADV_SSMS : Management Studio pour SQL, RS, AS, IS + Profiler + Tuning Advisor + Utility Mgt SDK : Software Developer Kit TOOLS : BC+BOL+BIDS+CONN+ADV_SSMS+SDK |
oui |
| /*SVCACCOUNT | Nom du compte de service démarrant le produit (Service Account)
Chaque service est identifié par le code suivant : AGT = Agent, AS = Analysis Services, SQL = SQL Server, IS = Integration Services, RS = Reporting Services. ( ex : /SQLSVCACCOUNT ) |
|
| /*SVCPASSWORD | Mot de passe associé au service correspondant.
AGT = Agent, AS = Analysis Services , SQL = SQL Server, IS = Integration Services, RS = Reporting Services. ( ex : /SQLSVCPASSWORD ) |
|
| /*SVCSTARTUPTYPE | Mode de démarrage du service. Automatic, Manual, Disabled
AGT = Agent, AS = Analysis Services , SQL = SQL Server, IS = Integration Services, RS = Reporting Services. ( ex : /SQLSVCSTARTUPTYPE ) |
|
| /SECURITYMODE | SQL
Si le paramètre est omis, l'instance est en mode d'authentification Windows uniquement. |
optionnel |
| /SAPWD | Mot de passe du compte SA
Le paramètre est obligatoire si /SECURITYMODE=SQL |
oui |
Une fois définis les paramètres d'installation standard enregistrés dans un fichier de configuration, on peut développer un script simple permettant d'exécuter une installation personnalisée.
Un fichier de configuration modèle peut être obtenu dans le répertoire de log d'une installation déjà réalisée en mode graphique.
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\AAAAMMJJ_HHMMSS\ConfigurationFile.ini
Ce script va non seulement exécuter l'installation automatisée de l'instance, mais également procéder à l'installation de procédures d'administration et/ou configurer l'instance en fonction du serveur.
Le DOS shell suivant réalise ces opérations en quelques questions.
@ECHO OFF
:: ###################################################################################
:: # @(#) Fichier : install.cmd
:: # @(#) Date : 04/12/2007
:: # @(#) Auteur : Majed Bouabda pour SQL 2005
:: # @(#) Objet : Installation automatisee SQL Server
:: # @(#) Usage : install.cmd
:: # @(#) Plusieurs questions successives vont être posées pour personnaliser:
:: # @(#) - les volumes de data, log et backup
:: # @(#) - la collation
:: # @(#) - les mots de passe
:: # @(#) - l'instance
:: # @(#) Il prend en charge :
:: # @(#) - La creation des arborescences DATA, TLOG et BACKUP
:: # @(#) - L'iInstallation de SQL Server 2008
:: # @(#) - La config moteur SQL Server (switchs/procs/jobs/alertes)
:: # @(#) - La config des services en stand-alone
:: # @(#) Exemples: install.cmd
:: # ---------------------------------------------------------------------------------
:: # @(#) Modif : FA - 01/11/2010 - installation sql 2008
:: ###################################################################################
:: ###################################################################################
:: Environnement
SET SQL_INSTANCE=MSSQLSERVER
SET SQL_DISK_DATA=E:
SET SQL_DISK_TLOG=D:
SET SQL_DISK_BACK=D:
SET SQL_COLLATION=SQL_Latin1_General_CP1_CI_AS
SET SQL_ENVT=TBD
SET SQL_COMMENT=TBD
SET SQL_SVC_PWD=
SET SQL_SA_PWD=
SET VALUE=
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=CHECK_USERNAME
@ECHO %SQL_ETAPE%
if /I "%USERNAME%" NEQ "zzsqlserver" GOTO SQL_ERREUR
@ECHO.
:: ###################################################################################
:: Parametres
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=PARAMETRES_SQL
@ECHO %SQL_ETAPE%
::
@ECHO Instance (Press ENTER for %SQL_INSTANCE%) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_INSTANCE=%VALUE%)
@ECHO.
::
@ECHO Disk Data (Press ENTER for %SQL_DISK_DATA%) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_DISK_DATA=%VALUE%)
@ECHO.
::
@ECHO Disk Log (Press ENTER for %SQL_DISK_TLOG%) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_DISK_TLOG=%VALUE%)
@ECHO.
::
@ECHO Disk Backup (Press ENTER for %SQL_DISK_BACK%) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_DISK_BACK=%VALUE%)
@ECHO.
::
@ECHO Collation (Press ENTER for "%SQL_COLLATION%") ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_COLLATION=%VALUE%)
@ECHO.
::
@ECHO Plateform (DEV/TEST/UAT/PROD/DR) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_ENVT=%VALUE%)
@ECHO.
::
@ECHO Comment (mutualise/dedie/sql2008/...) ?
SET /P VALUE=
if NOT /I "%VALUE%"=="" (SET SQL_COMMENT=%VALUE%)
@ECHO.
::
@ECHO Password SA ?
SET /P VALUE=
if /I "%VALUE%" == "" GOTO SQL_ERREUR
SET SQL_SA_PWD=%VALUE%
@ECHO.
::
@ECHO Password SQL Service ?
SET /P VALUE=
if /I "%VALUE%" == "" GOTO SQL_ERREUR
SET SQL_SVC_PWD=%VALUE%
@ECHO.
:: ###################################################################################
:: Controles
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=CONTROL
@ECHO - Parametres retenus pour l'installation:
@ECHO.
@ECHO --------------------------------------------
@ECHO SQL_MACHINE : %COMPUTERNAME%
@ECHO SQL_INSTANCE : %SQL_INSTANCE%
@ECHO SQL_DISK_BACK : %SQL_DISK_BACK%
@ECHO SQL_DISK_TLOG : %SQL_DISK_TLOG%
@ECHO SQL_DISK_DATA : %SQL_DISK_DATA%
@ECHO SQL_COLLATION : %SQL_COLLATION%
@ECHO SQL_ENVT : %SQL_ENVT%
@ECHO SQL_COMMENT : %SQL_COMMENT%
@ECHO --------------------------------------------
@ECHO SQL_SVC_PWD : %SQL_SVC_PWD%
@ECHO SQL_SA_PWD : %SQL_SA_PWD%
@ECHO --------------------------------------------
@ECHO.
@ECHO - Confirmez l'installation par "OK":
SET /P VALUE=
if /I "%VALUE%" NEQ "OK" GOTO SQL_FIN
@ECHO.
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=CHECK_SQL_SVC_ACCOUNT
@ECHO %SQL_ETAPE%
net use \\127.0.0.1\ipc$ /D 1>NUL 2>NUL
net use \\127.0.0.1\ipc$ /user:<domain>\<compte> %SQL_SVC_PWD% 1>NUL 2>NUL
IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
@ECHO.
:: ###################################################################################
:: Preparation
:: -----------------------------------------------------------------------------------
::SET SQL_ETAPE=LOCKMEMORYPAGES
::@ECHO %SQL_ETAPE%
::IF EXIST secedit.sdb DEL /F /Q secedit.sdb
::secedit /configure /DB secedit.sdb /CFG LockPagesInMemory.inf 1>NUL
::IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
::GPUPDATE /force 1>NUL
::IF EXIST secedit.sdb DEL /F /Q secedit.sdb
::@ECHO.
:: ###################################################################################
:: Installation
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=INSTALL_SQLSERVER
@ECHO %SQL_ETAPE%
start /wait SQL_2008_ENT_R2\setup.exe /configurationfile=install.ini _
/q _
/IACCEPTSQLSERVERLICENSETERMS _
/SAPWD="%SQL_SA_PWD%" _
/SQLSVCPASSWORD="%SQL_SVC_PWD%" _
/AGTSVCPASSWORD="%SQL_SVC_PWD%" _
/SQLCOLLATION="%SQL_COLLATION%"
IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
@ECHO.
:: ###################################################################################
:: Post-Installation
SET PATH=%PATH%;%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=CONFIG_MOTEUR_SQL
@ECHO %SQL_ETAPE%
if /I "%SQL_INSTANCE%" == "MSSQLSERVER" (sqlcmd.exe -S. -E -dMaster -i.\SQLconfig.sql) _
ELSE (sqlcmd.exe -S.\%SQL_INSTANCE% -E -dMaster -i.\SQLconfig.sql 1>NUL)
IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
@ECHO.
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=CREATE_PROC_DBA
@ECHO %SQL_ETAPE%
if /I "%SQL_INSTANCE%" == "MSSQLSERVER" (FOR %%a in (\\Par1db1-01\e$\MSSQL\dba\*.sql) _
DO sqlcmd.exe -S. -E -dMaster -i%%a )
IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
@ECHO.
:: -----------------------------------------------------------------------------------
SET SQL_ETAPE=SQL_REGISTER
@ECHO %SQL_ETAPE%
sqlcmd.exe -Spar1db1-01 -E -ddba_monitor -Q"insert into dbo.sql_instal...
IF NOT ERRORLEVEL 0 GOTO SQL_ERREUR
@ECHO.
:: ###################################################################################
:: Fin
GOTO SQL_FIN
::==================================================
:SQL_ERREUR
::==================================================
@ECHO !!! ERREUR : %SQL_ETAPE% !!!
@ECHO !!! ATTENTION: Installation incomplete ou annulee !!!
@ECHO.
::==================================================
:SQL_FIN
::==================================================
@ECHO - Fin
@ECHO Installation terminée
@ECHO.
pause
type install.ini
;SQLSERVER2008 Configuration File [SQLSERVER2008] ; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance. INSTANCEID="MSSQLSERVER" ; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter. ACTION="Install" ; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components. FEATURES=SQLENGINE,FULLTEXT,CONN,BC,SSMS,ADV_SSMS ; Displays the command line parameters usage HELP="False" ; Specifies that the detailed Setup log should be piped to the console. INDICATEPROGRESS="True" ; Setup will not display any user interface. QUIET="False" ; Setup will display progress only without any user interaction. QUIETSIMPLE="False" ; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system. X86="False" ; Detailed help for command line argument ENU has not been defined yet. ENU="True" ; Parameter that controls the user interface behavior. Valid values are Normal for the full UI, and AutoAdvance for a simplied UI. UIMODE="AutoAdvance" ; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature. ERRORREPORTING="False" ; Specify the root installation directory for native shared components. INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server" ; Specify the root installation directory for the WOW64 shared components. INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server" ; Specify the installation directory. INSTANCEDIR="E:\\" ; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature. SQMREPORTING="False" ; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS). INSTANCENAME="MSSQLSERVER" ; Agent account name AGTSVCACCOUNT="DOMAIN\sqlserver" ; Auto-start service after installation. AGTSVCSTARTUPTYPE="Manual" ; Startup type for Integration Services. ISSVCSTARTUPTYPE="Manual" ; Account for Integration Services: Domain\User or system account. ISSVCACCOUNT="NT AUTHORITY\NetworkService" ; Controls the service startup type setting after the service has been created. ASSVCSTARTUPTYPE="Manual" ; The collation to be used by Analysis Services. ASCOLLATION="Latin1_General_CI_AS" ; The location for the Analysis Services data files. ASDATADIR="Data" ; The location for the Analysis Services log files. ASLOGDIR="Log" ; The location for the Analysis Services backup files. ASBACKUPDIR="Backup" ; The location for the Analysis Services temporary files. ASTEMPDIR="Temp" ; The location for the Analysis Services configuration files. ASCONFIGDIR="Config" ; Specifies whether or not the MSOLAP provider is allowed to run in process. ASPROVIDERMSOLAP="1" ; A port number used to connect to the SharePoint Central Administration web application. FARMADMINPORT="0" ; Startup type for the SQL Server service. SQLSVCSTARTUPTYPE="Automatic" ; Level to enable FILESTREAM feature at (0, 1, 2 or 3). FILESTREAMLEVEL="0" ; Set to "1" to enable RANU for SQL Server Express. ENABLERANU="False" ; Specifies a Windows collation or an SQL collation to use for the Database Engine. SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS" ; Account for SQL Server service: Domain\User or system account. SQLSVCACCOUNT="DOMAIN\sqlserver" ; Windows account(s) to provision as SQL Server system administrators. SQLSYSADMINACCOUNTS="DOMAIN\sqlserver" ; The default is Windows Authentication. Use "SQL" for Mixed Mode Authentication. SECURITYMODE="SQL" ; Default directory for the Database Engine backup files. SQLBACKUPDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Backup" ; Default directory for the Database Engine user databases. SQLUSERDBDIR="E:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ; Default directory for the Database Engine user database logs. SQLUSERDBLOGDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ; Directory for Database Engine TempDB files. SQLTEMPDBDIR="D:\MSSQL10_50.MSSQLSERVER\MSSQL\Data" ; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express. ADDCURRENTUSERASSQLADMIN="False" ; Specify 0 to disable or 1 to enable the TCP/IP protocol. TCPENABLED="1" ; Specify 0 to disable or 1 to enable the Named Pipes protocol. NPENABLED="0" ; Startup type for Browser Service. BROWSERSVCSTARTUPTYPE="Disabled" ; Specifies how the startup mode of the report server NT service. When ; Manual - Service startup is manual mode (default). ; Automatic - Service startup is automatic mode. ; Disabled - Service is disabled RSSVCSTARTUPTYPE="Manual" ; Specifies which mode report server is installed in. ; Default value: "FilesOnly" RSINSTALLMODE="FilesOnlyMode" ; Add description of input argument FTSVCACCOUNT FTSVCACCOUNT="NT AUTHORITY\LOCAL SERVICE"
| Version | Date | Commentaires |
|---|---|---|
| 1.0 | 11/2010 | Version initiale |
How to: Install SQL Server
2008 R2 from the Command Prompt
How to: Install SQL Server
2008 R2 from the Command Prompt - Installation parameters