SQL Server 靜默安裝


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
此外,還可以單獨設置數據文件的數據目錄(INSTALLSQLDATADIR)等
---------------------
作者:薛定諤的DBA
來源:CSDN
原文:https://blog.csdn.net/kk185800961/article/details/62979524
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM