SQL Server 安裝時,須要在各個安裝窗口進行選擇和設置,若須要在多臺服務器安裝相同的數據庫,靜默安裝是比較省事的。
當安裝 SQL Server 到最後一步,會有一個安裝配置文件 ConfigurationFile.ini
該文件記錄了前面步驟的設置,彙總到該配置文件中。以下:(此示例是在域中安裝且使用域管理員做爲相關帳戶)
;SQL Server 2012 Configuration File
[OPTIONS]
; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.
ACTION="Install"
; 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,AutoAdvance for a simplied UI, and EnableUIOnServerCore for bypassing Server Core setup GUI block.
UIMODE="Normal"
; Setup will not display any user interface.
QUIET="False"
; Setup will display progress only, without any user interaction.
QUIETSIMPLE="False"
; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found.
UpdateEnabled="True"
; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, MDS, and Tools. The SQL feature will install the Database Engine, Replication, Full-Text, and Data Quality Services (DQS) server. The Tools feature will install Management Tools, Books online components, SQL Server Data Tools, and other shared components.
FEATURES=SQLENGINE,SSMS,ADV_SSMS
; Specify the location where SQL Server Setup will obtain product updates. The valid values are "MU" to search Microsoft Update, a valid folder path, a relative path such as .\MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services.
UpdateSource="MU"
; Displays the command line parameters usage
HELP="False"
; Specifies that the detailed Setup log should be piped to the console.
INDICATEPROGRESS="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"
; Specify the root installation directory for shared components. This directory remains unchanged after shared components are already installed.
INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"
; Specify the root installation directory for the WOW64 shared components. This directory remains unchanged after WOW64 shared components are already installed.
INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"
; 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"
; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will incorporate the instance ID of the SQL Server instance.
INSTANCEID="MSSQLSERVER"
; 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 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 installation directory.
INSTANCEDIR="C:\Program Files\Microsoft SQL Server"
; Agent account name
AGTSVCACCOUNT="KK\dcadmin"
; Auto-start service after installation.
AGTSVCSTARTUPTYPE="Automatic"
; CM brick TCP communication port
COMMFABRICPORT="0"
; How matrix will use private networks
COMMFABRICNETWORKLEVEL="0"
; How inter brick communication will be protected
COMMFABRICENCRYPTION="0"
; TCP port used by the CM brick
MATRIXCMBRICKCOMMPORT="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="Chinese_PRC_CI_AS"
; Account for SQL Server service: Domain\User or system account.
SQLSVCACCOUNT="KK\dcadmin"
; Windows account(s) to provision as SQL Server system administrators.
SQLSYSADMINACCOUNTS="KK\dcadmin" "Administrator"
; The default is Windows Authentication. Use "SQL" for Mixed Mode Authentication.
SECURITYMODE="SQL"
; Provision current user as a Database Engine system administrator for SQL Server 2012 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"
此配置文件是經過UI操做的,不適於靜默安裝,須要修改寫配置。
如當前本身用虛擬機測試的集羣中獨立安裝MSSQL,虛擬機不作什麼要求,在其餘節點都執行相同的配置文件靜默安裝sql server。
其中修改以下:
; SQL Server 2012 Configuration File
; 參考:https://msdn.microsoft.com/zh-cn/library/ms144259.aspx
[OPTIONS]
; ACTION 可選爲 INSTALL(安裝), UNINSTALL(卸載), UPGRADE(升級)
ACTION="Install"
; 【新增】必需,用於確認接受許可條款,靜默安裝用。
IACCEPTSQLSERVERLICENSETERMS
; 【新增】產品密鑰。 若是未指定此參數,則使用 Evaluation。
PID="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
; 在已本地化的操做系統上安裝英文版的 SQL Server。
ENU="True"
; 【註釋】UIMODE 可選爲Normal,AutoAdvance (UIMode 設置不能與 /Q (QUIET)或 /QS(QUIETSIMPLE)參數結合使用)
; Normal : 非 Express 版本,所選的功能提供其全部安裝程序對話框。
; AutoAdvance : 對於 Express 版本是默認值,它跳過不重要的對話框
; UIMODE="Normal"
; 【註釋】是否靜默安裝,靜默安裝不顯示用戶交互界面.QUIET 與 QUIETSIMPLE 二選一
; QUIET="True"
; 是否只顯示進度(最後一步安裝進度),不顯示用戶交互界面。靜默安裝仍是顯示進度吧。
QUIETSIMPLE="True"
; 是否應發現和包含產品更新,不更新。
UpdateEnabled="False"
; 安裝的功能,此爲 MSSQL存儲引擎 和 SSMS管理工具
FEATURES=SQLENGINE,SSMS,ADV_SSMS
; SQL Server 安裝程序將獲取產品更新的位置( .\MyUpdates)
UpdateSource="MU"
; 顯示安裝參數的用法選項,不顯示
HELP="False"
; 指定是否將詳細的安裝日誌文件傳送到控制檯。(此禁用或只看進度便可 QUIETSIMPLE="True")
; 安裝過程日誌信息:C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log
INDICATEPROGRESS="True"
; 是否容許32位程序安裝到64位系統上(WOW64)
X86="False"
; 爲 64 位共享組件指定一個非默認安裝目錄。
INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"
; 爲 32 位共享組件指定一個非默認安裝目錄。 僅在 64 位系統上受支持。
INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"
; 實例名稱
INSTANCENAME="MSSQLSERVER"
; 實例ID
INSTANCEID="MSSQLSERVER"
; 是否收集使用數據發送到 Microsoft(是:1 or True;否:0 or False )
SQMREPORTING="False"
; 是否將錯誤反饋發送到 Microsoft(是:1 or True;否:0 or False )
ERRORREPORTING="False"
; 安裝目錄
INSTANCEDIR="C:\Program Files\Microsoft SQL Server"
; 【新增】代理服務帳戶(新增密碼項)
AGTSVCACCOUNT="KK\dcadmin"
AGTSVCPASSWORD="dcadmin"
; 代理啓動模式,設置自動
AGTSVCSTARTUPTYPE="Automatic"
; CM 程序塊 TCP 通訊端口(未知)
COMMFABRICPORT="0"
; 矩陣如何使用專用網絡(未知)
COMMFABRICNETWORKLEVEL="0"
; 如何保護程序塊間的通訊(未知)
COMMFABRICENCRYPTION="0"
; CM 程序塊使用的 TCP 端口(未知)
MATRIXCMBRICKCOMMPORT="0"
; SQL Server 引擎服務的啓動模式
SQLSVCSTARTUPTYPE="Automatic"
; FILESTREAM 是否啓用,值爲 (0, 1, 2 or 3).
FILESTREAMLEVEL="0"
; 爲 SQL Server Express 安裝啓用運行身份憑據。
ENABLERANU="False"
; SQL Server 的排序規則設置
SQLCOLLATION="Chinese_PRC_CI_AS"
; 【新增】SQL Server 服務的啓動賬戶(新增密碼項)
SQLSVCACCOUNT="KK\dcadmin"
SQLSVCPASSWORD="dcadmin"
; 指定 Windows 帳戶做爲數據庫管理員
SQLSYSADMINACCOUNTS="KK\dcadmin" "Administrator"
; 【新增】SQL受權模式,"SQL"爲混合受權,需設置密碼(新增密碼項)
SECURITYMODE="SQL"
SAPWD="dcadmin"
; 【註釋】當前用戶做爲數據庫管理員(對於 SQL Server Express 版本爲 True,其餘未true)
; ADDCURRENTUSERASSQLADMIN="True"
; 指定 SQL Server 服務的 TCP 協議的狀態(0:禁用;1:啓用)
TCPENABLED="1"
; 指定 SQL Server 服務的 Named Pipes 協議的狀態(0:禁用;1:啓用)
NPENABLED="0"
; SQL Server Browser 服務的啓動模式,禁用。
BROWSERSVCSTARTUPTYPE="Disabled"
修改完成後,進入 mssql 安裝目錄, 執行 setup.exe 安裝:
.\setup.exe /CONFIGURATIONFILE="C:\PerfLogs\ConfigurationFile.ini"
等待完成便可,若出現中斷,查看安裝日誌什麼錯誤。 C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log