Table of Contents | |||
|
Long Term Support Stable, tested ServerTemplate assets |
|
To set up one of the following Microsoft SQL database configurations in a deployment using cloud resources of a public or private cloud.
This tutorial describes the steps for launching either a standalone Microsoft SQL server in a cloud or a mirrored setup consisting of a Principal and Mirror database server.
Note: Rackspace Performance Cloud Servers are not supported.
In a typical 3-tier architecture setup, DNS A records are used to create fully qualified domain names (FQDNs) that map to a particular server or tier of servers. The digram below shows a typical example of a 3-tier website architecture.
For example, the application servers locate the standalone or principal SQL database server by using the database server's FQDN (e.g., db-principal.example.com), which points to the server's private IP address. Similarly, front-end web traffic can be routed to a FQDN (e.g. www.example.com) where each load balancer server has a DNS record for that FQDN so that incoming requests are routed to one of the load balancer servers. Since the IP address of an instance in the cloud is often dynamically assigned at launch time, you are required to use a DNS provider that supports dynamic DNS (i.e. the ability to dynamically update the IP address of an A record) for the standalone/principal server (at a minimum). You can also use the same DNS provider for creating FQDNs for the load balancer servers. However, since they do not require the use of dynamic DNS, any DNS provider can be used.
TTLs
When you create the DNS records, it's important to set appropriate TTLs to ensure that servers will not stay connected to an old IP address that is no longer assigned to a functional server. For example, the DNS record that points to the standalone/principal database server should have a low TTL to ensure that the application servers will connect to the correct server within a reasonable amount of time. It's strongly recommended that you use a TTL of 60 seconds for the DNS record that points to the standalone/principal database server. If you are also creating DNS records for the front-end load balancer servers, you can use a more conservative TTL than the database tier. (e.g. 1800 seconds)
Note: If you are using Rackspace's Cloud DNS service, you must use a TTL of 300 seconds for the database servers because it's the lowest allowable TTL. Be sure to change the 'DNS_TTL' input from 60 (default) to 300.
You will need to create DNS records for the following servers:
RightScale's ServerTemplates contain scripts that support one of the following DNS providers. Create an account with one of the DNS providers below and set up the A records accordingly.
Important! The tutorials below assume that you are creating records for a Linux-based architecture. However, you can follow the general steps to create the DNS records that are required for Windows.
Prerequisite: Requires 'actor' user role privileges in the RightScale account.
In order to securely pass sensitive information to a script at runtime, you can use Credentials as a means of variable substitution. Later in this tutorial you will select these credentials when you define your inputs.
Create the appropriate credentials depending where the initial SQL backup file (.bak) or existing database file (.mdf) will be retrieved.
The ServerTemplate contains scripts that can retrieve a Microsoft SQL database backup file from a Remote Object Storage (ROS) location such as an Amazon S3 bucket or a Rackspace Cloud Files container. Create a new bucket/container and upload your database backup file. You can either restore the database using a SQL backup file (.bak) or attach an existing database file (.mdf). The file can remain a 'private' object because your cloud credentials can be used (as inputs) for authentication purposes to retrieve the file.
Warning! The filename of the backup file cannot contain a dash (-) in its prefix name. For example, if your dump file is named, 'my-app-201205030022.gz', you must manually rename it to be 'my_app-201205030022.gz' where you use an underscore (_) to replace the dash, otherwise the script (do::do_dump_import) that imports the database dump file into the instance will fail.
If you are setting up a database server for testing purposes, you may use the following sample SQL backup file to complete the tutorial.
Follow these steps to add a database server to the deployment.
The next step is to define the properties of your database server or servers by entering values for inputs. It is simplest and best to do this at the deployment level. For a detailed explanation of how inputs are defined and used in Chef recipes and RightScripts, see Understanding Inputs.
The inputs that you need to provide values for will depend on which options you're going to use. The ServerTemplate is very flexible and supports a variety of different configurations. You will need to provide the necessary values as inputs based on which options you want to use.
Go to the deployment's Inputs tab (Manage > Deployments > your deployment) and click Edit.
Although you can enter text values for all missing inputs, it's strongly recommended that you set up credentials for passing sensitive information to scripts such as passwords or any other sensitive data.
By default, the server will be configured to take continuous backups of the SQL database. Backups will either be saved as snapshots (if volumes and snapshots are supported by the cloud) or as backup files (.bak) to an ROS location such as an Amazon S3 bucket or Rackspace Cloud Files container. If you are setting up the SQL database with this ServerTemplate for the first time, you can either use an existing database (.mdf) or backup (.bak) file stored in an ROS container. If you are using the provided example, provide the appropriate inputs to use the backup file (DotNetNuke.bak).
Input Name | Description | Example Value |
BACKUP_FILE_NAME | The name of the database backup file that you previously uploaded to an ROS container. (e.g., sql-database.bak) If you are going to use a database file (.mdf), leave this field empty and use the MDF_FILE_NAME input instead. | For the provided sample file use: text: DotNetNuke.bak |
BACKUP_METHOD | Select the type of backup storage that will be used for taking backups of the database. If the cloud supports volumes and snapshots, you should use 'Snapshots' for this option.
| text: Snapshots |
DB_BACKUP_KEEP_DAILY, _LAST, _MONTHLY, _WEEKLY, _YEARLY | If you are using snapshots (BACKUP_METHOD=Snapshots) to create database backups, you can use these inputs to specify the preferred backup policy. Inputs are ignored if you are using 'Remote Storage' for BACKUP_METHOD. See Archiving of EBS Snapshots for more details. | |
MDF_FILE_NAME | The name of the database file that you previously uploaded to the ROS container. (e.g., sql-database.mdf) If you are going to use a database backup file (.bak), leave this field empty and use the BACKUP_FILE_NAME input instead. | text: sql-database.mdf |
AWS EC2 only
If you are launching your servers in AWS EC2 and using EBS volumes for local data storage, you must provide your AWS credentials for authentication purposes. If you are not using AWS services, set these inputs to 'ignore'.
Input Name | Description | Example Value |
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY | Specify valid AWS cloud credentials. | cred: AWS_ACCESS_KEY_ID cred: AWS_SECRET_ACCESS_KEY |
Input Name | Description | Example Value |
DATA_VOLUME_SIZE | The size of each volume that will be used to store the SQL database. For example, if the NUMBER_STRIPES input is '2' and you specify a DATA_VOLUME_SIZE of '5', two 5-GB volumes are created. It's recommended that you specify a large enough value that provides enough space for the database to grow over time and provide optimal read/write performance. Warning! If your are deploying on a CloudStack-based cloud that does not allow custom volume sizes, enter a predefined CloudStack volume size (e.g., 'Small' or 'Large') rather than a numeric value here. | For the provided sample file use:
NOTE: For Rackspace Open Cloud, the minimum volume size is 100 GB |
DB_LINEAGE_NAME | The lineage of the database backups. This is a string that is used to track all backups in a certain 'set', usually deployment wide. Ex: mymssqlserver | text: LineageName |
DB_NAME | Enter the name of the default database to assign to the created SQL Server login. This value is not an arbitrary value. The name of the database is already set. If there are multiple databases, you can define a comma-separated list of all the database names. Ex: DatabaseName | text: mydb
For the provided sample file use: text: DotNetNuke |
INIT_MIRRORING_METHOD | The method for setting up a SQL database mirroring session between two servers. A backup (.bak) of the database and a self-signed certificate are used to authenticate a mirror session between a principal and mirror database server. It's recommended that you launch your principal and mirror servers in different availability zones for high availability and disaster recovery reasons. You can either use a snapshot or an ROS container depending on the cloud volume support.
| text: Snapshots |
MASTER_KEY_PASSWORD | This password is used for the encryption of the master database key, which is used to protect other certificate keys in the database. This input allows you to set a master key password so that you are later able to decrypt and use the master key, if necessary. Note: It's strongly recommended that you use a credential to hide the actual key value from non-admin users while still allowing them to pass the appropriate value as an input. | cred: MY_MASTER_KEY_PASSWORD |
LOGS_VOLUME_SIZE | Size of the volume (in GB) for storing log files. Ex: 1 To Configure 'tempdb' this should be 1GB or greater than your instance core count. |
For the provided sample file use: text: 1 |
NUMBER_STRIPES | If the cloud supports the use of volumes, you can create a drive (e.g., D:\) that consists of a stripe of volumes. This input applies to both the data and log drives. If you do not want to use a volume stripe, keep the default setting which uses a single volume with no striping. (Default: 1) Warning! You can set this to a numeric value between 1 and 5 when launching your server in the Amazon EC2 cloud; however, do not set it to values greater than 2 for CloudStack-based servers. This restriction is due to a difference in the quantity of block devices supported for CloudStack-based clouds. | text: 1 |
Input Name | Description | Example Value |
DNS_DOMAIN_NAME | If you are using a DNS service provider that references records by a FQDN (DynDNS, Rackspace Cloud DNS, and Amazon Route 53) instead of a string ID, use this input to specify the fully qualified domain name that points to the standalone or principal database server.
For other DNS services, you can leave this field blank/unset. | text: my-principal.example.com |
DNS_ID | Use this input to provide the appropriate identification number of the standalone or principal database server's DNS record. See below for details. Examples:
| text: 1234567 |
DNS_PASSWORD | The account or record level password used to log into your DNS provider. For security reasons you may want to create and use a credential to pass this value to the script.
| cred: DNS_PASSWORD |
DNS_SERVICE | Select the DNS provider that will be used to update the DNS record of the principal database server.
| text: DNS Made Easy |
DNS_USER | The username used to log into your DNS provider. For security reasons you may want to create and use a credential to pass this value to the script.
| cred: DNS_USER |
OPT_USE_PUBLIC_IP | Defines whether or not a mirror database server will use the public (not private) IP address to connect to the principal database server.
| text: False |
USE_PUBLIC_IP_WITNESS | If you are going to launch a MSSQL Witness server, use this input to specify whether or not the witness will use the public network to connect to the principal and mirror database servers on TCP port 5022. If you launch the witness server in a cloud/region where it cannot communicate with the principal and mirror database servers over the private network, you must set this input to 'True' and set appropriate firewall permissions on both the pricipal and mirror servers to allow ingress communication from the witness server.
Note: Later when you launch the witness server, make sure the same value is used for this input. | text: False |
Input Name | Description | Example Value |
REMOTE_STORAGE_ACCOUNT_ID | The Account ID or Name of the Remote Storage account which is used to authenticate your requests to Remote Storage services. It's strongly recommended that you use a credential to hide the actual key value from non-admin users while still allowing them to pass the appropriate value as an input.
| cred: AWS_ACCESS_KEY_ID |
REMOTE_STORAGE_ACCOUNT_PROVIDER | The remote object storage provider where your database file is stored, select appropriate provider from the dropdown list.
| text: Amazon_S3 |
REMOTE_STORAGE_ACCOUNT_SECRET | The Secret Key or Password of the Remote Storage account which is used to authenticate your requests to Remote Storage services. It's strongly recommended that you use a credential to hide the actual key value from non-admin users while still allowing them to pass the appropriate value as an input.
| cred: AWS_SECRET_ACCESS_KEY |
REMOTE_STORAGE_CONTAINER | If retrieving from a Remote Storage container, specify its name here. If retrieving from an ROS container from another cloud account, the specified file must be publicly accessible (e.g. set to "public-read" at a minimum). Warning! If BACKUP_METHOD is set to 'Remote Storage' and the ROS container used for backups differs from the one where your database file is stored, ensure that you change this value back to your backup container, if needed, after running this script. | text: my-bucket |
Input Name | Description | Example Value |
ADMIN_PASSWORD | Set the new password for the local Administrator account. Note: The password must meet the Microsoft SQL Server Strong Password requirements, otherwise the random password that is generated for you at boot time (located under the Server's Info tab,'Initial Admin Password' field) will be used instead. The password must satisfy the following requirements:
When you RDP into the server, you will use this password to log in as the Windows 'Administrator' user. Note: It's strongly recommended that you use a credential to hide this value. However, anyone who needs to log into the server will need to know the actual value. | cred: WINDOWS_ADMIN_PASSWORD |
SYS_WINDOWS_TZINFO | Sets the system timezone to the timezone specified, which must be a valid Windows timezone entry. You can find a list of valid examples in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones". Some examples have been provided in the dropdown, which you may override if you do not see your timezone listed. It's strongly recommended that you use "UTC" | text: UTC |
After configuring your inputs, launch the database server that will serve as either the standalone or principal server.
Input Name | Description | Example Value |
SERVER_MODE | Select the database server's role/mode.
| text: Standalone |
The next step is to load the database onto the server by either using a backup (.bak) or database file (.mdf) from an ROS container (e.g., Amazon S3 bucket).
The next step is to create your first backup of the database, which adds a set of tags (such as the lineage name) to the backup snapshots/file. The tags are used by the ServerTemplate's scripts to properly locate and retrieve backups for initial setups and database restorations.
Note: If you are only setting up a standalone SQL database server, you can skip this step.
If you are going to connect an IIS application server to the database, you will want to create an application specific SQL user. Application servers will access the database using the created SQL user's username and password. If you want to use credentials to hide the actual username and password values, create appropriately named credentials prior to running the script below.
Input Name | Description | Example Value |
DB_NAME | The name of the SQL database for which you are creating a user. | For the provided sample file use: text: DotNetNuke |
DB_NEW_LOGIN_NAME | User created with database privileges. The IIS web application will use the created SQL user to access the database. After the server is operational, run the 'DB SQLS Create login' script to create the SQL database user. Note: You can also create a user with a script used by the IIS application ServerTemplate. | text: dbuser cred: SQL_SERVER_USER |
DB_NEW_LOGIN_PASSWORD | Password of the SQL database user (DB_NEW_LOGIN_NAME). Note: Password must meet standard Windows 2008/2012 server password complexity requirements. It should be at least 7 characters long with at least one uppercase letter, one lowercase letter, and one digit. | text: 4MicroSoft! cred: SQL_SERVER_PASSWORD |
Important! If you only want a standalone SQL database server your configuration is complete. However, if you want to set up a mirrored SQL configuration that contains a dedicated principal and mirror database server for high-availability purposes, please follow the remaining steps.
Input Name | Description | Example Value |
PRIVATE_KEY_PASSWORD | This is the password used to encrypt the certificate's private key. Although you can input this value as text, it's recommended that you create a credential for each certificate password. Although you can use the same password for each certificate, it's more secure if each certificate has its own unique password. Note: The password must meet the Microsoft SQL Server Strong Password requirements:
| For the Principal Certificate cred: SQL_PRINCIPAL_PRIVATE_KEY_PASSWORD
For the Mirror Certificate cred: SQL_MIRROR_PRIVATE_KEY_PASSWORD
For the Witness Certificate cred: SQL_WITNESS_PRIVATE_KEY_PASSWORD |
MASTER_KEY_PASSWORD | This password is used for the encryption of the master database key, which is used to protect other certificate keys in the database. This input allows you to set a master key password so that you are later able to decrypt and use the master key, if necessary. Note: It's strongly recommended that you use a credential to hide the actual key value from non-admin users while still allowing them to pass the appropriate value as an input. | cred: MY_MASTER_KEY_PASSWORD |
Note: Because your principal server is already operational, the inputs you modify at the deployment level will not affect the currently running principal server. The purpose of modifying these inputs is so your mirror will be able to interpret these inputs.
Note: If you want to create a witness server to monitor whether or not your principal and mirror servers stay connected, see the Database Manager for Microsoft SQL Server Witness - Beta ST - Tutorial.
Go to your deployment > Inputs. Click Edit and modify the following inputs:
Input Name | Description | Example Value |
PRINCIPAL_CERTIFICATE (Required for Principle) | This is the certificate to be used for authentication on the mirroring endpoint of the principal server. This input is required for a principal server. | Cred: SQL_PRINCIPAL_CERTIFICATE |
PRINCIPAL_PRIVATE_KEY_PASSWORD (Required for Principle) | Password to decrypt private key contained in PRINCIPAL_CERTIFICATE input. This input is required for a principal server. This should be the same password which was used to generate and encode certificate and private key by the 'DB SQLS Generate and Save a Certificate' RightScript. | Cred: SQL_PRINCIPAL_PRIVATE_KEY_PASSWORD |
MIRROR_CERTIFICATE (Required for Mirror) | This is the certificate to be used for authentication on the mirroring endpoint of the mirror server. This input is required for a mirror server. | Cred: SQL_MIRROR_CERTIFICATE |
MIRROR_PRIVATE_KEY_PASSWORD (Required for Mirror) | Password to decrypt private key contained in MIRROR_CERTIFICATE input. This input is required if you are going to launch a mirror server. when launching mirror server but not needed for a Standalone SQL Server. This should be the same password which was used to generate and encode certificate and private key by the 'DB SQLS Generate and Save a Certificate' RightScript. | Cred: SQL_MIRROR_PRIVATE_KEY_PASSWORD |
The first step is to change the existing database server from "standalone" to "principal" mode.
Note: You will need to re-enter the information for the MIRROR_CERTIFICATE, MIRROR_PRIVATE_KEY_PASSWORD, PRINCIPAL_CERTIFICATE, and PRINCIPAL_PRIVATE_KEY_PASSWORD (see Modify Deployment Inputs) because the Deployment Level inputs that were modified in the previous step do not have an influence on operational servers.
Note: You will not see a 'completed: DNS SQLS Init Principal' audit entry on the principal server until there is a "mirror" server connected to it.
Next, launch a new server that will become a mirror of the principal server.
If you are setting up a synchronous mirrored SQL Server environment, you will need to launch another SQL database server that will act as a "mirror" of the "principal" server. Ignore this step if you are only setting up a stand-alone SQL Server environment.
Input Name | Description | Example Value |
SERVER_MODE | Since you already have a 'Principal' server running, set this input to 'Mirror'. | text: Mirror |
Since the size, recovery model, and growth settings for the SQL Server tempdb system database can impact server performance, you should configure the principal database according to Microsoft's optimization recommendations, described in the Microsoft Developer Network (MSDN) article Optimizing tempdb Performance.
To configure these optimization settings automatically, run the DB SQLS Configure TempDB operational script, which will:
Note: Make sure that this value multiplied by the number of instance cores does not exceed your value for LOGS_VOLUME_SIZE.
To launch IIS application servers that will connect to the Microsoft SQL database server, see the 3 Tier Deployment Setup (HAProxy-IIS-SQL) tutorial.
See Database Manager for Microsoft SQL Server Witness Beta (v13 Infinity).
Follow the steps below to properly shutdown a SQL database server.
© 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.