To create a 3-tiered production-like deployment from scratch using ServerTemplates published by RightScale for a PHP application.
Table of Contents
Although this end-to-end tutorial was originally designed as a hands-on exercise in an Instructor Led Training course, anyone can follow the tutorial and use it as a learning tool as well. The class environment influences naming conventions, hence we often precede names with initials or names in our examples. (For example, an A Record for John Doe named "jd-www", rather than simply "www"). Be sure to provide enough time for yourself to complete the end-to-end exercise. (Estimate: 1-3hrs)
This tutorial will demonstrate how to build a common 3-tier website architecture in the cloud using several of RightScale's ServerTemplates.
Disclaimers
It's recommended that you create a new deployment (Manage > Deployments) for each new project or reference architecture that you're going to build because you do not want to accidentally inherit any unknown configuration settings.
See Create a New Deployment. (Requires 'actor' user role privileges.)
Tip: It's recommended that you create a bookmark to the deployment's Servers tab for quick navigation back to the deployment at any time.
Prerequisites: Requires 'actor' user role privileges in the RightScale account to create SSH Keys and Elastic IPs, and 'security_manager' privileges to create security groups.
Each cloud infrastructure is unique and requires different resources in order to launch a server in their cloud. Depending on the type of cloud infrastructure that you're going to use to launch servers, you will find it useful to create some of the required cloud-specific resources beforehand so that you can select them in the "Add Server Wizard" when you add servers into a deployment. Cloud resources are also cloud-specific. For example, you cannot launch an EC2 instance in the 'us-east' region with an 'us-west' security group.
If the cloud does not require the use of an SSH Key, you can ignore this step.
SSH Keys are used for authentication purposes to create SSH console sessions for root level access to the instance. Although you are required to associate an SSH Key to a server before you can launch it, the private key material is no longer required if managed SSH (Server Login Control) is enabled for the account (Settings > Account Settings > SSH). By default, Server Login Control is enabled at the account level, where a user's own unique RSA key pair (Settings > User Settings > SSH) is used for authentication purposes for establishing SSH console sessions on all RightLink-enabled instances.
You can either use an existing SSH Key or create a new one.
If the cloud does not support Security Groups, you can ignore this step.
Security groups are firewall settings that apply to instances within a cloud at the infrastructure layer. Security groups are typically used to control ingress communication (i.e. inbound communication to an instance over a particular port and protocol) however, some clouds support the use of security groups to also control egress communication (i.e. outbound requests from the instance). Once you create a security group you can create different firewall rules that control the level of access to instances launched with that particular security group(s). Firewall rules are enforced at the cloud (infrastructure) level using IP-based or Group-based permissions.
If you are building this deployment for demonstration and testing purposes, you can simply create a single security group for all servers in your deployment.
The steps for creating a single security group are different depending on the type of account and cloud that you are using.
Once you are successful setting up your first multi-tier deployment you can set up more secure firewall permissions that would be more realistic for production environments. See Configuring multiple Security Groups for a multi-tiered Deployment.
Some clouds support the use of public IP addresses that you can associate with a server at launch time or remap to another running server, as necessary for lifecycle management scenarios. It's recommended that you use this service, if available for front-end load balancer or web servers that are designed to be public facing. If you're using dedicated HAProxy load balancer servers, you should create/reserve one IP address for each load balancer server. Typically, you will have two HAProxy load balancer servers for high-availability and failover purposes. If you are using a cloud's load balancing service such as Amazon Elastic Load Balancers (ELB) or Rackspace Cloud Load Balancers (CLB) you cannot assign remappable IP addresses. In such cases, skip this step.
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 diagram below shows a typical example of a 3-tier website architecture.
In this type of architecure, the application servers and any "slave" database servers locate the "master" database server by using Master-DB's FQDN (e.g. db-master.example.com), which points to the Master-DB'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 Master-DB 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 "master" 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 "master" 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 because that is the lowest allowable TTL. Be sure to change the 'Database DNS TTL Limit' input from 60 (default) to 300.
You will need to create DNS records for the following servers:
Note: Be aware that you will need to create Database Servers in RightScale before you create DNS A records from them, as private IP addresses are not known until a server has been created successfully. If you are using existing servers you have already created in RightScale for this new deployment, you can proceed with DNS A record creation.
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.
Prerequisites: Requires 'designer' user role privileges in the RightScale account to create a new credential.
Important!
Only the user who created the credential and any 'admin' users will be able to view and modify an existing credential.
Credentials are a way of passing sensitive information to a script (as an input) in a discrete manner without making the actual value visible in the Dashboard. As a best practice, many of the ServerTemplates published by RightScale are preconfigured to use certain credentials. It's recommended that you create these common credentials in your own account. If they already exist and apply to a different deployment, you might want to create a new set of credentials to avoid any conflicts. In such cases, it's helpful to use a common prefix to group the credentials together. (e.g. APP1_DBADMIN_USER)
If you try to launch a server where one of the inputs references a credential that does not exist in the RightScale account, you will receive an error message and will not be able to launch the server. Therefore, it's best to create any required credentials before you configure and launch a server. Depending on your cloud provider and backup storage selections, you may want to create additional credentials.
At a minimum, create the following credentials. See Create a New Credential for more information.
If you are going through a 3-tier tutorial you should create the following credentials with your own values or you can use the example values, if desired.
* If you use Amazon Route 53 or Rackspace Cloud DNS as your DNS provider, you do not need to set up separate DNS user name and password credentials because your cloud credentials are used for authentication purposes.
ServerTemplates published by RightScale have built-in support for several remote object storage (ROS) solutions. Valid cloud credentials are required to retrieve "private" files from an ROS container, create a new container, or store files in a container (such as a binary database backup files).
Set up your desired ROS service(s) and create the recommended user-defined credentials, which you will use when you define inputs for your deployments.
If you are using a source control management (SCM) system to host your application code, you will need to create the appropriate credentials to retrieve your source code from the specified repository.
You can also download application source code from rsync sources.
If you are using SSL to support HTTPS access, you should create credentials for any of the following values that apply. See How do I create an SSL certificate for my web server?
If you are using the public network to connect to the master database server, it's recommended that you use SSL to encrypt the data being transfered between the master database server and the associated slave and/or application servers. Note: SSL is currently only supported in the Database Manager for MySQL 5.1/5.5 ServerTemplates.
The ServerTemplate contains scripts that can retrieve a database dump file from a container in one of the supported Remote Object Storage (ROS) providers (e.g. Amazon S3, Rackspace Cloud Files). See Database Dump Retrieval.
Create a new bucket/container and upload your database dump file. The file can remain a 'private' object because your cloud credentials can be used (as inputs) for authentication purposes to retrieve the file. Supported file types include .gz, .bz2, and .zip. Make sure the uploaded file maintains the its file extension.
Warning! The filename of the MySQL dump 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 or if you do not have your own dump file, you can use the following sample MySQL dump file to complete the tutorial. The sample is a gzip (.gz) file.
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 must provide values for the required inputs based on the chosen options.
Go to the deployment's Inputs tab (Manage > Deployments > your deployment > Inputs) and click Edit.
Although you can enter values for missing inputs as text values, it's strongly recommended that you set up credentials for passing sensitive information to scripts such as passwords or any other sensitive data.
Rackspace only
If you use Rackspace for your database servers and backup storage (i.e., Cloud Files) the storage-related Chef recipes will use Rackspace Service Net (SNET) by default. SNET is Rackspace's internal private networking service for optimized communication between Rackspace Cloud Servers and Cloud Files. If SNET is not supported in your Rackspace environment, you must set the "Rackspace SNET Enabled for Backup" input to false; otherwise, all backup and restore operations that rely on Cloud Files will fail.
If the cloud supports the use of mountable volumes (e.g. AWS EBS Volumes, CloudStack volumes, etc.), primary backups will be saved as volume snapshots. It's strongly recommended that you use volumes to store the contents of the MySQL database for efficiency and performance reasons.
However, if the cloud does not support mountable volumes (e.g. Rackspace First Generation), primary backups must be saved to a Remote Object Storage location. In such cases, the contents of the MySQL database will be stored locally on the instance's ephemeral drive and backups of the database will be stored as binary dump files to the specified object storage container.
Required
Base
Input Name | Description | Example Value |
Primary Backup Secret (default) | Input is ignored if volume snapshots are supported for taking primary backups. Required cloud credential to store a file in the ROS location specified by the Primary Backup Storage Cloud (default) input.
| No value/Ignore cred: AWS_SECRET_ACCESS_KEY |
Primary Backup User (default) | Input is ignored if volume snapshots are supported. Required cloud credential to store a file in the ROS location specified by the Primary Backup Storage Cloud (default) input.
| No value/Ignore cred: AWS_ACCESS_KEY_ID |
Secondary Backup Storage Cloud (default) | The cloud provider of the specified ROS container where the secondary backup will be stored.
| text: Cloud_Files |
Secondary Backup Secret (default) | Required cloud credential to store a file in the ROS location specified by the Secondary Backup Storage Cloud (default) input.
| cred: RACKSPACE_AUTH_KEY |
Secondary Backup User (default) | Required cloud credential to store a file in the ROS location specified by the Secondary Backup Storage Cloud (default) input.
| cred: RACKSPACE_USERNAME |
Secondary Backup Storage Container (1) | The name of the ROS container where the secondary backups will be saved to or restored from. If undefined, secondary backups will be saved to a container name that matches the value specified for the 'Database Backup Lineage' input. If the container does not exist, a new container will be created using the lineage name in the default ROS region. (S3: us-east, Cloud Files: Dallas) The script will fail if a container cannot be created, which may occur in ROS services where container names use a global namespace and a container with that name already exists. (e.g. Amazon S3) Tip: If you want the secondary container to be in a specific region for performance reasons, you should create the container before launching any servers. | text: mysqlbackups |
Block Device Mount Directory (1) | Input is ignored if volumes are not supported. For cloud providers supporting volume-based storage, the mount point for your backup volume or volumes. (Default is /mnt/storage.) | text: /mnt/storage |
Nickname (1) | Input is ignored if volumes are not supported. For cloud providers supporting volume-based storage, the nickname will be used to name the created volumes and snapshots along with an epoch timestamp. (e.g. data_storage-201203100927) By default, this input is set to 'data_storage' however it's recommended that you create a nickname that describes your application or deployment, which will make it easier to identify the created volumes and snapshots. | text: my_deployment |
Number of Volumes in the Stripe (1) | To use striped volumes with your databases, specify a volume quantity. The default is 1, indicating no volume striping. Ignored for clouds that do not support volume-based storage (e.g. Rackspace First Generation). | text: 1 |
Total Volume Size (1) | Specify the total size, in GB, of the volume or striped volume set used for primary storage. If dividing this value by the stripe volume quantity does not yield a whole number, then each volume's size is rounded up to the nearest whole integer. For example, if "Number of Volumes in the Stripe" is 3 and you specify a "Total Volume Size" of 5 GB, each volume will be 2 GB. If deploying on a CloudStack-based cloud that does not allow custom volume sizes, the smallest predefined volume size is used instead of the size specified here. This input is ignored for clouds that do not support volume storage (e.g., Rackspace First Generation). Important! The value for this input does not describe the actual amount of space that's available for data storage because a percent is reserved for taking LVM snapshots. Use the 'Percentage of the LVM used for data (1)' input to control how much of the volume stripe is used for data storage (default: 10%). Be sure to account for additional space that will be required to accommodate the growth of your database over time. | text: 10
NOTE: For Rackspace Open Cloud, the minimum volume size is 100 GB |
Percentage of the LVM used for data (1) | The percentage of the total Volume Group extents (LVM) that is used for data storage. The remaining percent is reserved for taking LVM snapshots. (e.g. 90% for data storage and the remaining 10% for overhead and snapshots) WARNING: If the database experiences a large amount of writes/changes, LVM snapshots may fail. In such cases, use a more conservative value for this input. (e.g. 50%) Be sure to adjust the 'Total Volume Size (1)' input accordingly. | text: 90% |
Advanced
Input Name | Description | Example Value |
Primary Backup Storage Cloud (default) | Input is ignored if volume snapshots are supported for taking primary backups. If the instance is launched into a cloud that does not support volume snapshots, you must specify which ROS solution to use for storing primary backups. You must use ROS for primary backups if the database server is launched into one of the following cloud types.
Primary backups to ROS are saved as binary dump files to a container that matches the value specified for the Database Backup Lineage input. If a matching container in your account does not exist, one will be created for you. However, if the ROS service has a global namespace (e.g. Amazon S3), and you specify a name that is owned by another account, the primary backup scripts will fail. Therefore, it's recommended that you create an ROS container that matches the value for the Database Backup Lineage input.
| No value/Ignore text: s3 |
Primary Backup Storage Cloud Endpoint URL (default) | The endpoint URL for the primary backup storage cloud. You must specify this value for Swift-based ROS services.
This URL is used to set the default endpoint for making API requests to the specified ROS service. Typically not required for public clouds because the endpoint is already known. However, if you are using a private cloud (e.g. OpenStack) where you've set up a local object storage service (e.g. Swift), you must provide this value so that the script knows where to make the API request. Example: http://endpoint_ip:5000/v2.0/tokens | text: http://endpoint_ip:5000/v2.0/tokens |
Secondary Backup Storage Cloud Endpoint URL (default) | The endpoint URL for the secondary backup storage cloud. You must specify this value for Swift-based ROS services.
This URL is used to set the default endpoint for making API requests to the specified ROS service. Typically not required for public clouds because the endpoint is already known. However, if you are using a private cloud (e.g. OpenStack) where you've set up a local object storage service (e.g. Swift), you must provide this value so that the script knows where to make the API request. Example: http://endpoint_ip:5000/v2.0/tokens | text: http://endpoint_ip:5000/v2.0/tokens |
Input Name | Description | Example Value |
Database Admin Password Database Admin Username | Username and password of a database user with administrator privileges. The admin username and password are used for tasks that require administrator access to the database. | cred: DBADMIN_PASSWORD cred: DBADMIN_USER |
Database Application Password Database Application Username | Username and password of a database user with user-level privileges. The application username and password allow the application to access the database in a restricted fashion. | cred: DBAPPLICATION_PASSWORD cred: DBAPPLICATION_USER |
Database Backup Lineage | The name associated with your primary and secondary database backups. It's used to associate them with your database environment for maintenance, restore, and replication purposes. Backup volume snapshots will automatically be tagged with this value. (e.g. rs_backup:lineage=mysqlbackup) Backups are identified by their lineage name.
If volume snapshots are not supported. Primary backups are saved to an ROS container that matches the value specified for this input. If the container does not exist, a new container will be created using the lineage name in the default ROS region. (S3: us-east, Cloud Files: Dallas) The script will fail if a container cannot be created, which may occur in ROS services where container names use a global namespace and a container with that name already exists. (e.g. Amazon S3) Similarly, if you are setting up secondary backups and do not provide a value for the 'Secondary Backup Storage Container (1)' input, the backups are saved to an ROS container that matches the value specified for this input. If the container does not exist, a new container will be created using the lineage name in the default ROS region. (S3: us-east, Cloud Files: Dallas)
Tip: If you want the container to be in a specific region for performance reasons, you should create the container before launching any servers. | text: mysqlbackup |
Database Master FQDN | The fully qualified domain name that points to the master database server. Slave database servers and application servers will use the FQDN to locate the "master" database server. Typically, the DNS record will point to the Master-DB server's private IP address. | text: master-db.example.com |
Database Master DNS Record ID | The record ID or hostname used to identify your master database server to your DNS provider. See Deployment Prerequisites (Linux) for more information. Examples:
| text: 1234567 |
Database Replication Password Database Replication User | Username and password of a database user with replication permissions on the MySQL server. The replication username and password are used for replication between the "master" and "slave" database servers. | cred: DBREPLICATION_PASSWORD cred: DBREPLICATION_USER |
Database DNS TTL Limit | The specified TTL limit of the database servers' dynamic DNS records. It's recommended that you use a low TTL for your database servers DNS records to promote quick failovers. The default is set to 60 (seconds). If you are using Rackspace's Cloud DNS service for Rackspace cloud servers, set this value to 300 (which is the lowest allowable TTL for Cloud DNS). | text: 60 text: 300 (Cloud DNS only) |
Database Replication Network Interface | Defines the network interface to use for database replication. If the master and slave database servers are in the same cloud, you should establish replication using the private network. However, if a slave database server exists in a different cloud/region than the master database server, you must perform replication over the public network. In such cases, replication must be performed over the public network. Therefore, it's strongly recommended that you use SSL to encrypt the transferred data for security reasons. The chosen network selection will also determine which IP address (private or public) of the master database server that is used to update the DNS record, which is defined by the Database Master FQDN input.
| text: private |
Force Promote to Master | Determines whether or not the slave checks if there is a current running master database server and changes the current master into a slave after a database server promotion. This input applies to scripts and cookbooks that use the db::do_promote_to_master operational script.
| text: false |
Most of the MySQL-specific inputs are preconfigured with acceptable default values, but you can change any values, as necessary.
However, if you are setting up master-slave database replication between database servers located in different clouds/regions, you are forced to use the public network for replication. Therefore, you have to perform database replication over the public network (Database Replication Network Interface = public).
Input Name | Description | Example Value |
CA SSL Certificate | The name of your CA SSL Certificate, which is required for encrypted replication over the public network. Use a credential to store this value. (e.g. cred: MYSQL_SSL_CA_CERT) | cred: MYSQL_SSL_CA_CERT |
Master SSL Certificate | The name of your Master SSL Certificate, which is required for encrypted replication over the public network. Use a credential to store this value. (e.g. cred: MYSQL_SSL_MASTER_CERT) | cred: MYSQL_SSL_MASTER_CERT |
Master SSL Key | The name of your Master SSL Key, which is required for encrypted replication over the public network. Use a credential to store this value. (e.g. cred: MYSQL_SSL_MASTER_KEY) | cred: MYSQL_SSL_MASTER_KEY |
Slave SSL Certificate | The name of your Slave SSL Certificate, which is required for encrypted replication over the public network. Use a credential to store this value. (e.g. cred: MYSQL_SSL_SLAVE_CERT) | cred: MYSQL_SSL_SLAVE_CERT |
Slave SSL Key | The name of your Slave SSL Key, which is required for encrypted replication over the public network. Use a credential to store this value. (e.g. cred: MYSQL_SSL_SLAVE_KEY) | cred: MYSQL_SSL_SLAVE_KEY |
Input Name | Description | Example Value |
DNS Service Provider | Select the DNS provider that you used to create the DNS records for the database servers.
| text: DNSMadeEasy |
DNS Password | The password/key required to update the DNS record of a master/slave database server with the specified DNS service provider.
| cred: DNS_PASSWORD |
DNS User | The username required to update the DNS record of a master/slave database server with the specified DNS service provider.
| cred: DNS_USER |
Cloud DNS region | If 'CloudDNS' is the chosen 'DNS Service Provider', use the dropdown menu to select the appropriate cloud region based on the location of the Rackspace cloud servers. Note: This input is ignored unless you are using CloudDNS. | text: Chicago |
After configuring your inputs, launch your newly configured master database server.
Wait for the server to reach the "operational" state before you run a script to initialize the database server.
The script performs the following actions:
Since you have not loaded an actual database onto the server there is no reason to create a primary backup of the database.
Go to the "current" server's Scripts tab and run the db::do_primary_backup_schedule_disable operational script to disable your scheduled backups (cron jobs).
Later, once you have imported your database you will reverse this action and enable continuous backups.
After initializing the master database server and disabling scheduled backups, you will need to add your database (or databases) and records to it.
Note: If you use a previous backup snapshot instead of a MySQL dump file or initialize a blank MySQL database, refer to the Database Manager for MySQL 5.1/5.5 Runbook for instructions.
Input Name | Description | Example Value |
Dump Container | Name of the ROS container that contains the MySQL database dump file. | text: mysqldumps |
Database Schema Name | Name of the MySQL database schema to restore from the MySQL dump file identified by the "Dump Prefix" input. This name is set when you import the dump file into MySQL. The name is only defined within the MySQL instance and not within the actual dump file. As a result the name is somewhat arbitrary but should be descriptive. Important! | text: my_db_schema
For the 'app_test-201109010029.gz' MySQL dump file: text: app_test |
Dump Prefix | The prefix of the MySQL dump file without the associated file extension (.gz, .bz2, or .zip) to retrieve from the ROS container specified by the "Dump Container" input. You can specify either the entire file name including the timestamp or just the file prefix without the timestamp, which selects the most recent dump file available with that prefix. Example: If your dump file is named "mydb-201112202212.gz," you could specify either "mydb-201112202212" or "mydb." If you are using the attached sample MySQL dump file (app_test-201109010029.gz), use "app_test" as the value. | text: app_test |
Dump Storage Account ID | Required cloud credential to retrieve a private file from the specified ROS location. Set to 'Ignore' if the file is publicly accessible.
| cred: AWS_ACCESS_KEY_ID cred: RACKSPACE_USERNAME
|
Dump Storage Account Secret | Required cloud credential to retrieve a private file from the specified ROS location. Set to 'Ignore' if the file is publicly accessible.
| cred: AWS_SECRET_ACCESS_KEY cred: RACKSPACE_AUTH_KEY |
Dump Storage Account Provider | The remote object storage provider where your MySQL dump file is stored.
| text: s3 |
You are now ready to create the first primary backup of the database. You will need a completed backup in order to initialize a slave database server.
It is now safe to enable continuous backups of the database server.
For more information about configuring and modifying your scheduled backup policy, see the Database Manager for MySQL 5.1/5.5 Runbook.
Although you can run MySQL in single-server mode and having a separate slave server for replication purposes is not required, this is strongly recommended for failover purposes. Create a slave server in your deployment.
Make sure the following conditions are true before you launch the second database server.
You are now ready to launch a "slave" database server for failover and redundancy purposes.
DB (advanced)
Input Name | Description | Example Value |
Init Slave at Boot | Set to 'True' to have the instance initialize with a running master database server as a "slave" on boot. | text: true |
The scripts perform the following actions:
If you created a DNS record for the slave database server, you can set a value for the Database Slave DNS Record ID input and run the db::do_set_dns_slave operational script.
If you want to test the status of the "master" and "slave" database servers, see Check Database Status of Master or Slave.
Follow these steps to add a load balancer server to the deployment.
For production environments, it's strongly recommended that you have at least two load balancer servers (preferably in different availability zones or datacenters) for redundancy purposes. The easiest way to create a second load balancer is to simply clone and modify the first load balancer server.
The next step is to define the properties of your load balancer server or servers by entering values for inputs. As a best practice, you should define required inputs for the servers at the deployment level. For a detailed explanation of how inputs are defined and used in Chef recipes and RightScripts, see Inputs and their Hierarchy.
To enter inputs for the Chef recipes that will run on your load balancers, open the deployment's Inputs tab, click Edit, and use the following settings to configure input values. We recommend that you set up credentials for password values and any other sensitive data as shown in the examples.
Input Name | Description | Example Value |
Load Balance Pools | Comma-separated list of URIs or FQDNs for which the load balancer will create server pools to answer website requests. The last entry will be the default backend and will answer for all URIs and FQDNs not listed here. A single entry of any name (for example, default) will mimic basic behavior of one load balancer with one pool of application servers. This will be used for naming server pool backends. Note: Application servers can provide any number of URIs or FQDNs to join corresponding server pool backends (for example, www.mysite.com, api.mysite.com, /serverid, default). |
For the 3-tier tutorial, use: |
Health Check URI | Relative URI (resource path), including the preceding forward slash, pointing to the health-check page on your application servers. For example, /hlthchk378923.html points to the file hlthchk378923.html in the application directory on your application servers. During the testing phase, you may leave this input set to the default (/) value, indicating that health check pages are not included on the application servers. | text: / For the DotNetNuke Windows 3 tier example, use: text: /Default.aspx |
Use Session Stickiness | Leave this value set to "true" to enable session persistence (stickiness). In this case, the load balancer will route client requests made in the same session to the same application server, via a cookie. Set to "false" to disable session stickiness, in which case the load balancer routes each new client request to the next available application server, regardless of session. | text: true
For the 3-tier tutorial, use: |
Status Page Password Status Page Username | Username and password (if required) to access the HAProxy status report page, which is accessible from the URI set in Status URI. | cred: LB_STATUS_PASSWORD cred: LB_STATUS_USERNAME |
Status URI | Relative URI (resource path) pointing to the HAProxy status report page. If you use the default value (/haproxy-status) you can append this value to the hostname or public DNS/IP address for your a load balancer to access the status report—for example, http://example.com/haproxy-status or http://192.123.123.12/haproxy-status. | text: /haproxy-status |
Input Name | Description | Example Value |
Load Balancing Algorithm | Defines which load balancing algorithm is used to establish connections with application servers in the load balancing pool.
| text: roundrobin |
If you are not setting up SSL, leave the SSL related inputs set to 'No value/Ignore' (default).
Input Name | Description | Example Value |
Allow Override Directive | Set to All to allow the use of .htaccess files in the project web root directory. Set to None (default) to disallow the use of .htaccess files. | text: None |
Application Name | On your application servers, the server subdirectory where your application code files are stored. This must match the Application Name input for your application servers. | text: myapp |
Multi-Processing Module | Set to the value matching the application servers that your load balancer will connect to: "prefork" for PHP servers, or "worker" for Rails, Apache Tomcat, and stand-alone application servers. | text: prefork |
SSL Certificate | Contents of the X.509/PEM-format SSL server certificate used for enabling HTTPS communications. | No value/Ignore
cred: SSL_CERTIFICATE |
SSL Certificate Chain | The certificate authority (CA) certificate chain associated with the server certificate used to set up HTTPS communications. | No value/Ignore
cred: SSL_CERTIFICATE_CHAIN |
SSL Enable | Set to "true" to enable SSL ('https'). Set to "false" to disable SSL. (default) | No value/Ignore
text: false |
SSL Certificate Key | The SSL server certificate's private key, in PEM format. | No value/Ignore
cred: SSL_CERTIFICATE_KEY |
SSL Passphrase | If required by an SSL certificate, you must provide the passphrase so Apache can start. | No value/Ignore
cred: SSL_PASSPHRASE |
If you are using Elastic IPs or already know the public IP addresses that will be used by the load balancer servers, you might have already set up the DNS records for the load balancing tier. However, if you do not know the public IP addresses that will be assigned to the load balancer servers, you must manually set up the DNS records after the servers have been launched. Once the servers become operational (and have been assigned their respective public IP addresses), create or update the DNS records with your DNS provider. Each load balancer server should have its own DNS record with the same hostname (e.g. www.example.com) that points to its public IP address.
The DNS records for the HAProxy load balancing tier should direct traffic from the associated hostname (FQDN) (e.g. www.example.com) to the application servers in its load balancing pool.
The ServerTemplate supports the ability to download your application code either as a tarball (.tgz) from a Remote Object Storage (ROS) location or checkout the codebase from a software repository or specific URL.
Note: Currently, OpenStack (Swift) Object Storage is not supported.
Remote Object Storage (ROS)
If you have a tarball of your application, upload it to a Remote Object Storage location as either a 'public-read' or 'private' object. If you are using a 'private' object you must provide valid cloud credentials (as inputs) for authentication purposes in order to properly retrieve the object. For more information see the following tutorials.
Software Repository
If you want to checkout your application code from a software repository (e.g. GitHub), you will need to provide your access credentials as inputs later in this tutorial so that a script can be executed to automatically retrieve your application code. If the code is in a private repository, you may need to generate an SSH key (e.g. GitHub SSH Key) for authentication purposes and create a credential (Design -> Credentials) to store the sensitive value.
If you need an example application for testing purposes, you can use the application code from the following git repository.
If you prefer to use a tarball instead, download the file below and upload it into your own remote storage container. (e.g. S3 bucket)
Follow these steps to add an application server to the deployment.
The next step is to define the properties of your application server by entering values for inputs. It is 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 Inputs and their Hierarchy.
To enter inputs for the Chef recipes that will run on your application servers, open the deployment's Inputs tab and click Edit, then follow the directions below to configure input values. We recommend that you set up credentials for password values and any other sensitive data as shown in the examples.
Note: Some inputs referenced in this tutorial are considered "advanced" are not initially displayed in the Dashboard. If you are unable to find an input in the Dashboard, be sure to use the "Show advanced inputs" option to view all related inputs of a particular input category.
Important! The ServerTemplate supports multiple configuration permutations. Read each input description carefully. You must provide appropriate values depending on your chosen configuration.
Input Name | Description | Example Value |
Database Schema Name | Enter the name of the database schema to which applications will connect to. The database schema should have been created when the initial database was first set up. This input will be used to set the application server's database configuration file so that applications can connect to the correct schema within the database. This input is also used for database dump backups in order to determine which schema will be backed up. | text: db_schema_name
For the 'app_test-201109010029.gz' MySQL dump file: text: app_test |
Application IP Type Given to Load Balancer | Specify the type of IP address that the application service will listen on. Before making this selection, make sure your firewall permissions are properly configured to accept requests on its public or private IP address.
| text: private |
Application Listen Port | The port that the application service listens on to accept requests from the load balancer. If you specify another port than the 8000 (default), be sure to add the port to the "Firewall Rule Port" input and make sure that the security group's settings also allow access (if applicable). | text: 8000 |
Input Name | Description | Example Value |
PHP module packages | To optionally install additional PHP modules besides the default PHP 5.3 packages installed by the ServerTemplate recipes, specify package names here in a comma-separated list. Package naming conventions will differ depending on your Linux distribution; for example, they include a php53u prefix for CentOS and php5 prefix for Ubuntu. | text: php53u-mysql,php53u-pecl-memcache |
Input Name | Description | Example Value |
Database Application Password Database Application Username | Database username and password to add to the MySQL database server for application access. | cred: DBAPPLICATION_PASSWORD cred: DBAPPLICATION_USER
|
Database Master FQDN | Fully qualified domain name for the master MySQL database server. Application servers use this input to locate the "master" database server. | text: master-db.example.com |
Database Provider Type | The type of database that the application will connect to on the client side. Select one of the predefined options in the dropdown menu or use the "Override" option to specify a custom option. The value must be a string that contains the name of the cookbook that contains the matching provider resource and version of the database (optional).
| text: db_mysql_5.5 |
Input Name | Description | Example Value |
Load Balance Provider | Select the type of load balancer (or service) that the application server(s) will connect to.
| text: lb_client |
Load Balance Pools | Specify the load balancing pool(s) to which the application server belongs. Typically, an application server will belong to one load balancing pool, however an HAProxy load balancing server can service multiple pools. An application server can also connect to multiple load balancing pools, if desired. Specify the load balancing pool that the application server will connect to or disconnect from by using one of the following types:
| text: default |
Load Balance Service ID Load Balance Service Secret | For CLB, specify the Rackspace username and API key to use for authentication purposes. For ELB, specify the Amazon access key ID and secret access key for authentication purposes. Note: For HAProxy, aiCache, and other load balancers launched with ServerTemplates, set to 'ignore'. | cred: RACKSPACE_USERNAME cred: AWS_ACCESS_KEY_ID |
Load Balance Service Name | The name of the Amazon Elastic Load Balancer (ELB) or Rackspace Cloud Load Balancer (CLB). Note: For HAProxy, aiCache, and other load balancers launched with ServerTemplates, set to 'ignore'. | text: my-lb-name |
Load Balance Service Region | Note: Input only applies to a Rackspace Cloud Load Balancer (CLB). For a CLB, select the Rackspace region of the Cloud Load Balancer. It's recommended that you create your CLB in a region as close to your application servers as possible.
| text: ORD (Chicago) |
The values that you use for the repository inputs will depend on where the application code will be retrieved from. The selection for the Repository Provider input will determine which inputs will be used to retrieve the application. Unrelated inputs are ignored.
The following inputs are used to retrieve the application from either a Git/SVN software repository or an ROS location (Amazon S3 bucket or Rackspace Cloud Files container). Specify the appropriate inputs based upon the selection for the 'Repository Provider' input.
Input Name | Description | Example Value |
Repository Provider | Specify where the application code should be checked out from.
| For the provided sample application from ROS: For the provided sample application from GitHub: |
Repository URL/ROS Container | The name of the Remote Object Storage (ROS) container where a tarball (.tgz) of the application code will be retrieved from or the URI that points to the location of the application code repository.
| text: my-container For the provided sample application: |
Project App root | The destination location where the application code will be placed on the local instance. If you want the application code to be placed in the root directory, use a forward slash (/) otherwise you will need to specify the full path (e.g. /path/to/code). If set to 'ignore' the default location (/home/webapps) will be used. The 'Application Name' input is used to name the destination folder into which the application code will be placed. Apache and Tomcat will look for the application in the specified path. | text: /home/webapps For the provided sample application: |
Action | Specify how the application code will be pulled from the specified repository.
| text: pull For the provided sample application: |
Known Hosts SSH Key | Use the credential you created earlier in the tutorial. This input will allow verification of the destination host by comparing its IP, FQDN and SSH-RSA with the record in the /root/.ssh/known_hosts file. This input provides improved security by preventing MiTM attacks. | cred:SSH_KNOWN_HOST_KEY |
Important!
If you are checking out code from a Git repository, specify values for the following inputs.
Input Name | Description | Example Value |
Account credential | In order to check out application code from a private (not public) Git repository, you must provide the repository's SSH key (e.g. Git SSH Key) for authentication purposes. Set to 'ignore' if you are using an application in a repository that allows 'public-read' access. | cred: GIT_SSH_KEY For the provided sample application from GitHub: |
Repository Branch/Tag/Commit | The specific branch/tag/SHA of the specified Git repository that the application code should be checked out from. (e.g. mybranch) Use "master" to retrieve the master branch from the repository. | text: mybranch For the provided sample application from GitHub: |
Important!
If you are checking out code from an SVN repository, specify values for the following inputs.
Input Name | Description | Example Value |
Account name Account credential | The username and password required to access and retrieve the application code from the specified SVN repository. | cred: SVN_USER cred: SVN_PASSWORD |
Repository Branch/Tag/Commit | The specific branch or tag of the specified SVN repository that the application code should be checked out from. (e.g. mybranch) Use "trunk" to retrieve the main branch from the repository. | text: mybranch |
Important!
If you are checking out code from a Remote Object Storage (ROS) location, specify values for the following inputs.
Input Name | Description | Example Value |
ROS Prefix | The prefix that will be used to locate the correct tarball of the application. For example, if you're using 'myapp.tgz' specify 'myapp' as the ROS Prefix. | text: myapp For the provided sample application from ROS: |
Account Name | In order to retrieve a tarball of the application code that's a "private" object within the specified Remote Object Storage (ROS) location, you must provide proper cloud authentication credentials. For security reasons, it's recommended that you create and use credentials for these values instead of entering the text value. Specify the Account ID or name of the Remote Storage account.
| text: AWS_ACCESS_KEY_ID |
Account credential | In order to retrieve a tarball of the application code that's a "private" object within the specified Remote Object Storage (ROS) location, you must provide proper cloud authentication credentials. For security reasons, it's recommended that you create and use credentials for these values instead of entering the text value.
| cred: AWS_SECRET_ACCESS_KEY |
Storage Cloud Endpoint URL | The endpoint URL for the ROS service. You must specify this value for Swift-based ROS services.
This URL is used to set the default endpoint for making API requests to the specified ROS service. Typically not required for public clouds because the endpoint is already known. However, if you are using a private cloud (e.g. OpenStack) where you've set up a local object storage service (e.g. Swift), you must provide this value so that the script knows where to make the API request. Example: http://endpoint_ip:5000/v2.0/tokens | text: http://endpoint_ip:5000/v2.0/tokens |
ROS Storage Account Provider | The Remote Object Storage (ROS) service where the tarball of the application code will be retrieved from.
Note: Openstack Object Storage (Swift) is currently not supported. | text: s3 |
Input Name | Description | Example Value |
Application Name | On your application servers, the server subdirectory where your application code files are stored. If you are using dedicated load balancer servers launched with RightScale's "Load Balancer with HAProxy" ServerTemplate, this value must match the Application Name input for your load balancer servers. | text: myapp |
Multi-Processing Module | Leave this input set to the default, "prefork": the valid value for a PHP server. | text: prefork |
After configuring the inputs, you are now ready to launch the server(s) in the deployment and/or server array.
Once all of the servers are operational you can perform the following tests.
If you set up your DNS records and firewall permissions (e.g. security groups) correctly, incoming web requests to your hostname (e.g. www.example.com) will be sent to one of the load balancer servers. HAProxy will then take the request and forward it to one of the application servers in its load balancing pool.
Based on your DNS records, enter the hostname (FQDN) associated with your load balancer servers into a browser window. (e.g. www.example.com) You should see your application's default landing page. If you are using the sample PHP application from RightScale, you should see the following landing page.
If you are using RightScale's sample application and database dump file, you can build the following URL in a browser window to see which application server you were connected to by the load balancer server.
http://<FQDN>/serverid (e.g. http://brian-www.example.com/serverid)
You should see a page that displays the private IP address of the application server.
If you are using RightScale's sample application and database dump file, you can build the following URL in a browser window to verify that the application server can properly access and read the database on the "master" database server.
http://<FQDN>/dbread (e.g. http://brian-www.example.com/dbread)
The easiest way to check the status of the HAProxy load balancing pool is to view the HAProxy Status page. By default, the Status URI input is set to /haproxy-status.
If you created DNS A Records for the load balancer servers, you can visit the HAProxy Status page by entering your <FQDN>/haproxy-status in a web browser window. (e.g. josh-www.rightscaleblue.com/haproxy-status)
If DNS A Records are not used, you can also use the public DNS name or IP of a load balancer server. (e.g. http://192.34.456.77/haproxy-status)
Each application server that's successfully added to the load balancing pool will be highlighted in green. In the example screenshot above, two application servers are in the load balancing pool and are able to receive requests from the load balancer servers. Notice that each application server is identified by its universally unique identifier (UUID) that RightScale assigns to each instance. You can find the server's UUID in its machine tags or under its Info tab.
Application servers highlighted in red are not included in the load balancing pool and will not receive any client requests. There are several reasons why an application server may be highlighted in red.
To perform a standard health check test to make ensure proper communication between HAProxy load balancers and the application servers in its load balancing pool, see the Perform a Health Check Test tutorial.
To replace the static application servers in the deployment (under the deployment's Servers tab) with a scalable server array for dynamically autoscaling the application tier, follow the Add a Scalable Application Server Array to a Deployment tutorial.
If you completed the tutorial for testing purposes and no longer need the running servers, follow the steps below to safely shutdown the deployment.
© 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.