A simple guide to deploying MySQL Router with MySQL Database service in OCI

MySQL Database service in Oracle Cloud Infrastructure (OCI) are highly secure. We can’t connect directly to the MySQL endpoints stated in the console through a public network. To connect to MySQL Database service in OCI, we can either connect from within an OCI tenancy or establish a VPN or FastConnect and connect from other cloud service provider or on-premises location with the subnet security list allowing the configured port of the MySQL database.

Sometimes an application needs to connect to MySQL Database service in a location where you can’t implement a VPN or Fast Connect. In this case, you can configure MySQL Router as the public endpoint to connect to your private MySQL database. MySQL Router is a lightweight middleware that provides transparent routing between application and backend MySQL servers. It provides high availability and scalability by routing database traffic to appropriate backend MySQL servers.

Installing and configuring MySQL Router

To install MySQL Router, To deploy MySQL Router as basic connection routing, or refer to the following simple three-step setup.
1. Prepare a connection config file. Allow access from MySQL Router public subnet to MySQL Database service private subnet port 3306.

$ vi /home/opc/mysqlrouter/mysqlrouter-config.conf

[logger]

level = INFO

[routing:primary]

bind_address = localhost

bind_port = 7001

destinations = 10.0.1.108:3306

routing_strategy = first-available

2. Start MySQL Router.

$ sudo nohup mysqlrouter –config=/home/opc/mysqlrouter/mysqlrouter-config.conf &

3. Connect to your MySQL database through the local host endpoint using following command:

$ mysql -u root -P 7001 –protocol=TCP -p

Summary

With MySQL router installed in a public facing virtual machine, you can easily connect your application to Oracle Cloud Infrastructure MySQL Database service without a VPN or Fast Connect.


Categories

Leave a Reply

Your email address will not be published. Required fields are marked *