oh-ren / openshift-cartridge-mysql

Custom cartridge for OpenShift providing MySQL > 5.7.11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom MySQL cartridge for OpenShift

mysql-openshift

This is a custom OpenShift cartridge providing the latest MySQL version (5.7.11 as of February 27th 2016).

Why

Because the standard OpenShift MySQL cartridge is stuck at 5.5 and some people are keen to use the latest MySQL server features (such as improved support for spatial data).

When to use

When you need a quick and unsofisticated solution to run your application with the latest MySQL version.

Installing

To install this cartridge in your existing OpenShift application, go to "See the list of cartridges you can add", paste the URL below in "Install your own cartridge" textbox at the bottom of the page and click "Next".

http://cartreflect-claytondev.rhcloud.com/github/icflorescu/openshift-cartridge-mysql

Setting up

Once the cartridge is created and started, you can SSH into the database gear:

ssh gear-url

...and connect to the server with mysql client like this:

${OPENSHIFT_DATA_DIR}.mysql/bin/mysql --socket=${TMP}mysql.sock -u root

If you really need it, you can enable remote access for root like this (make sure to replace secret with a strong password):

${OPENSHIFT_DATA_DIR}.mysql/bin/mysql --socket=${TMP}mysql.sock -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION; FLUSH PRIVILEGES;"

If you're using multiple gears, here's how you can find the MySQL gear SSH url:

rhc app show application-name --gears

Once you've enabled remote access, you can use rhc port-forward and MySQL Workbench or your favorite client to connect from your development machine.

Use DB_HOST and DB_PORT environment variables to connect from an application running in the main web cartridge. For instance, here's how you'd do it in a Node.js application using Knex.js:

var knex = require('knex')({
  client: 'mysql',
  connection: {
    host     : process.env.DB_HOST,
    port:    : process.env.DB_PORT,
    user     : 'your_database_user',
    password : 'your_database_password',
    database : 'myapp_test'
  }
});

Notes

  • Can't guarantee this cartridge is production-ready. Some people use it though (on their own responsibility).
  • This is a lean cartridge. A standard MySQL installation takes a huge amount of space (over 1.5GB for MySQL 5.7.5). To save space, just the necessary MySQL binaries are installed.
  • In order to avoid an OpenShift configuration conflict, the server instance is listening on 13306 instead of the standard MySQL port 3306.
  • Don't hesitate to make a pull-request with an updated version in this file if you notice this cartridge version is behind the latest MySQL release.
  • Don't open issues in this repository to ask questions about rhc port-forward. Please refer to the OpenShift documentation to learn about it. I am not an employee of RedHat / OpenShift, nor do I have any form of consultancy agreement with them and the fact that I open-sourced this cartridge doesn't mean I'm willing to offer free advice on the subject. Pull-requests and suggestions are always welcome, though.

TODO

Update the install script when MySQL 5.7 final is released. OpenShift doesn't allow "5.7.7-rc" as version number in the cartridge manifest file, so right now I'm "manually" adding the "-rc" suffix in the install script.

Related

Since you're here, chances are you might also be interested in this custom Node.js cartridge or this custom MongoDB cartridge.

Credits and attributions

This cartridge was inspired by Ted Wennmark's blog post on how to create a minimal MySQL installation for an embedded system.

Credits

See contributors here.

If you find this repo useful, don't hesitate to give it a star and spread the word.

License

The ISC License.

About

Custom cartridge for OpenShift providing MySQL > 5.7.11

License:ISC License


Languages

Language:Shell 100.0%