Analysis of Automatic Installation of SQLServer using scripts

Source: Internet
Author: User
Tags mssqlserver

Every time this happens, I always say to myself: cups are not enough in my life. Because SQL Server installation is still complicated, you must first install it. net, Windows Installer, in the formal installation process also need to fill in a variety of parameters, of course, this does not include the time to copy more than 3 GB of installation files. After several such tragedies, I realized that I had to write a script to change this cruel reality.

Some time ago, I finally got out of my heavy work and could find some time to study the script. When I first started experimenting with this script, my team called me to play the game, so I was lazy and didn't prepare the experiment environment. I ran the installation program using my notebook and then switched to the game. As a result, the system in my book encountered a very hard-to-interpret error. I wrote the detailed information in my previous BLOG. The tragic "BITS Service exception caused CPU Full load". The painful lesson tells us that the experiment still requires the security of virtual machines.

Lab environment:

A Windows server 2003 Enterprise Edition X86 SP2 instance is installed in VMware, which uses SQL Server 2008 R2. Unzip the installation file, save the Virtual Machine snapshot, and save the pure system environment. This way, you can restore it back and re-experiment at any time.

Automated script:

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 script is the above two sections. In fact, only one line is required to install and pass the parameters. However, the installation process of SQL Server is special, so it must be written in two lines. Install the. NET patch and the Windows Installer patch first. After the installation is complete, the entire program will be interrupted. So the one in the first line without a long parameter is to trigger the installation of the. NET patch and the Windows Installer patch. After these two patches are installed, the program will be interrupted, so a long parameter is not required here. The second line is the installation process of the real SQL Server with a long parameter.

In this long string of parameters, it is still regular to sum up.

First,/QS/ACTION = Install/IACCEPTSQLSERVERLICENSETERMS. These parameters are used to set the installation mode and agree to the authorization protocol.

Then, the/FEATURES = SQLEngine, IS, SSMS/INSTANCENAME = MSSQLSERVER/INSTALLSQLDATADIR = "D: \ sqlserverdata" parameters set the installed components and instance information.

Note that Windows and SQL authentication can be set during script installation. If no parameter is specified, Windows authentication is performed by default. I strongly recommend that you use Windows authentication. If you need SQL authentication, you can set the Authentication Mode after installation. If you set SQL authentication in the script, the sa account password will be recorded. If the script is lost, a large number of machines are installed using this script, so there is no need to explain it. Tragedy ......

The next section is purely service settings. Many functions of SQL Server are run in the form of services, so we need to assign them the corresponding startup methods (automatic, prohibited, etc ). In addition, an appropriate startup account (SYSTEM account, local service, domain permission, etc.) is given to the service ). Permissions are granted a lot of lower permissions, and higher permissions will affect security. This should also be considered comprehensively.

The last step is/SQLSYSADMINACCOUNTS = "hanxu". Add an account for SQL sysadmin to log on.

Other optimizations:

1. the installation disk of SQL Server contains X86, X64, and AI64 versions. If you only use one of the Architecture versions, you can delete the folders that store the installation files of other versions and then package them. This simplifies the installation package.

2. I have a script corresponding to SQL Server 2008. If it is a previous version, it may need to be patched. You can also integrate the patch file into the script and then install it automatically using the script. I tested a script to Install SQL Server 2008 AND ITS SP1 Patch, which is very convenient.

3. There is a small difference in the parameters of scripts between different versions of SQL Server. We recommend that you use virtual machine snapshots to save the initial state and try again and again. If an error occurs, the script will provide the error parameter in the command line. You can use the/help command or the MSDN command to query detailed parameters.

It's still nice to use an automated script. I had to manually install it for half an hour. Now, just click it. You can even add the automatic restart command to the script and click the mouse to use it in half an hour. To write this script, I tried virtual machines for dozens or even 20 times. I spent the night, but for me who often installed a large number of tasks, it can be said that an investment is used for life. I would like to share with you some help.

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.