Sqlserver 2008安装

##本文档所有安装操作都使用自动化脚本
----
###安装脚本的参数
```
#!set
saPassword=pass@word1 //sa数据库密码
sqlComponent=SQLENGINE,REPLICATION,FULLTEXT,CONN,BC,SDK,SSMS,ADV_SSMS,SNAC_SDK,OCS //安装组件
collation=Arabic_BIN //排序规则
INSTALLSQLDATADIR=c:/ //默认安装目录
SQLSYSADMINACCOUNTS=.\administrator //本地账号
```
###安装脚本
```
#!cmd
7z x -o${basedir} -y %this.INSTALL_URL% > nul //解压安装包
#!ant //替换安装参数,并使用ant脚本替换sqlserver的交互应答文件
<replace encoding="UTF-8" dir="${basedir}">
<include name="**/*.ini" />
<replacefilter token="@component@" value="%this.sqlComponent%"/>
<replacefilter token="@collation@" value="%this.collation%"/>
<replacefilter token="@INSTALLSQLDATADIR@" value="%this.INSTALLSQLDATADIR%"/>
<replacefilter token="@SQLSYSADMINACCOUNTS@" value="%this.SQLSYSADMINACCOUNTS%"/>
</replace>

#!cmd //执行安装脚本,执行交互应答文件的路径,指定sa密码
cd cn_sql_server_2008_r2_enterprise_x86_x64_ia64_dvd_522233
setup.exe /q /ACTION=Install /ConfigurationFile="standalone.ini" /sapwd=%this.saPassword%

#!ant //删除所有文件
<delete >
<fileset dir="${basedir}" includes="**/*.*"/>
</delete>
```
###sql交互应答文件`standalone.ini`
```
;SQLSERVER2008 Configuration File
[SQLSERVER2008]

INSTANCEID="MSSQLSERVER"

ACTION="Install"

IAcceptSQLServerLicenseTerms="True"

FEATURES=@component@

HELP="False"

INDICATEPROGRESS="True"

QUIET="True"

QUIETSIMPLE="False"

X86="False"

ENU="False"

ERRORREPORTING="False"

INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"

INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"

INSTANCEDIR="C:\Program Files\Microsoft SQL Server"

SQMREPORTING="False"

INSTANCENAME="MSSQLSERVER"

AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE"

AGTSVCSTARTUPTYPE="Manual"

ISSVCSTARTUPTYPE="Automatic"

ISSVCACCOUNT="NT AUTHORITY\NetworkService"

ASSVCSTARTUPTYPE="Automatic"

ASCOLLATION="@collation@"

ASDATADIR="Data"

ASLOGDIR="Log"

ASBACKUPDIR="Backup"

ASTEMPDIR="Temp"

ASCONFIGDIR="Config"

ASPROVIDERMSOLAP="1"

FARMADMINPORT="0"

SQLSVCSTARTUPTYPE="Automatic"

FILESTREAMLEVEL="0"

ENABLERANU="False"

SQLCOLLATION="@collation@"

SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE"

SQLSYSADMINACCOUNTS="@SQLSYSADMINACCOUNTS@"

SECURITYMODE="SQL"

INSTALLSQLDATADIR=@INSTALLSQLDATADIR@

ADDCURRENTUSERASSQLADMIN="False"

TCPENABLED="1"

NPENABLED="0"

BROWSERSVCSTARTUPTYPE="Disabled"

RSSVCSTARTUPTYPE="Automatic"

RSINSTALLMODE="FilesOnlyMode"

```
----
##使用说明
核心点在安装脚本,安装脚本中类似`%this.sqlComponent%`是用来替换在安装参数中定义的变量,并替换交互应答文件`standalone.ini`,然后执行关键脚本
```
setup.exe /q /ACTION=Install /ConfigurationFile="standalone.ini" /sapwd=%this.saPassword%
```

安装成功之后,使用sa密码登陆Sqlserver管理控制器

你可能感兴趣的:(sqlserver)