Join Lynn Langit for an in-depth discussion in this video Exploring MongoDB Labs, part of NoSQL for SQL Professionals.
- View Offline
- To start our tour of Cloud based document NoSQL databases, we'll take a look at the Google implementation or a Google implementation. If I click on API Project and I drill into, and I'll close some of these other, so we can see. Compute, actually close Compute Engine. You can see under Compute we have a new category, relatively new for this Cloud service, it's called Click toDeploy and the idea is similar to the Amazon AMI or Amazon Machine Images where you have pre-built images with different types of services.
In our case NoSQL databases pre-installed that make it easy for you to just click to deploy basically. So under the Google Developer console here I'm just going to scroll down and you can see that if wanted to spin up MongoDB on a Google compute engine instance we would just click Go and then it shows us their particular setup here. Where we have a Primary, and we have a Secondary, and then we have this other node that helps with leader election. Then if we scroll down we pick the zone, the MongoDB version, how many server nodes, machine type, the type of disk, SSD or Standard Persistent, the data size, and the Arbiter, the guy who makes the decision as to who's the leader basically.
Notice, we have a More down here. So we can set some other properties around the replica set which has to do with how replication is handled on Mongo and really it's a one click to spin it up. There's details about it inside of here. Now this might work for you if you're on the Google Cloud already and you just want to add some instances, in Mongo it might be quick and easy for you, but I wanted to show you some alternatives that I've used in production, in addition to the big three. Microsoft you would have to build your own image, as far as I understand.
They don't have any pre-built image. So Amazon has a pre-built image, Google has a pre-built image. Of course, you could just set up compute engine on multiple instances and set this clustering up yourself but that would kind of defeat the purpose of some of the management being done for you. That being said, for a partially managed solution I often use MongoLab. I've signed into the MongoLab site. You can see my sign in up here and what I can now do is click the Create new button. The next thing that I need to do is look at the Cloud providers and I have a choice of Amazon, Google, Rackspace, or Windows Azure, and from each provider I have a subsequent choice of which location.
So you can see for Amazon I have the different regions. If I click on the Google Cloud, I have a different one region here. Rackspace I have one, two regions. Azure I have a couple of regions. Then within the Cloud provider, under Region, I have the ability to set up a Single-node and I can do a Sandbox for free, which I'm going to do or I can do a Replica set cluster. So this allows for MongoLab to provide some of the cluster management for you and this is a way of up leveling the database replica set so that they're managing the up time and the availability so that you can just get your data into it.
Of course you are paying them for that. So for demonstration I'm just going to go to Single-node and I'm going to set up a Sandbox. Then I'm going to scroll down. Notice you select the version number. Right now we're just on 2.6 and I'm going to call this one testlynda and I'm going create a new deployment. So what this is doing is on the Amazon Cloud it is allocating EC2 Virtual Machines with MongoDB and in this case I believe it's only one and here I have my Sandbox.
So inside of here, if I open this up, they provide me with a little GUI that i can work with to work a little bit more on this database. So if I click on it i can either use the MongoDB shell or I can connect using a URI, or I can use this GUI interface to just test things out. Now you might remember that NoSQL databases have a concept of collections rather than tables and the data that they store is JSON data.
So if I click Add Collection and I say testcollection and I have some advanced options here, I could reallocate the size and I could set a size cap. Then I say Create. That's going to create my collection. Now inside of my collection I have no documents. Collections are containers for documents and documents are JSON documents. Notice there is a collection of indexes that comes by default. I click into the collection itself and here I could work with documents from this GUI.
I can add a document and you can see it's giving me the JSON here, so I'm just going to copy and paste. They'll actually be a JSON formatting correction that I need to make in order for this to go in properly because you'll see if I say, Create and continue editing, it gives me a JSON Error. So it tells me I need to have double quotes around the field names and values. So here's my field names.
I'm going to just put double quotes and I'm going to Create and continue editing. Notice, MongoDB added a unique identifier here. Now there's lots of optimizations that you can and will do around MongoDB data because of the format. One of the optimizations that many Mongo customers do, for example, is they change the identifier to something that's a little bit more concise. Another set of optimizations is around the querying of data.
So if I click back into my database you can now see in my testcollection that I have one document. Now when you're working with these manage services it's really a question of you start generally with a small, single or a couple of nodes, and then you will expand based on your needs. And the best way to understand that is to look at the Plans & Features. You can see that you get to pick your Cloud and then you look at what your needs are.
Whether they're shared or dedicated and if you're going to have multiple nodes or how many nodes and how much size. So it's a nice alternative to regular hosted NoSQL to have this more managed NoSQL, if you will, if you don't have an administrator on site and you do have a need for mission critical NoSQL implementation.
- What is NoSQL?
- What is Hadoop?
- Exploring Redis, HBase, MongoDB, and Neo4j
- Exploring NoSQL features in Microsoft SQL Server
- Working with NoSQL data in the cloud
- Applying NoSQL choices to business scenarios
- Considering how data will be input and output at your business