Production considerations – Mongo and xDB part four

There’s a massive amount of information regarding Mongo in production. The topic can get quite complex in a short space of time too, so I’ve attempted to distil some of it down into a manageable chunk. Whenever we think of moving to production we think of user security, network security, capacity or resource usage and allowing the system to scale. There are other topics too but this is a good place to start as the rest can be specific to each environment you’re working in.

Continue reading

Making backups and importing data – Mongo and xDB part three

There are a few ways you can make a backup with Mongo. The most simple is to take a copy of the database files and put them somewhere safe. This is made easier if you’ve put each database into its own directory. However, this is a pretty naive method as you will have to stop the server and restart it. You also will be taking a full backup. That said, this method does have its uses in a scenario where you are messing around with a secondary but that’s beyond the scope of this short post.

Its possible to extend this a little by using mongodump against the file system. The tool will lock the files so the database cannot be in use at the time but it at least provides a binary export of the data.

For a developer scenario, its more likely that we’ll be using mongodump, mongorestore, mongoimport and mongoexport against our running database. We may need some data from a co-worker or from the live system or we may be the provider of some data to another member of our team.

Continue reading

Securing and navigating around xDB – Mongo and xDB part two

Peeking around

There are a number of options for navigating your way around Mongo. Depending on what you’re most comfortable with, you may prefer using command line tools and batch files or you may prefer GUI tools like RoboMongo, MongoChef or MongoVue. That said, for the more complex operations you’ll have to be comfortable with the command line tools unless you’re hosting with a third party.

The Mongo eco-system is based on a Javascript ‘shell’. This means that all functions, loops and the like follow the normal Javascript syntax rules. It also means that reading any custom functions and profile scripts should be easy for anyone who is familiar with Javascript for web development. Before we continue and look at some simple operations, its useful to repeat some Mongo definitions. Naturally these are all available on the Mongo documentation website so I’ll be brief:

  • Database – the same concept as in a relational product like Sql Server.
  • Collection – similar to a table but doesn’t have a schema
  • Document – a record in a collection.
  • Index – the same concept as in a relational product

When we want to insert data into Mongo, we create a new document and add it to a collection. Mongo also allows us to embed one document inside another which can be useful but does require some care when constructing queries and designing indexes. Once we have some documents, we can pull them out using queries (as you’d expect). These queries can have a bit of a ‘linq’ feel to them due to the use of the Javascript shell. Here’s an example:

use myusertable
db.users.find({"Country": "New Zealand"}).sort( { "Surname": 1, "Firstname": 1 } )

Continue reading

Getting started – Mongo and xDB part one

With the release of Sitecore 7.5 we saw the introduction of NoSQL to the Sitecore ecosystem. Sitecores platform of choice is MongoDB, an open source document database that runs as a separate server. MongoDB stores all of its data as memory mapped files in a format very similar to JSON (called BSON).

By default, Sitecore Analytics now requires both SQL Server and MongoDB to operate. MongoDB provides much of the data capture and storage and SQL Server the aggregation of that data. Additionally, the ECM and WFFM for Sitecore 7.5 now also use the xDB platform and so also use MongoDB by default.

Its worth knowing this as any implementation of Sitecore 7.5 (or an upgrade to it) will need the infrastructure to support a Mongo installation. Reading through the xDB documentation, it isn’t immediately clear what is required of an xDB infrastructure and it does require quite a bit of background reading. This first post, of a series, is intended to give you a background in some of the items you’ll need to be aware of and also how this relates to Sitecore.

Continue reading