These instructions describe how to expose a MySQL database (running on an EC2 instance) to Syncari, using an internet-facing Network Load Balancer.
Prerequisites
- A VPC with an internet gateway attached
- A public subnet in this VPC that allows inbound TCP traffic on port 3306 and all outbound TCP traffic (via a security group)
- An EC2 instance running MySQL in the above VPC, with:
- MySQL listening on port 3306 (verify with
netstat -tlnp | grep 3306orss -tlnp | grep 3306) -
bind-addressinmy.cnfset to0.0.0.0(or the instance’s private IP), not127.0.0.1 - A MySQL user account configured to allow remote connections (e.g.,
'user'@'%') - The instance’s security group permitting inbound TCP on port 3306 from the NLB’s subnet CIDR (or from the security group used by the NLB)
- MySQL listening on port 3306 (verify with
Steps
- Note the private IP address of the EC2 instance hosting MySQL. You can find this in the EC2 Console under Instances → your instance → Details → Private IPv4 address.
- Create a new EC2 Target Group. Choose Instances as the target type (or IP addresses if you prefer to register by IP). Set the protocol to TCP and the port to 3306. Select the VPC from the prerequisites.
- Configure the health check to use TCP on port 3306.
- In the next step of target group creation, register the MySQL EC2 instance (or its private IP if you chose IP target type). Click the Include as pending below button under the Port section.
- Create the target group.
- Create a Network Load Balancer from EC2 → Load Balancers, selecting Internet-facing. Under Network mapping, choose the VPC and public subnet from the prerequisites.
- Choose the security group created in prerequisites (the one allowing inbound TCP on port 3306).
- Add a listener: change the protocol to TCP and the port to 3306.
- Select the target group created in the previous step in the Forward to target group configuration.
- Review and create the NLB.
Configuring the Syncari MySQL Synapse
Once the NLB is created you can use the DNS name shown on the details panel as the “Host name” configuration on the Syncari MySQL synapse. Reference the MySQL Setup article for the Synapse configuration steps.