martedì 1 dicembre 2015

Google compute engine: Setup virtual machine with postgresql and ruby

Yesterday a friend of mine send me a link to the new Google Cloud Platform and, after a few lines, I decided that I should give it a try.
As an amazon aws user I feel comfortable with all the terms about virtual machines instances, sql support, data storing and so on, simply speaking is like the amazon aws but on google servers (I know is not like this but just for make things clear).

So with what I could begin? The simplest thing will be create virtual machine and hosting a simple website with postgresql installed on it. Quite easy no? Well it is until you try to install postgresql and it fails without a clear reason or maybe the reason is here under your eyes but you need a little tweak to make it work.

You can find a tutorial on how to do it here [1] but at the end of the setup process the server can't start due tu a missing locale settings.
The simple things you have to do is install the default locale on your system with this simple command:

sudo apt-get install language-pack-[lang]-base
where lang is you default locale.

If you do this command before the postgresql installation when you install it you'll have no error and you have a working installation.

If you do this after the postgresql installation the startup script will complain about missing default cluster.
Now just type:

pg_createcluster 9.3 main --start

To create the default cluster and then your server is up & running.