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
版权声明:本文为博主原创文章,转载请附上博文链接!