如果玩Windows多的话,看标题就很明白了,利用应答文件自动安装SQL Server,目标很清晰,适用于需要部署多台SQL Server服务器的情况,softice也是近期因项目的需求,找了个时间特意研究了一下sql server 2005的自动化安装,基本上不是很难,走个过场就有了。
在SQL Server 2005的安装光盘的Servers目录下,有一个template.ini文件,这一个文件就是我们制作应答文件需要参考的文件了,接下来,对照着这个文件,对照着GUI安装步骤,走个套路,生成一个应答文件
1、首先把光盘中的内容复制出来,放在硬盘上,给个sql文件夹让它呆着,在sql\servers目录下新建一个空的unattend.ini文件,第一行写上[options],启动setup.exe,接受安装许可,这一步骤不需要unattend.ini写入
![](https://i-blog.csdnimg.cn/blog_migrate/da068be40ce68e9f1e9dc51c5c2a6f62.png)
2、下一步,安装必备组件,unattend.ini也不需要做更改
![](https://i-blog.csdnimg.cn/blog_migrate/60090b04fd885af7a4564a228fe95900.png)
3、接下来走向导,直到注册信息这一步,需要在unattend.ini中填写了
![](https://i-blog.csdnimg.cn/blog_migrate/e6818fe5983d59f1935393dc633f2500.png)
在unattned.ini中填入相应的信息为
USERNAME=Softice
COMPANYNAME=Microsoft
PIDKEY=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
4、继续下一步,这一次我们要选择安装的组件,我们可以根椐需要安装相应的组件,这里因为我们没有安装IIS,所以Report Services是不可选的
![](https://i-blog.csdnimg.cn/blog_migrate/06bb31a445d8480db7a1e20e29e24eee.png)
同样的,我们还可以选择高级选项按钮,查看每一个组件的组成
![](https://i-blog.csdnimg.cn/blog_migrate/667d6d98c70581eab08e49967c0b4904.png)
而这一些,要在unattend.ini中说明,我们可以如下写入
[Options]
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,
AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
这一些组件的名称说明,可以在template.ini找到
SQL Server Database Services SQL_Engine
; Data Files SQL_Data_Files
; Replication SQL_Replication
; Full-Text Search Engine SQL_FullText
; Analysis Server Analysis_Server
; Data Files AnalysisDataFiles
; Reporting Services RS_Server
; Report Manager RS_Web_Interface
; Notification Services Notification_Services
; Engine Components NS_Engine
; Client Components NS_Client
; Integration Services SQL_DTS
; Client Components* Client_Components
; Connectivity Components Connectivity
; Management Tools SQL_Tools90
; Business Intelligence Development Studio SQL_WarehouseDevWorkbench
; Software Development Kit SDK
; SQLXML Client Features SQLXML
; Legacy Components Tools_Legacy
; Documentation and Samples* SQL_Documentation
; SQL Server Books Online SQL_BooksOnline
; Sample Databases SQL_DatabaseSamples
; AdventureWorks Sample OLTP SQL_AdventureWorksSamples
; AdventureWorksDW Sample Data Warehouse SQL_AdventureWorksDWSamples
; AdventureWorks Sample OLAP SQL_AdventureWorksASSamples
; Sample Code and Applications SQL_Samples
; Data Files SQL_Data_Files
; Replication SQL_Replication
; Full-Text Search Engine SQL_FullText
; Analysis Server Analysis_Server
; Data Files AnalysisDataFiles
; Reporting Services RS_Server
; Report Manager RS_Web_Interface
; Notification Services Notification_Services
; Engine Components NS_Engine
; Client Components NS_Client
; Integration Services SQL_DTS
; Client Components* Client_Components
; Connectivity Components Connectivity
; Management Tools SQL_Tools90
; Business Intelligence Development Studio SQL_WarehouseDevWorkbench
; Software Development Kit SDK
; SQLXML Client Features SQLXML
; Legacy Components Tools_Legacy
; Documentation and Samples* SQL_Documentation
; SQL Server Books Online SQL_BooksOnline
; Sample Databases SQL_DatabaseSamples
; AdventureWorks Sample OLTP SQL_AdventureWorksSamples
; AdventureWorksDW Sample Data Warehouse SQL_AdventureWorksDWSamples
; AdventureWorks Sample OLAP SQL_AdventureWorksASSamples
; Sample Code and Applications SQL_Samples
5、继续下一步,指定实例名,我们使用默认实例名
![](https://i-blog.csdnimg.cn/blog_migrate/5f60034fe99c1ee88b368905fd9e4bd7.png)
而在unattend.ini中,要使用默认实例名的话,必须把实例名写为MSSQLSERVER
[Options]
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
6、继续下一步,指定服务帐户,我们根椐安全和使用需求进行选择,作为演示,我们使用本地系统帐户,同时安装结束时启动SQL Server和Analysis Services服务
![](https://i-blog.csdnimg.cn/blog_migrate/ebdd6be9960d5366a6f1519d1e9359b9.png)
而这一些写在unattend.ini中,便是如下
[Options]
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
SQLBROWSERACCOUNT= "NT AUTHORITY\SYSTEM"
SQLACCOUNT="NT AUTHORITY\SYSTEM"
AGTACCOUNT="NT AUTHORITY\SYSTEM"
ASACCOUNT="NT AUTHORITY\SYSTEM"
SQLBROWSERAUTOSTART=0
SQLAUTOSTART=1
AGTAUTOSTART=0
ASAUTOSTART=1
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
SQLBROWSERACCOUNT= "NT AUTHORITY\SYSTEM"
SQLACCOUNT="NT AUTHORITY\SYSTEM"
AGTACCOUNT="NT AUTHORITY\SYSTEM"
ASACCOUNT="NT AUTHORITY\SYSTEM"
SQLBROWSERAUTOSTART=0
SQLAUTOSTART=1
AGTAUTOSTART=0
ASAUTOSTART=1
7、继续下一步,选择身份验证模式,这里我们选择混合模式,并指定sa的密码
![](https://i-blog.csdnimg.cn/blog_migrate/934a9fda21237638cc164ca1e9138bd6.png)
写在unattend.ini中,则多了两行
[Options]
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
SQLBROWSERACCOUNT= "NT AUTHORITY\SYSTEM"
SQLACCOUNT="NT AUTHORITY\SYSTEM"
AGTACCOUNT="NT AUTHORITY\SYSTEM"
ASACCOUNT="NT AUTHORITY\SYSTEM"
SQLBROWSERAUTOSTART=0
SQLAUTOSTART=1
AGTAUTOSTART=0
ASAUTOSTART=1
SECURITYMODE=SQL
SAPWD=abc123,./
USERNAME=softice
COMPANYNAME=Microsoft
ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,SQL_FullText,Analysis_Server,AnalysisDataFiles,Client_Components,Connectivity,SQL_Tools90,SQL_Documentation
INSTANCENAME=MSSQLSERVER
SQLBROWSERACCOUNT= "NT AUTHORITY\SYSTEM"
SQLACCOUNT="NT AUTHORITY\SYSTEM"
AGTACCOUNT="NT AUTHORITY\SYSTEM"
ASACCOUNT="NT AUTHORITY\SYSTEM"
SQLBROWSERAUTOSTART=0
SQLAUTOSTART=1
AGTAUTOSTART=0
ASAUTOSTART=1
SECURITYMODE=SQL
SAPWD=abc123,./
到这一步为止,一个基本的unattned.ini文件己创建好了,我们可以直接使用它来进行无人值守的安装了,只要我们在命令行中执行命令
setup.exe /setting:"c:\sql\servers\unattned.ini" /qb
![](https://i-blog.csdnimg.cn/blog_migrate/93825521fdca13461ab2cdd00ed5499b.png)
其中,setup.exe是servers目录下的安装文件,qb表示安装时显示安装界面。
最后如果有更多的安装场景,需要更灵活的应答文件,可以以此为本,查询template.ini文件,多玩几次,就熟了