Implementation steps for automating SQL Server installation with scripts analysis _mssql

Source: Internet
Author: User
Tags mssqlserver
Whenever this happens, I always say in my heart: "Cup, Ah, this life is not finished." Because the installation of SQL Server is still more complex, you have to install. Net, Windows Installer, and in the process of the formal installation of the various parameters to be interactive, of course, this does not include the copy of the 3GB more installation files time. After a few of these tragedies, I was decisively aware of the need to study writing a script to change this brutal reality.

Some time ago will be a school graduation defense I finally left the heavy work, can find a time to study the script. Just started experimenting with this script, because the classmate shouted I play games, I lazy did not prepare the experimental environment, directly with my notebook ran the installation program, and then cut to the game. The result also caused the system of my book to appear difficult to explain the error, detailed situation I wrote in the blog, the tragedy of "BITS service exception raised CPU full." The bitter lesson tells us that it is safer to do experiments or virtual machines.

Experimental environment:

A Windows Server 2003 Enterprise Edition X86 SP2 is installed in VMware with SQL Server 2008 R2. Install the file after decompression to save the virtual machine snapshot, save this pure system environment, so you can restore back at any time, the experiment again.

Automation scripts:

Setup.exe/qs

Setup.exe/qs/action=install/iacceptsqlserverlicenseterms
/features=sqlengine,is,ssms/instancename=mssqlserver
/installsqldatadir= "D:\sqlserverdata"/agtsvcaccount= "SYSTEM"
/agtsvcstartuptype= "Disabled"/sqlsvcaccount= "SYSTEM"
/sqlsvcstartuptype= "Automatic"/issvcaccount= "SYSTEM"
/issvcstartuptype= "Automatic"/issvcaccount= "local SERVICE"
/issvcstartuptype= "Automatic"/sqlsysadminaccounts= "Hanxu"

Pause


The main part of the entire script is the two paragraph above, in fact, to install and pass the parameters in the original only need a line. However, because of the special installation process for SQL Server, it needs to be written in two lines. The real installation needs to be installed first. NET patches and Windows Installer patches, the entire program is interrupted after Windows Installer is installed. So the first line that doesn't take very long parameters is to trigger the installation. NET patches and Windows Installer patches. After these two patches are installed, the program is interrupted, so there is no need to attach a long parameter. The second line, the one with a long argument, is the real SQL Server installation process.

In this very long string of parameters inside, in fact, summed up there is still a regular.

The first is/qs/action=install/iacceptsqlserverlicenseterms, which is used to set the installation mode and agree to the authorization protocol.

Then,/features=sqlengine,is,ssms/instancename=mssqlserver/installsqldatadir= the "D:\sqlserverdata" parameters to set the installed components and instance information.

Here is a bit of the need to explain, script installation support to set Windows and SQL authentication, if any parameters are not filled is the default Windows certification. I strongly recommend the use of Windows authentication, if you need SQL authentication can wait for installation and then set the verification mode, if the script inside the set of SQL verification, the inside will be recorded with the SA account password. If the script is lost, a lot of machines are installed with this script, and that doesn't have to be explained, tragedy ...

The following paragraph is a purely service setting, and many of the functions of SQL Server are run in a service way, so give them the appropriate starting mode (automatic, disable, etc.). There is the right to the service to give the start account (System account, Local service, domain permissions, etc.). Permissions to a lot of low permissions, permissions to the high will affect security, this should also be considered comprehensively.

The last is/sqlsysadminaccounts= "Hanxu", which adds an account to the SQL sysadmin for landing.

about other optimizations:

1.SQL Server installation disk contains the 3 versions of X86, X64, AI64, if only one of the framework of the version, you can store other versions of the installation files folder directly deleted, and then packaged, so you can streamline the installation package.

2. My strength script corresponds to SQL Server 2008, if the previous version may need to be patched. You can also integrate the patch file into the script, and then walk the script automatically installed. I've experimented with a script that installs SQL Server 2008 and its SP1 patch, which is handy.

The script for different versions of 3.SQL server has a small difference in parameters, it is recommended to save the initial state with a virtual machine snapshot, and then try again and again. If there is an error, the script gives the error parameter in the command line. Detailed parameter queries can use the/help command or go to the MSDN query.

With the automation of the script is still very cool, the original manual installation half an hour of work, now click the mouse on the line. You can even give the script the automatic Restart command, click the mouse, half an hour after the direct can be used. In order to write this script, I used a virtual machine to experiment with a few 十、二十次 appearance, overnight a night, but for me this often a large number of installation tasks, can be said to be a lifelong investment. Here to share with you, hope to help you.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.