Using Google Cloud SQL with WSO2 Products

Image for post
Image for post

Cloud SQL is a fully-managed database service that makes it easy to set up, maintain, manage, and administer your relational databases on Google Cloud Platform. You can use Cloud SQL with either MySQL or PostgreSQL.

In this post, we will look into how we can configure Google Cloud SQL for WSO2 MB 3.0.0.

Below are the steps that you should follow.

  1. Navigate to https://cloud.google.com/
  2. You need to create an account here. You can register for a $300 account free for 12 months.
  3. Once the account is created, you need to create a project by navigating the below link.
  4. Once the project is created you will be navigated to a page like below.
Image for post
Image for post

5. Create a Google Cloud SQL instance by navigating to this link.

6. I’m creating a MySQL instance here. I’m choosing MySQL 5.6 version. You need to provide an instance id and root password.

Image for post
Image for post

7. You can connect to your instance using the mysql client in Cloud Shell by clicking click the Cloud Shell icon in the upper right corner. It will display

Login to the instance as below.

Configuring Google Cloud Instance

Once the MySQL instance is created, you can view the instance details as below.

Image for post
Image for post

You will get a public IP address. This is the IP that you should be providing in WSO2 configuration files in order to connect to the data source.

It needs to add the IP addresses which should be authorized to connect.

Go to the Connections tab in MySQL instance.

Image for post
Image for post

Go to Authorized networks under public IP.

Click on Add Network and you need to provide your public IP here.

Image for post
Image for post

Earlier we logged through the Cloud Shell. Now you can login to the MySQL instance using your local terminal as below.

Provide the password once the password is prompt.

Configuring WSO2 Message Broker to connect to Google Cloud SQL

  1. Download the WSO2MB-3.0.0 distribution from the product page.
  2. Extract the distribution and go to <PRODUCT-HOME>/repository/conf/datasources/master-datasources.xml file
  3. We can configure WSO2_MB_STORE_DB to use Google Cloud SQL as below.

4. Create databases in Google Cloud MySQL instance as below.

5. Now our database and the datasource configurations are ready. Copy the mysql connector jar(mysql-connector-java-5.1.44-bin.jar) to <PRODUCT_HOME>/repository/components/lib folder.

6. Start the carbon server.

Written by

Senior Software Engineer — QA at WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store