Clustering in Trove

This is also implemented by the use of strategies, but unlike in the case of replication that is a guest agent strategy alone, the strategy for clustering comprises a strategy for trove-api, trove-taskmanager, and trove-guestagent.

This is due to the contrast among different database engines in the way they implement clustering. Having said that, Trove in this case also is purely an enabler and the database engine itself has to support clustering for Trove to even consider implementing a strategy.

Supported data store

The Juno release brought clustering to MongoDB, and now with the current release, we have clustering enabled for the following data stores and the associated actions that are supported:

Data store name

Cluster actions supported

MongoDB

Create/add shards/grow/shrink/delete

PXC

Create/delete/grow/shrink

Redis

Create/delete

Vertica

Create/delete

As we can see, MongoDB has more features when it comes to clustering in Trove compared to its counterparts; we will use that to test clustering.

Note

Please remember that we don't have a MongoDB image, so we either create our own like shown in the previous chapters, or we can download the image from the Tarballs site. Please remember that the IP range needs to be 10.0.0.0/24 if we need to use images downloaded from the website.

Since we don't have the image, we will use DIB to create a new image using the following command. Please remember to export the variables before running the command (as shown in Chapter 5, Provisioning Database Instances).

Creating and uploading the MongoDB image

The command to build the MongoDB image is shown as follows:

cd /opt/stack

diskimage-builder/bin/disk-image-create -a i386 
-o /home/alokas/images/ubuntu_mongo/ubuntu_mongodb -x 
--qemu-img-options compat=0.10 ubuntu vm heat-cfntools  
cloud-init-datasources ubuntu-guest ubuntu-mongodb

We will then upload the image to Glance.

glance image-create --name mongodb --disk-format qcow2 
 --container-format bare 
 --visibility public 
 --file /home/alokas/images/ubuntu_mongo/ubuntu_mongodb.qcow2

We will have to note down the ID of the image in the output of the previous command. We will then create the data store and the data store version.

trove-manage datastore_update mongodb ''

trove-manage datastore_version_update mongodb 2.4.9 
 mongodb 0b446ab8-5c35-44eb-902c-d3b040d03296 mongodb 1

Once the MongoDB image is ready, we will need to create a suitable flavor for MongoDB, which we can do by executing the command nova flavor-create by passing the flavor ID (please ensure the flavor ID is not already taken by using the command nova flavor-list. In this case, we have used 6 as that was not used; we specify the RAM to be 1024 MB or 1 GB and 4 GB disk).

nova flavor-create mongodb.f1 6 1024 4 1
Creating and uploading the MongoDB image

Creating a cluster

Understanding the sharded clustering concepts in MongoDB is beyond the scope of this book; however, from a very basic point of view, the MongoDB cluster has three components:

  • Replica sets
  • Configuration servers
  • Query routers

The replica sets are a group of MongoDB processes that keep the same information (replication that we discussed earlier). The query router is used to route the queries to appropriate replica sets/shards. The configuration server stores the metadata for the shards.

The reason it is recommended to have an odd number of servers in a replica set is that we will always have voting ability and will be able to elect a primary node.

A simplified diagram to show the whole process of clustering is next. The replicated set keep the data replicated among themselves and the query router and the configuration server directs the query to the correct node. Please note that with a single replica set, there is no sharding shown in the diagram.

Creating a cluster

We can then create the MongoDB three-node cluster using the following command:

trove cluster-create mongo-cl --datastore mongodb 
--datastore_version 2.4.9 
--instance flavor_id=6,volume=4 
--instance flavor_id=6,volume=4 
--instance flavor_id=6,volume=4 

Note

Please note that the MongoDB cluster needs a minimum of three nodes (to ensure the replicated set has the ability to elect a master). At the time of writing this book, only a three-node cluster is supported. However, in the future, a three, five, or seven-node cluster may be supported.

Please note that the cluster is not viewable by the generic trove list command. In order to view the cluster, we have to execute the trove cluster-list command and see that the cluster is created. The cluster is considered ready for use, when the Task Name in the cluster-list output task is set to NONE as shown in the following screenshot:

Creating a cluster

In order to see the cluster members, we use the command trove cluster-instance <ClusterName>. So, in our case, the command will be:

trove cluster-instance mongo-cl
Creating a cluster

The configuration server and query router are also spun up, which should be seen in the output of the nova list command.

Creating a cluster
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.162.201