Getting Started with Radius for AWS RDS

Introducing the Radius for RDS Service!

We created Radius to help you save up to 80% on your monthly RDS bill. When running a production RDS database it is necessary to do so in a highly available manner. What this means is running multiple (and expensive) slave and read replica nodes in case the master RDS instance were to fail. These redundant instances spend 99.9% of their lives waiting for a failure to occur (and also facilitate seamless DB updates). This led us to take the decision to create our own HA solution for RDS which we call Radius. Radius integrates directly with RDS and provides a single interface to manage and create slave and read replica nodes that can run on Spot instances. Lets dive right in to the configuration!

Notes:

Spotinst Radius creates a standby instance and synchronously replicates the primary DB data to a different Availability Zone. Radius is currently only available for a multi-az RDS configuration for MySQL version 5.6 and above.

1.0 Update Spotinst Policy

Before you provision your first Radius instance, you will need to update your Spotinst IAM policy and add the relevant permissions
  1. Login to your AWS console and go to IAM console
  2. Open Spotinst policy and click Edit
  3. Add the below permissions:
"rds:DescribeDBInstances",
"rds:DescribeDBParameterGroups",
"rds:DescribeDBParameters",
"ec2:AllocateAddress",
"ec2:ReleaseAddress",
"lambda:InvokeFunction",
"lambda:ListFunctions",
"rds:DescribeDBInstances",
"rds:DescribeDBParameterGroups",
"rds:DescribeDBParameters",
"ec2:AllocateAddress",
"ec2:ReleaseAddress",
"route53:CreateHostedZone",
"route53:DeleteHostedZone",
"route53:ListHostedZones",
"route53:ChangeResourceRecordSets"

2.0 Create DB User

Create a user in your Master RDS with the following permissions:

CREATE USER 'USER_NAME'@'%' IDENTIFIED BY 'PASSOWRD';

GRANT EXECUTE, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'USER_NAME'@'%' IDENTIFIED BY 'PASSOWRD';

FLUSH privileges;

Please make sure that the user is open (and not private). MySQL syntax info can be found here: http://dev.mysql.com/doc/refman/5.7/en/grant.html

3.0 Create Read Replica

In order for Spotinst to replicate the data, you need to create a Read Replica instance from which we will copy the data.

  1. Login to AWS console and go to RDS console
  2. Click on the Master RDS you want to migrate to Radius
  3. Click on “Instance Actions” -> “Create Read Replica”

4.0 Configure Security Groups

Need to configure new security groups or modify an existing one to allow access between Radius to your RDS instances.

For RDS in public subnet:

  1. Security Group setting for Radius slave instance:
    1. Inbound :
      The inbound rule need to allow access only to your DB port. For example:
      ec2-management-console-2017-01-05-17-45-54
  2. Security Group setting for your RDS Master instance:
    1. Inbound:
      The inbound rule needs to allow access only to your DB port. For example:
      ec2-management-console-2017-01-05-17-45-54

For RDS in private subnet:

  1. Create a new security group without rules:
    screen-shot-2017-01-26-at-10-43-10-am
  2. Add an inbound rule only for this security group:
    screen-shot-2017-01-26-at-10-40-29-amMake sure that the security group in open to port 22 so that you will be able to SSH to the instance.
  3. Add the security group you just created to the Master RDS.

4.1 – For private subnet RDS only:

Launch the cloudformation stack.

This cloudformation will allow us to communicate with the EC2 instance.

  1. Login to AWS cloudforamtion and create a new stack: screen-shot-2017-01-26-at-10-50-07-am
  2. Select cloudformation template: Paste this URL: https://s3.amazonaws.com/multai/radius/mysql/cloudformation/templates/radius-cf-mysql-template.json
    screen-shot-2017-01-26-at-10-51-15-am
  3. Click next and specify your RDS details. In security groups insert the group you created in step 4 and click next.
  4. Add tags (if needed) and click next.
  5. Make sure that the checkbox “I acknowledge that AWS cloudformation might create IAM resources”. Click ‘create’.

5.0 Generate API token

  1. Click on the ellipses at the top right of the Spotinst console and click on “Settings”
    image-004
  2. Click on “API Zone” at the top of the screen
  3. Click on “API Tokens” and click on Generate to generate a new token. Provide a descriptive name like “radius token” and save the token string somewhere safe.
    auth-token

6.0 Create Radius!

  1. From your Spotinst console main screen, click on “Radius
  2. Click “Create
  3. Step 1: Validate
    1. Choose the Region of your RDS instance
    2. Choose your VPC
    3. Select RDS Master name from the drop-down list
    4. Select Read-replica
    5. Enter the username and password you for the DB user you just created in step 2.0
    6. For Private subnet only – select the Proxy type: Lambda and the function name
      screen-shot-2017-01-26-at-11-26-03-am
    7. Click “Validate” – Radius will validate the DB engine, existence of a read replica, connectivity to the master, and DB permissionsscreen-shot-2017-02-21-at-4-26-56-pmscreen-shot-2017-02-21-at-4-57-45-pm
  4. Step 2: Configure
    1. Name of the Radius
    2. On-Demand instance type (we will use this instance type in case Spot is not available)
    3. Spot instance type (you can choose multiple instance types. Out of them Radius will choose the best market to launch)
    4. Choose your instance Key pair
    5. Select the Availability Zones and subnets
    6. Enter the personal access token from step 5
  5. Step 3Launch
    In the last step of the wizard, click on “Launch” to create your Radius instance. You can follow the creation process to make sure all resources are being created successfully. In the case of a failure, you will see the exact error message and try you launch the Radius again.

7.0 Replicate Data

Now that you have your Radius instance live and running, we need to replicate and copy the data from the Read Replica instance

  1. SSH to your Radius instance
    image-103
  2. Run sudo su- Command
  3. Run init-radius command
    Enter Master RDS User password

8.0 Connecting to your Radius Instance

You can now go into your Radius instance by logging into your Spotinst console. The DNS name will appear at the top of the screen and you can now connect to your Radius Database instance.
image-110

That’s it! Your new Radius instance is up and running and saving your up to 80% on your RDS spend for the replica instance. 

 

Yours,
The Spotinst Team.