Home > ServerTemplates > Infinity > ST > Database Manager for MySQL 5.1/5.5 (v14 Infinity) > Database Manager for MySQL 5.1/5.5 (v14 Infinity) - Tutorial

Database Manager for MySQL 5.1/5.5 (v14 Infinity) - Tutorial

Table of Contents    

Infinity

Leading edge features

   ►  Tutorial - Setup

Objective

To set up two MySQL 5.1/5.5 database servers running in an asynchronously replicated (master/slave) configuration in a single deployment in a public or private cloud environment.

Prerequisites

  • You must log in under a RightScale account with 'actor,' 'designer', 'security manager,' and 'library' user roles in order to complete the tutorial.
  • For Amazon EC2, CloudStack, and other clouds that support security groups, you must have a security group defined with TCP port 22 open for SSH access, and any other ports required by the server (for example, the default MySQL port, TCP port 3306), for the required security groups and IP addresses. Also, remember that iptables is installed and enabled by default on all servers.
  • We strongly recommend that you set up credentials for password values and any other sensitive data included as Chef recipe inputs. Also, some default input values assume that predefined credentials exist, such as the MySQL user name and password credentials described in Create Credentials for Common Inputs.
  • This tutorial installs a blank MySQL database and uses a mysql dump file stored in an ROS container to restore a single database. If you want to restore a database from a Primary backup, please review the Database Manager for MySQL 5.1/5.5 Runbook.
  • In MySQL, do not set a password for the "root" user; otherwise, the recipes will fail. The “root” user should only be able to log in from “localhost”.
  • To import a MySQL database, you will need a MySQL dump file stored in an Amazon S3 bucket or Rackspace Cloud Files container. If you only wish to install a blank MySQL server, the data import step can be skipped.

Overview

This tutorial describes the steps for launching MySQL database servers running in an asynchronously replicated (master/slave) configuration in the cloud. 

Before starting the tutorial it's strongly recommended that you read the Database Manager for MySQL 5.1/5.5 (v13 Infinity), which will provide a technical overview of the ServerTemplate's overall functionality. 

Create Credentials

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 following credentials.  For more information on setting up credentials, see Create a New Credential.

  • DBADMIN_USER - Username of a database user with admin-level privileges.
  • DBADMIN_PASSWORD - Matching password for DBADMIN_USER.
  • DBAPPLICATION_USER - User name of a database user with user-level privileges.
  • DBAPPLICATION_PASSWORD - Matching password for DBAPPLICATION_USER.
  • DBREPLICATION_USER - User name of a database user with replication permissions on the server.
  • DBREPLICATION_PASSWORD - Matching password for DBREPLICATION_USER.
  • DNS_USER* - Username that's used to log into your DNS provider and access your DNS records.
  • DNS_PASSWORD* - Password for DNS_USER.

If you use Amazon Route 53 as your DNS provider, you do not need to set up separate DNS username and password credentials because your AWS credentials are used for authentication purposes. 

 

Remote Object Storage (ROS)

Depending on your cloud provider and backup storage selections, you may need to create additional credentials. For example, if you are using an ROS service for taking primary and/or secondary backups of your database, you should create credentials for your cloud's object storage service. 

 

SSL for MySQL Replication

For a master-slave database setup where a slave replicates with a master that's located in a different cloud/region for disaster recovery or migration purposes, data is transferred over the public network. In such cases, it's strongly recommended to use SSL for securely encrypting data between the master and slave database servers. Be sure to set the Database Replication Network Interface input appropriately. (e.g. public)

  • MYSQL_SSL_CA_CERTIFICATE - Certificate of Authority (CA) for SSL
  • MYSQL_SSL_MASTER_CERTIFICATE - RSA Certificate for the Master-DB server
  • MYSQL_SSL_MASTER_KEY - RSA Key for the Master-DB server
  • MYSQL_SSL_SLAVE_CERTIFICATE - RSA Certificate for the Slave-DB server
  • MYSQL_SSL_SLAVE_KEY - RSA Key for the Slave-DB server

Steps

Upload the Database Dump File

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.

Add a Server

Follow these steps to add a database server to the deployment.

  1. Go to the MultiCloud Marketplace (Design MultiCloud Marketplace > ServerTemplates) and import the most recently published revision of the following ServerTemplate into the RightScale account. (Note: The following ServerTemplates were deprecated from the MultiCloud Marketplace and can no longer be imported.)​
    • Database Manager for MySQL 5.1 (v13.x)
    • Database Manager for MySQL 5.5 (v13.x)
  2. From the imported ServerTemplate's show page, click the Add Server button.
  3. Select the cloud for which you will configure a server. 
  4. Select the deployment for the new server.
  5. Next, the Add Server Assistant wizard will walk you through the remaining steps that are required to create a server based on the selected cloud.
    • Server Name - Provide a nickname for your new database server (e.g., mysql-db1). Do not include "master" or "slave" in the name, because a database server's role can change in the future.
    • Select the appropriate cloud-specific resources (e.g. SSH Key, Security Group, etc.) that are required in order to launch a server into the chosen cloud. The required cloud resources may differ depending on the type of cloud infrastructure. If the cloud supports multiple datacenters/zones, select a specific zone. Later, when you create the other database server you will use a different datacenter/zone to ensure high-availability. For more information, see Add Server Assistant.
    • Important! If you are not using volumes to store the database, you must select an instance type that has disk space that's at least twice as large as your database because LVM snapshots are performed locally on the instance before they are gzipped and saved to the specified ROS location. Also, although these ServerTemplates will work with any instance size, you may experience degraded performance with small instance sizes (such as EC2 micro, Rackspace 256MB etc) due to lack of system resources. We do not recommend smaller instance types for production use.
  6. Click Confirm, review the server's configuration and click Finish to create the server.

Configure Inputs

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.

  • Where will the contents of the database be stored?
    • On volumes attached to the instance.
    • On the local/ephemeral drive.
  • If you're using volumes, are you going to use a stripe?
    • Yes - Use a stripe of multiple volumes.
    • No - Use a single volume. 
    • INPUTS: Block Device Mount Directory (1), Nickname (1), Number of Volumes in the Stripe (1), Total Volume Size (1)
  • Are you building a master-slave database setup?
    • Yes
    • No
    • INPUTS: Database Master FQDN, Database Master DNS Record ID, Database Slave DNS Record ID, Database Replication Password, Database Replication Username
  • Will there be replication between master-slave database servers across different clouds/regions? If yes, you should set up SSL.
    • Yes
    • No
    • INPUTS: CA SSL Certificate, Master SSL Certificate, Master SSL Key, Slave SSL Certificate, Slave SSL Key
  • What are you going to use to take "primary" backups of the database?
    • Volume Snapshots
    • Binary Dumps to an ROS container (e.g. S3 bucket, Cloud Files container, etc.)
    • INPUTS: Primary Backup Secret (default), Primary Backup User (default), Primary Backup Storage Cloud (default), Primary Backup Storage Cloud Endpoint URL (default), Database Backup Lineage
  • Are you going to take "secondary" backups of the database? If yes, which ROS provider will you use?
    • Amazon S3, Rackspace Cloud Files (US or UK), Google Cloud Storage, Azure Blob Storage, Swift-based Storage, SoftLayer Object Storage
    • INPUTS: Secondary Backup Storage Cloud (default), Secondary Backup Secret (default), Secondary Backup User (default), Secondary Backup Storage Container (1), Secondary Backup Storage Cloud Endpoint URL (default), Secondary Backup Storage Container (2)
  • Which DNS provider are you using for dynamic DNS at the database level?
    • DNS Made Easy
    • DynDNS
    • Amazon Route 53
    • Rackspace Cloud DNS
    • INPUTS: DNS Service Provider, DNS Password, DNS User, Database Master FQDN, Database Master DNS Record ID, Database Slave DNS Record ID, Cloud DNS region

Set Inputs at the Deployment Level

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.

Block Device

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.

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.

  • Amazon S3 - AWS Secret Access Key (e.g. cred: AWS_SECRET_ACCESS_KEY)
  • Rackspace Cloud Files - Rackspace Account API Key (e.g. cred: RACKSPACE_AUTH_KEY)
  • Google Cloud Storage - Google Secret Access Key (e.g. cred: GOOGLE_SECRET_ACCESS_KEY)
  • Microsoft Azure Blob Storage - Microsoft Primary Access Key (e.g. cred: AZURE_PRIMARY_ACCESS_KEY)
  • Swift - OpenStack Object Storage (Swift) Account Password (e.g. SWIFT_ACCOUNT_PASSWORD)
  • HP - HP Secret Access Key (e.g. cred: HP_SECRET_ACCESS_KEY)
  • SoftLayer Object Storage - SoftLayer API Access Key (e.g. cred: SOFTLAYER_API_KEY)

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.

  • Amazon S3 - Amazon Access Key ID (e.g. cred: AWS_ACCESS_KEY_ID)
  • Rackspace Cloud Files - Rackspace login username (e.g. cred: RACKSPACE_USERNAME)
  • Google Cloud Storage - Google Access Key (e.g. cred: GOOGLE_ACCESS_KEY_ID)
  • Microsoft Azure Blob Storage - Azure Storage Account Name (e.g. cred: AZURE_ACCOUNT_NAME)
  • Swift - OpenStack Object Storage (Swift) Account ID (tenantID:username)  (e.g. SWIFT_ACCOUNT_ID)
  • HP - HP Object Storage Account ID (account number:tenantID) (e.g. cred: HP_ACCESS_KEY_ID)
  • SoftLayer Object Storage - Username of a SoftLayer user with API privileges (e.g. cred: SOFTLAYER_USER_ID)

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.

  • s3 - Amazon S3
  • Cloud_Files - Rackspace Cloud Files (United States)
  • Cloud_Files_UK - Rackspace Cloud Files (United Kingdom)
  • google - Google Cloud Storage
  • azure - Microsoft Azure Blob Storage
  • swift - OpenStack Object Storage (Swift)
  • hp - Hewlett Packard Cloud Object Storage
  • SoftLayer_Dallas - SoftLayer's Dallas (USA) cloud
  • SoftLayer_Singapore - SoftLayer's Singapore cloud
  • SoftLayer_Amsterdam - SoftLayer's Amsterdam cloud
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.

  • Amazon S3 - AWS Secret Access Key (e.g. cred: AWS_SECRET_ACCESS_KEY)
  • Rackspace Cloud Files - Rackspace Account API Key (e.g. cred: RACKSPACE_AUTH_KEY)
  • Google Cloud Storage - Google Secret Access Key (e.g. cred: GOOGLE_SECRET_ACCESS_KEY)
  • Microsoft Azure Blob Storage - Microsoft Primary Access Key (e.g. cred: AZURE_PRIMARY_ACCESS_KEY)
  • Swift - OpenStack Object Storage (Swift) Account Password (e.g. SWIFT_ACCOUNT_PASSWORD)
  • HP - HP Secret Access Key (e.g. cred: HP_SECRET_ACCESS_KEY)
  • SoftLayer Object Storage - SoftLayer API Access Key (e.g. cred: SOFTLAYER_API_KEY)
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.

  • Amazon S3 - Amazon Access Key ID (e.g. cred: AWS_ACCESS_KEY_ID)
  • Rackspace Cloud Files - Rackspace login username (e.g. cred: RACKSPACE_USERNAME)
  • Google Cloud Storage - Google Access Key (e.g. cred: GOOGLE_ACCESS_KEY_ID)
  • Microsoft Azure Blob Storage - Azure Storage Account Name (e.g. cred: AZURE_ACCOUNT_NAME)
  • Swift - OpenStack Object Storage (Swift) Account ID (tenantID:username)  (e.g. SWIFT_ACCOUNT_ID)
  • hp - HP Object Storage Account ID (account number:tenantID) (e.g. cred: HP_ACCESS_KEY_ID)
  • SoftLayer Object Storage - Username of a SoftLayer user with API privileges (e.g. cred: SOFTLAYER_USER_ID)
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.

  • CloudStack (for non-Xen hypervisors)
  • OpenStack
  • Rackspace Private
  • SoftLayer
  • HP Cloud
  • Rackspace (First Generation; not OpenCloud)

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.

  • s3 - Amazon S3
  • Cloud_Files - Rackspace Cloud Files (United States)
  • Cloud_Files_UK - Rackspace Cloud Files (United Kingdom)
  • google - Google Cloud Storage
  • azure - Microsoft Azure Blob Storage
  • swift - OpenStack Object Storage (Swift)
  • hp - Hewlett Packard Cloud Object Storage
  • SoftLayer_Dallas - SoftLayer's Dallas (USA) cloud
  • SoftLayer_Singapore - SoftLayer's Singapore cloud
  • SoftLayer_Amsterdam - SoftLayer's Amsterdam cloud

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.

  • Swift (OpenStack)

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.

  • Swift (OpenStack)

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

DB

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:

  • DNSMadeEasy: 1234567  (Dynamic DNS ID)
  • Route53: Z3DSDFSDFX:master-db.example.com
  • DynDNS: db-master.example.com
  • Cloud DNS: 3334445:A-1234567  (<Domain ID>:<Record ID>)
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.

  • private (default)
  • public
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.

  • false (default) - Slave verifies that there is a running master database server before it promotes itself to become the new master. The old master will become a slave of the new master after the promotion.
  • true - Slave will not check with the master before being promoted to assume the master role. If there is a running master database server, it will not become a slave of the new master after the promotion. You will not have database replication until a new slave database server is launched.
text: false

DB_MYSQL

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

SYS_DNS

Input Name Description Example Value
DNS Service Provider

Select the DNS provider that you used to create the DNS records for the database servers.

  • DNSMadeEasy
  • DynDNS
  • Route53 (Amazon Route 53)
  • CloudDNS
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.

  • DNSMadeEasy - DME Password
  • DynDNS - DynDNS Password
  • Amazon Route 53 - AWS Secret Access Key
  • Rackspace CloudDNS - Rackspace Password
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.

  • DNSMadeEasy - DME Username
  • DynDNS - DynDNS Username
  • Amazon Route 53 - AWS Access Key ID
  • Rackspace CloudDNS - Rackspace Username

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

Launch the Database Server

After configuring your inputs, launch your newly configured master database server.

  1. Go to the deployment's Servers tab and launch the database server. When you view the input confirmation page, there should not be any missing values (highlighted in red) for inputs that are required by any of the server's boot scripts. If there are any inputs highlighted in red, cancel the launch and add the missing values at the deployment level before launching the server again. Refer to the instructions in Launch a Server if you are not familiar with this process. Click the Launch (not 'Save and Launch') button at the bottom of the input confirmation page. 

Initialize the Master Database Server

Wait for the server to reach the "operational" state before you run a script to initialize the database server.

  1. Go to the "current" server's Scripts tab and run the db::do_init_and_become_master operational script to initialize it as the "Master" database server.
  2. (Optional) You can go to the "current" server's Audit Entries tab to track the status of the operation.


The script performs the following actions:

  • Registers it as the "master" database server and assign appropriate replication privileges and machine tags. (e.g. rs_dbrepl:master_instance_uuid=01-AVMV4MFHJQOK0 and rs_dbrepl:master_active=20130313200931-bob)
  • For cloud providers with volume support, it creates and mounts either a single volume or group of striped volumes for data storage.
  • Creates a database backup to primary storage.
  • Schedules a cron job to run backups to primary storage once every hour from a "slave" and once per day from the "master" server. A random time is chosen for taking the backups, however inputs are available for setting a specific time for backups. For example, you may want to make sure that the daily backup from the "master" server is taken at off-peak teams. (For information on modifying the default backup schedule, see the Database Manager for MySQL 5.1/5.5 Runbook.)
  • Updates the dynamic DNS record for the "Master" database with the DNS provider. The DNS record is updated with the server's IP address. By default, it will use the instance's private IP address (Database Replication Network Interface = private). The default TTL of the "master" DNS record must also be set to 60 seconds or less (Database DNS TTL Limit = 60) unless you are using Rackspace's Cloud DNS service, where the lowest allowable TTL is 300 seconds.

Disable Scheduled Primary Backups

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.

Set Up the Database

After initializing the master database server and disabling scheduled backups, you will need to add your database (or databases) and records to it.

  1. Go to the "current" server's Scripts tab and run the db::do_dump_import operational script to import a MySQL dump file from an ROS location.


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!
Be sure to record this value. You will need to specify this value again when you set up the application server tier so that they can connect to the correct database schema.

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.

  • Amazon S3 - Amazon Access Key ID (e.g. cred: AWS_ACCESS_KEY_ID)
  • Rackspace Cloud Files - Rackspace login username (e.g. cred: RACKSPACE_USERNAME)
  • Google Cloud Storage - Google Secret Access Key (e.g. cred: GOOGLE_ACCESS_KEY)
  • Microsoft Azure Blob Storage - Azure Storage Account Name (e.g. cred: AZURE_ACCOUNT_NAME)
  • Swift - OpenStack Object Storage (Swift) Account ID (tenantID:username)  (e.g. SWIFT_ACCOUNT_ID)
  • SoftLayer Object Storage - Username of a SoftLayer user with API privileges (e.g. cred: SOFTLAYER_USER_ID)

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.

  • Amazon S3 - AWS Secret Access Key (e.g. cred: AWS_SECRET_ACCESS_KEY)
  • Rackspace Cloud Files - Rackspace Account API Key (e.g. cred: RACKSPACE_AUTH_KEY)
  • Google Cloud Storage - Google Secret Access Key (e.g. cred: GOOGLE_SECRET_ACCESS_KEY)
  • Microsoft Azure Blob Storage - Microsoft Primary Access Key (e.g. cred: AZURE_PRIMARY_ACCESS_KEY)
  • Swift - OpenStack Object Storage (Swift) Account Password (e.g. SWIFT_ACCOUNT_PASSWORD)
  • SoftLayer Object Storage - SoftLayer API Access Key (e.g. cred: SOFTLAYER_API_KEY)

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.

  • s3 - Amazon S3 
  • Cloud_Files - Rackspace Cloud Files (United States)
  • Cloud_Files_UK - Rackspace Cloud Files (United Kingdom)
  • google - Google Cloud Storage
  • azure - Microsoft Azure Blob Storage
  • SoftLayer_Dallas - SoftLayer's Dallas (USA) cloud
  • SoftLayer_Singapore - SoftLayer's Singapore cloud
  • SoftLayer_Amsterdam - SoftLayer's Amsterdam cloud
text:  s3

Create a Primary Backup

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.

  1. Go to the "current" server's Scripts tab and run the db::do_primary_backup operational script to manually generate a primary backup of your database server.

Enable Scheduled Primary Backups

It is now safe to enable continuous backups of the database server.

  1. Go to the "current" server's Scripts tab and run the db::do_primary_backup_schedule_enable operational script.


For more information about configuring and modifying your scheduled backup policy, see the Database Manager for MySQL 5.1/5.5 Runbook.

Add a Slave Database Server

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.

  1. Clone the Master-DB server. See Clone a Server.
  2. Rename the server accordingly. (e.g. mysql-db2) Remember, you do not want to include the word "slave" in the nickname because this server may become the "master" server during a failover scenario. You don't want the server's nickname to potentially cause any confusion.
  3. Under the server's Info tab, click Edit and change the server's availability zone. In order to ensure high availability, it's strongly recommended that you launch the Slave-DB server in a different availability zone as the Master-DB.  Note: Cross-zone data transfer costs may apply.

Launch the Slave Database Server

Make sure the following conditions are true before you launch the second database server.

  • The master database server state is "operational."
  • The initial primary backup of the master database server is 100% complete. If you are using a cloud that supports snapshots for backups, you can track the status in the dashboard (Clouds > region > Snapshots). The time required to complete the initial primary backup will vary based on factors such as storage type, volume size, etc.


You are now ready to launch a "slave" database server for failover and redundancy purposes. 

  1. Go to the deployment's Servers tab and launch the server that will be the slave database server. 
  2. When you view the input confirmation page, change the value for the following input because you have an operational master database server an a completed database backup. 

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
  1. If there are any required inputs that are missing values (highlighted in red), cancel the launch and add the missing values at the deployment level before launching the server again. Refer to the instructions in Launch a Server if you are not familiar with this process.
  2. Click the Launch (not Save and Launch) button at the bottom of the input confirmation page because you do not want to override this input at the server level. You may not want this server to become a slave the next time it is launched or relaunched.

The scripts perform the following actions:

  • Assigns the "slave" role to the server.
  • Uses the most recently completed database backup (default) to initially populate the database in order to reduce the time needed for the slave to become in-sync with the master.
  • Sends a request to the master server to allow connections from the slave server's private IP address and opens the default MySQL client port (TCP port 3306) on the master server's firewall (i.e. iptables) for this purpose.
  • Schedules a cron job to run primary backups of the database once per hour (default). 

(Optional) Update the DNS Record for the Slave Database Server

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.

Test Database Setup (optional)

If you want to test the status of the "master" and "slave" database servers, see Check Database Status of Master or Slave.

 

You must to post a comment.
Last Modified
09:07, 6 May 2014

Page Rating

Was this article helpful?

Tags


Announcements

UCP Migration

Glossary | 用語용어 Site Map | Site Help Community Corporate Site Get Support Dashboard Login
Doc Feedback Product Feedback Resources MultiCloud Marketplace Forums

Dashboard Status


© 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.