In this tutorial I will show how to create multiple VMs automatically with CUBRID installed on each of them and have them configured in one HA group. I will tell you that with Vagrant and Chef Cookbook it is as easy as running vagrant up and waiting for 4-5 minutes until everything gets set up.

Requirements

Requirements are the same as in the first tutorial. Refer to it for details. In short, you need VirtualBox and Vagrant installed.

I have removed the comments this time so that you can see the real code more prominently.

Number of VMs

The first thing to take care in this scenario is to define how many VMs (hosts) we would like to run in this HA environment. No matter how many, each host will run an independent CUBRID Server node. Later all these hosts will join in one HA group and provide auto failover between themselves.

This means that we want Vagrant to build for us two VMs. The first VM should be distinguished by node1 name and should be assigned 10.11.12.13 IP address. The second VM will have a hostname node2 with an IP 10.11.12.14. In this example both hostname and IP are arbitrary, i.e. you can set your own, but you should remember to set IP within the same netmask (refer to Multiple Networks in Vagrant for details).

This is how you define the number of VMs to start up. The first VM which gets configured and started will become "master" in CUBRID HA, while other VM hosts will become "slaves".

VM memory size

In this example we set each VM to have 800MB RAM. This is enough, though you can set lower or higher values.

config.vm.customize "modifyvm", :id, "--memory", 800

If you need to have different memory on each VM, you can do so by specifying this same property when you define each VM.

Configure CUBRID HA

First of all, you need to add "cubrid::ha" recipe to have CUBRID HA configured.

Second, you need to provide a list of hosts and IPs which should join the same HA group. For this override ha_hosts attribute. These hosts and IPs must be identical to those you have defined for each VM above.

Then, optionally, you can override ha_dbs attribute by providing an array of database names to create and sync in HA. By default it will create one database called testdb.

Also, you can optionally override ha_group attribute which defaults to cubrid. This is the HA group all hosts will join. You can set any arbitrary value.

That is all you need to configure CUBRID HA. Now let's go and bring up CUBRID HA.

Vagrant Box

I will assume that you have already added precise64 (Ubuntu 12.04 LTS x64) Vagrant box. If you haven't, see the previous tutorial.

Start Up Vagrant

Run the following command to start Vagrant:

$ vagrant up

Wait some 4-5 minutes and you will have your VMs up and running in HA environment.

Test CUBRID HA

Validate CUBRID HA

Let's first validate and see if CUBRID HA has been properly configured.

Open SSH connection

For this we will open SSH connection and login to the first node1 VM. Remember, the first VM which got started becomes master while the rest become slaves.

Conclusion

In this tutorial you have learnt how to create multiple VMs automatically with CUBRID installed on each of them and have them configured in one HA group. As you can see, Vagrant along with Chef cookbook allow us to work with CUBRID Database and other software very easily. It is so much convenient and saves so much of our time. Now creating a development environment is no more painful.

Now as you know how to setup CUBRID HA environment, you can proceed to configuring CUBRID SHARD multi VM environment. Refer to: