Using MySQL on Openshift - Red Hat's public cloud

No comments
Developing a prototype, I found myself wanting a trustworthy cloud provider. Having heard of Openshift, I got my hands on it. It's Red Hat's Platform as a Service. With it, you can host and scale applications in a cloud environment. As a developer I found some wonderful features on the quite generous free tier. The ones I'd like to highlight are that:

  • It's based on a gear and cartridge concept that abstracts container provisioning.
  • Application deployment through Git, updating the application with each push to the remote repo. 

Cartridges are what provide the run-time for each of the supporting technologies. Remote access is through a Web console and a dedicated SSH client (RHC). For the purpose of this post, we'll go through the following scenario:
1. Creating a new application on Openshift
2. Deploying the MySQL gear
3. Deploy the phpMyAdmin gear
4. Accessing phpMyAdmin to manage the database instance
5. Port forwarding to attach a local machine MySQL administration software
For the first step, you'll first have to:
After successfully finishing the pre-requisites, you can create a new application, called "mysqllab" for our MySQL scenario, with the PHP programming language specified using the following command:
C:\mysqllab> rhc app create mysqllab php-5.4 
It will create the application with the PHP cartdrige. OpenShift provides a wide range of languages and services, deployed in applications through a cartridge. Cartridges can be web frameworks, databases, monitoring services, or connectors to external backends:
On the following step, we'll provision the MySQL gear, to provide a database server for our scenario. To add it to the "mysqllab" application, use the command:
C:\mysqllab> rhc cartridge add mysql-5.5 -a mysqllab
After the database gear creation, you're presented with the database credentials information. You can also access those credentials at any time using the Web console:
Having the database server up and running, we'll provision the phpMyAdmin cartridge:
C:\mysqllab> rhc cartridge add phpmyadmin -a mysqllab
Going over to the Web console, our gears are presented on the application. You can open phpMyAdmin from the popout link. The username and password are the same as the database credentials:
And there you have it, a MySQL instance working on Red Hat PaaS cloud:
You can save the phpMyAdmin cartridge if you forward the MySQL port and use your local admin software to attach and manage the database server. To perform port forwarding, enter on the the command line:
C:\mysqllab> rhc port-forward -a mysqllab
Afterwards, try connecting your usual DBA tool. While the command prompt window is open, the ports are forwarded to and from the local host:
If you need some help to get things going and go deeper into Red Hat's cloud platform, I recommend the book  Learning OpenShift.

No comments :

Post a Comment