To create a 3-tier Windows Deployment from scratch using the Microsoft IIS App Server (v13.1) and Database Manager for Microsoft SQL Server (v13.1) ServerTemplates on Amazon EC2 (Load Balancer with HAProxy (v13) as a load balancer, Microsoft IIS App Server (v13.1) as an application server and mirrored Database Manager for Microsoft SQL Server (v13.1)as a database server).
Note: This tutorial works with the v13.1 inifinity lineage branch only. The 12.11 LTS branch of ServerTemplates is NOT compatible. If you are using the 12.11 LTS branch of ServerTemplates, see 3 Tier Deployment Windows (LTS). For more information about release terminology, see ServerTemplate Release and Lineage Methodology.
Table of Contents
Determine which AWS region the Windows servers will be launched into and create an EC2 SSH Key in that region. See Create a New SSH Key.
You will need two EIPs for both of the front end Load Balancers. Name them appropriately. (e.g. myapp-lb1 and myapp-lb2) (Those in a classroom environment should preface their EIP names with their initials for easy identification later.) See Create Elastic IPs (EIP).
Tip:
Create an EC2 Security Group with the following port permissions in the selected AWS region. For development and test purposes you can simply create a single security group that will be used by all Windows servers. However, if you are building a production environment, you should consider creating separate security groups for each tier. Use 0.0.0.0/0 CIDR notation to open the ports to any IP address. See Create a New EC2 Security Group.
The created security group should have permissions that look like the following:
Create an S3 bucket with a properly formatted name (see Create a New S3 Bucket) and upload an archive file of the application code (.zip) and a valid database file. You can either restore the database using a SQL backup file (.bak) or attach an existing database file (.mdf). Upload the files to the S3 bucket. Later in this tutorial you will need to provide the URLs to these files as input values. If you do not have your own files that you would like to use, you can download and use the following example files to complete the tutorial.
Note regarding file permissions: When you upload a file to an S3 bucket, its access permissions will automatically be set to "private" which means it can only be accessed with the AWS account credentials. Our scripts will be able to access the database dump file if it's located inside one of your account's S3 buckets even if it's "private" because the AWS account credentials can be used for authentication. However, if you're using an application or dump file that's in an S3 bucket that doesn't belong to this account, you will need to make sure the file is set to "public-read" by updating its permissions with the drop down menu.
The Database Manager for Microsoft SQL Server (v13.1) ServerTemplate supports the following DNS Providers:
You will need to create three DNS A records: two for both of the load balancers and one for the SQL Server principal node. Log into your DNS account and follow the steps below.
Note: The following steps were created using a DNS Made Easy account.
Create a new deployment that will be used to contain all of the Windows servers. See Create a New Deployment.
Now that you have a deployment, you can now use the Database Manager for Microsoft SQL Server (v13.1) ServerTemplate to launch a SQL database server.
Go to the new Deployment and click Add Server button. See Add a Server to a Deployment.
The next step is to provide values for any missing inputs at the Deployment level. Some input parameters are inherited from the ServerTemplate, whereas some are left undefined because they are user-specific.
Go to the Deployment's Inputs tab and click Edit. Although you technically only have to define inputs that are required to launch a database server, you might want to define values for some of the other missing inputs at the deployment level so that you can better manage and keep track of your settings. Also, if you define your inputs now, you will not need to provide any inputs later when you run any of the Operational Scripts.
You will need to create a credential for the ADMIN_PASSWORD input:
Password to set for the local administrator account. Required parameter. You will use this password to log into the Server using RDP. Create a Credential to use and name it ADMIN_PASSWORD.
Important! You will need to provide a password that meets the syntax requirements.
At least one number
Go to the Inputs tab of your Deployment and click Edit and define these missing inputs:
Input Name | Description | Example Value |
ADMIN_PASSWORD | Set the password for the local Administrator account. This should be at least 7 characters long with at least one uppercase letter, one lowercase letter, and one digit. | Cred: ADMIN_PASSWORD |
AWS_ACCESS_KEY_ID | Your AWS credentials are used to set up EBS volumes created and attached to your server. | Cred:AWS_ACCESS_KEY_ID |
AWS_SECRET_ACCESS_KEY | Your AWS credentials are used to set up EBS volumes created and attached to your server. | Cred:AWS_SECRET_ACCESS_KEY |
DATA_VOLUME_SIZE | Enter the size (in GB) for the volume that will be used to store the database file. By default, drive letter D:\ will be used for the data volume. To override this setting and use a different drive letter you can use the OPT_DATA_VOLUME_LETTER input. | Text: 30 |
DB_LINEAGE_NAME | The lineage of the database backups. A string that is used to track all backups in a certain 'set' usually deployment wide. | Text: dotnetnuke |
DNS_DOMAIN_NAME | Enter the Fully Qualified Domain Name (FQDN) of the DNS record. | e.g. text: abc-db1.domain.com |
DNS_ID | Enter the DDNSID of the DNS record you created in a previous step. | 1234123 |
DNS_IP_ADDRESS | Choose whether to use 'public' or 'private' IP addresses for the DNS record. | text:Public IP |
DNS_PASSWORD | Enter the password of your DNS account or select the appropriate credential. | Cred:DNS_PASSWORD |
DNS_SERVICE | Select one of the predefined DNS provider: DNS Made Easy, DynDNS, Rackspace Cloud DNS, or Route53. Note: Do not override the predefined values. | text: DNS Made Easy |
DNS_USER | Enter the user name of your DNS account or select the appropriate credential. | Cred:DNS_USER |
DNS_TTL | Enter the TTL of the DNS record. The default value is 60 seconds. | Text:60 |
INIT_MIRRORING_METHOD | Method of transferring database files and certificates between principal and mirror server to initialize mirroring session. Since we are placing principal and mirror servers in different availability zones, set this input to Remote Storage. | Text: Remote Storage |
LOGS_VOLUME_SIZE | Enter the size (in GB) for the volume that will be used to store the database log file. By default, drive letter E:\ will be used for the log volume. To override this setting and use a different drive letter you can use the OPT_LOGS_VOLUME_LETTER input. | Text: 10 |
OPT_USE_PUBLIC_IP | Since we are placing principal and mirror database servers into different availability zones, this input should be set to True to use public (external) IPs for mirroring connection. | Text: True |
REMOTE_STORAGE_CONTAINER, REMOTE_STORAGE_CONTAINER_APP | Enter the name of S3 bucket to be used as storage for application files, initial database backup and certificate exchange. | Text: Bucketname e.g. mybucket |
REMOTE_STORAGE_ACCOUNT_PROVIDER, REMOTE_STORAGE_ACCOUNT_PRROVIDER_APP | Type of remote storage used to store database backup, application code and certificate exchange. Currently AWS S3, Rackspace Cloud Files, Windows Azure Storage, and SoftLayer Object Storage are supported. In this tutorial we are using S3. | Text: Amazon S3 |
REMOTE_STORAGE_ACCOUNT_ID, REMOTE_STORAGE_ACCOUNT_ID_APP | The Account ID or Name of the Remote Storage account which is used to authenticate your requests to Remote Storage services. We are using S3 in this tutorial so AWS access key id should be used. | Cred:AWS_ACCESS_KEY_ID |
REMOTE_STORAGE_ACCOUNT_SECRET, REMOTE_STORAGE_ACCOUNT_SECRET_APP | The Secret Key or Password of the Remote Storage account which is used to authenticate your requests to Remote Storage services. We are using S3 in this tutorial so AWS secret access key should be used. | Cred:AWS_SECRET_ACCESS_KEY |
SYS_WINDOWS_TZINFO | Set the system time to a specific timezone. Some examples are provided in the dropdown, but can be overridden if the timezone is not listed. | Text: Pacific Standard Time |
Note: We are using the same S3 bucket to store IIS application code and SQL Server database. In a real world scenario you might want to use different S3 buckets (so 2 buckets need to be created and inputs REMOTE_STORAGE_CONTAINER and REMOTE_STORAGE_CONTAINER_APP set to appropriate values).
If you want to download application code from some URL (i.e. https://mydomain.com/app.zip) or from SVN repository you will need to set inputs ZIP_URL and SVN_APP_PATH, SVN_PASSWORD, SVN_USERNAME respectively. For this tutorial all these inputs should be set to 'ignore'.
Other inputs can be left set to default values.
Click Save.
The next step is to import the database onto the instance by restoring it from a backup file (.bak) or attaching an SQL Server data file (.mdf). You will need to select and run the appropriate operational script based upon the chosen method.
Follow these instructions if you want to load the database by using a backup file (.bak).
Input Name | Description | Example Value | |
BACKUP_FILE_NAME | Enter the filename of the database backup file (.bak) that will be used to load the database. (e.g. DotNetNuke.bak) | e.g. text: DotNetNuke.bak | |
BACKUP_LOCAL_DIR | You can leave this input with default value ('ignore'), it could be used to restore from backup file located on file system of the server (not downloading from S3 as in this tutorial). | No value/Ignore | |
DB_NAME | The name of the default SQL Server database that will be created. (e.g. DotNetNuke) Note that this name should match the original database name the backup was taken from. | text: DotNetNuke | |
OPT_BACKUP_TEMP_DIR | You can leave this input with default value ('ignore') | No value/Ignore | |
OPT_LOGICAL_FILE_NAME | Use this optional input to provide the logical name of the data and log files. If your backup files use the default SQL Server logical files naming convention, set this input to 'Ignore'. | No value/Ignore | |
OPT_FORCE_NORECOVERY | For this tutorial you can leave the default value of False to restore the database in Normal mode. | False | |
REMOTE_STORAGE_CONTAINER |
| Text: Bucketname e.g. mybucket | |
REMOTE_STORAGE_ACCOUNT_PROVIDER | Leave the default value of Amazon S3 for this input. | text: Amazon S3 | |
REMOTE_STORAGE_ACCOUNT_ID | Leave the preconfigured value -- AWS access key ID. | Cred:AWS_ACCESS_KEY_ID | |
REMOTE_STORAGE_ACCOUNT_SECRET | Leave the preconfigured value -- AWS secret access key. | Cred:AWS_SECRET_ACCESS |
Click Continue.
Follow these instructions if you want to load the database by using a SQL Server data file (.mdf).
Now you have your principal server ready to serve the database.
Go to the "primary" server's Scripts tab and run the DNS Register IP Operational Script.
Note: The inputs required to run this script have been defined at the Deployment level.
Create the SQL Server login username/password that will be used by the application servers to connect to the "primary" SQL database server. Run the DB SQLS Create login script and specify the following inputs:
Input Name | Description | Example Value |
DB_NAME | Enter the name of the database. | text: DotNetNuke |
DB_REMOTE_SQL_LOGIN | (Optional) Enter the SQL Server login username with administrative rights to the remote SQL Server database server. | cred:DB_SQL_Login |
DB_REMOTE_SQL_PASSWORD | (Optional) Enter SQL Server login password. You can enter a text:'password', but for best practices it would be best to create a credential with your password value and name it something like DB_LOGIN_PASSWORD. | cred:DB_SQL_PASSWORD |
DB_NEW_LOGIN_NAME | Enter the login name for the new SQL Server user. You can enter a text:'password', but for best practices it would be best to create a credential with your password value and name it something like SQL_SERVER_USER_NAME. Important: This value needs to match the OPT_CONNECTION_STRING_DB_USER_ID defined later in this tutorial. To be properly configured, this DB value needs to match the IIS Server value (OPT). | cred:SQL_SERVER_USER_NAME |
DB_NEW_LOGIN_PASSWORD | Enter the login password for the new SQL Server user. You can enter a text:'password', but for best practices it would be best to create a credential with your password value and name it something like SQL_SERVER_USER_PASSWORD. Important: This value needs to match the OPT_CONNECTION_STRING_DB_USER_PASSWORD defined later in this tutorial. To be properly configured, this DB value needs to match the IIS Server value (OPT).
| cred:SQL_SERVER_USER_PASSWORD |
Note: You may not need to perform this step if your SQL Server configuration already contains all necessary logins/users for database access.
Go to the new Deployment and click Add Server button. See Add a Server to a Deployment.
You now have two load balancer servers that have identical configurations. Under the second load balancer server Info tab, click Edit and select the second Elastic IP you created in previous step.
Note: For high availability purposes, you might want to launch the load balancers into different zones from each other. Typically, you will want to use the same zones as the database servers so that each zone will contain a load balancer and database server. To change availability zone of the server you can go to Info tab of that server and click Edit.
Go to the deployment's Inputs tab and define values for the following missing inputs:
Input Name | Description | Example Value |
APPLICATION | Enter the name of the application. | (e.g. myapp) |
HEALTH_CHECK_URI | The URI of the health check page, which is used by HAProxy for checking whether the site is up or not. You must create your own health check page, which returns HTTP 200 OK. The contents of the page are not relevant but its name should be unique (preferably a random number). The same page is used for ALL application servers to determine if the server is UP. For example, if you use '/hlthchk378923.html' (Note: be sure to include the slash before the filename), the health check page would be 'http://www.mydomain.com:80/hlthchk378923.html' and its content could be as simple as "OK." For simplicity we are using /Default.aspx in this tutorial. | text: /Default.aspx |
Go to the deployment's Servers tab and launch both of the load balancer servers.
The next step is to create and launch server array consisting of Microsoft IIS Application Servers.
Go to the Deployment and click Add Array button.
Note: You may receive a warning ‘Some of the Input parameters for boot scripts are missing. Please update them to launch instances successfully’. This is OK, you will take care of the remaining inputs shortly.
Under the server array's Next Alerts tab you will be able to add to the existing alert specifications that are being inherited by the array's application ServerTemplate. Next, you will need to add two new alert specifications that will be used for triggering auto-scaling. When you set up your own custom deployment, you will want to pick appropriate metrics and thresholds that make sense for auto-scaling your own application. But for this tutorial, you can use the suggested parameters below:
Condition: if "cpu-0/cpu-idle.value < '30' for 5 min then vote to grow array by setting the tag to be the name of your server array. We used '3tier'.
Go to the deployment's Inputs tab and Edit values for the following missing inputs.
The required inputs will be different depending on whether you are downloading the application code from a URL or SVN repository or Remote Storage. In this tutorial we are using ZIP file located in AWS S3 bucket.
Note: If you are not using Rackspace, you can set the following inputs to 'Ignore' (RACKSPACE_AUTH_KEY, RACKSPACE_USERNAME), otherwise you will need to provide the appropriate values as text or credentials. The ServerTemplate assumes that you already have credentials that match input names for specifying Rackspace login credentials.
Input Name | Description | Example Value |
---|---|---|
OPT_CONNECTION_STRING_DB_NAME | Name of the database for the application server to connect to. This is the database served by pair of SQL Server instances you configured earlier in this tutorial. | e.g. text: DotNetNuke |
OPT_CONNECTION_STRING_DB_SERVER_NAME | Fully qualified domain name of the database server you created earlier in this tutorial. | e.g. text: abc-db1.example.com |
OPT_CONNECTION_STRING_DB_USER_ID | Login name to be used for database connections created earlier in this tutorial. Important: This value needs to match the DB_NEW_LOGIN_NAME defined earlier in this tutorial. To be properly configured, this IIS Server value needs to match the DB value. | cred:SQL_SERVER_USER_NAME |
OPT_CONNECTION_STRING_DB_USER_PASSWORD | Password for the login created by OPT_CONNECTION_STRING_DB_USER_ID above. Important: This value needs to match the DB_NEW_LOGIN_PASSWORD defined earlier in this tutorial. To be properly configured, this IIS Server value needs to match the DB value. | cred:SQL_SERVER_USER_PASSWORD |
OPT_CONNECTION_STRING_NAME | Application-specific name of the connection string. For DotNetNuke the name is 'SiteSqlServer'. | e.g. text: SiteSqlServer |
ZIP_FILE_NAME | File name of the zip file containing the application code located on remote storage (note that we already configured STORAGE_TYPE and STORAGE_CONTAINER_NAME inputs on deployment level earlier in this tutorial). | e.g. text: DotNetNuke.zip |
Note, if you want to download application code from some URL (i.e. https://mydomain.com/app.zip) or from SVN repository you will need to set inputs ZIP_URL and SVN_APP_PATH, SVN_PASSWORD, SVN_USERNAME respectively. For this tutorial all these inputs should be set to 'ignore'.
Other inputs you can leave to its default values.
Click Save.
Now that you have operational load balancers ready to accept requests, and primary/mirror database servers on the backend, you are ready to start-up the server array to run your application.
Go to your server array page.
Here you have two alternatives:
Enable the server array - if you are using this tutorial for learning purposes, just enable the server array by going to the server array's Info tab and clicking the enable link in the Status row.
Note: After being enabled, the array launches application servers as specified in the Default Min Count autoscaling policy parameters (configured earlier in this tutorial).
To test if your deployment is operational just enter your LB_HOSTNAME in browser address fields. (http://my-www.example.com)
You may find the need to perform some clean up, either to minimize costs, or to perform the tutorial again from a clean slate. Follow these high level steps to do so:
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.