Here we will introduce troubleshooting when garbled characters or errors occur in Using Amazon RDS as an External Master (AWS console) and Using Amazon RDS as an External Master (Terraform).

TOC

Cannot Connect to Database

If the following mysql command fails to connect to the database, check the database instance settings (public accessibility permittance, VPC security group settings):

mysql -h {ENDPOINT} -P {PORT NUMBER} -u {MASTER USERNAME} -p

Public Accessibility Permittance

First, let’s check the permission concerning public access. Select your database instance and check Public Accessibility on the Connectivity & security tab.

If Public accessibility is Yes you do not need to set it, so proceed to the next VPC security group settings. If it is No, click Modify at the top right.

Find the Network & Security block among the items whose settings can be changed, set Public accessibility to Yes and click Next.

Select Apply immediately in the Scheduling of modification and click Modify DB Instance.

VPC Security Group Settings

In case Public accessibility is Yes and you still can’t connect to the database, check your VPC security group settings.

Select your database instance and click the VPC security group displayed on the Connectivity & security tab.

Click Edit inbound rules on the Inbound rules tab.

Click Add Rule, select All Traffic, My IP, then click Save.

With the above settings you can now connect to the database using mysql command. Let’s try executing the command below again. (Enter the master password after the command.)

mysql -h {ENDPOINT} -P {PORT NUMBER} -u {MASTER USERNAME} -p

Characters Get Garbled

Unify the character code of the database to UTF-8 to prevent garbled characters.

Select Parameter Group from the left menu of Amazon RDS, and then click Create parameter group.

「Select DB Cluster Parameter Group in Type. Enter Group name (in this example, paramgroup-for-utf8) and Description, then click “Create”.

Click Edit Parameters for the parameter group you just created, set the following five parameters to utf8 and skip-character-set-client-handshake to 1, then click Save Changes.

Select the database cluster and click Modify.

Select the parameter group you created to DB cluster parameter group in the Additional configuration block and click Next.

Select Immediately in Scheduling of modifications and click Modify cluster.

Restart the database instance to apply the parameter group changes. Select the database instance then click Reboot in the Actions dropdown at the top right.

Let’s check the character code configuration, after waiting for a while for the completion of the database instance restart. Connect to your database and enter the following MySQL command consecutively to mysql> and execute:

show variables like 'char%';

It is good if the value of these variables, character_set_client, character_set_connection, character_set_database, character_set_results, and character_set_server is utf8 as shown below.

+--------------------------+--------------------------------------------------+
| Variable_name            | Value                                            |
+--------------------------+--------------------------------------------------+
| character_set_client     | utf8                                             |
| character_set_connection | utf8                                             |
| character_set_database   | utf8                                             |
| character_set_filesystem | binary                                           |
| character_set_results    | utf8                                             |
| character_set_server     | utf8                                             |
| character_set_system     | utf8                                             |
| character_sets_dir       | /rdsdbbin/oscar-5.6.10a.200340.0/share/charsets/ |
+--------------------------+--------------------------------------------------+

Lambda Function does not Run

You can check the execution log of the Lambda function in CloudWatch, an AWS service. Go to Log groups in the left menu, and select the created Lambda function to display the log.

If the error was due to a timeout, your Lambda function’s timeout setting could be too short. You can change the Lambda function timeout via the Edit button in the Basic Settings block.

Error in Terraform Execution (InsufficientStorageClusterCapacity)

When you execute terraform apply, you may get the following error:

Error: error creating RDS cluster: InsufficientStorageClusterCapacity: Couldn't create cluster: insufficient capacity in requested AZs

This error occurs when there is insufficient free space in the AZ (Availability Zone) of the specified region. This error can occur depending on the AWS resource status, regardless of the account settings. There are several ways to avoid this error:

  • Wait a while, and then try again (the shortage of space may be resolved)
  • Specify another AZ (rewrite the network.tf file)
  • Specify another region (rewrite the .tfvars file)

To specify a different AZ, firstly check the available AZs with the following command.

aws ec2 describe-availability-zones --region {REGION NAME (eg:ap-northeast-1)}

If you see only two AZs you cannot specify another AZ (Because the Terraform code has already specified both AZs). When three or more AZs are displayed, specifying the third and subsequent AZs in the following procedure may resolve the error.

At lines 33 and 40 of the network.tf the AZ name is specified. Rewrite the index of one or both AZ names to different numbers of 2 or more. For example, set one of the indexes to 2 as follows.

availability_zone       = data.aws_availability_zones.available.names[2]

After overwriting network.tf, please try executing terraform apply again.

1 thought on “Using Amazon RDS as an External Master (Troubleshooting)”

  1. Pingback: Using Amazon RDS as an External Master (AWS Console) – Questetra Support

Comments are closed.

%d bloggers like this: