Config File

Config File

To enable shard, you need to create a file named shards.yml in your config directory inside your rails application. If you want to use octopus in a plain ruby application, create a folder named config, and put the file inside them. The shards.yml file should looks like this:

In this example, you have one shard for each environment, named shard_one. This is a example of a config file using rails, when you have a shard for development, and another for production. You also need to specify what environments octopus will runs, with the ‘environments’ tag. All configs should start with the ‘octopus’ tag. The difference stays when you have an application that isn’t running rails, so octopus will assume that you don’t have shards for environments, like this example:

If Octopus finds the directive replicated: true, it will assume all shards as slaves, and the database specified in database.yml as master database. By default, octopus will assume `fully_replicated` to be `true`. So, if you don’t want to send all write queries to master, and all reads queries to slaves, you need to disable with the following line:

If you have some shards specified inside a group, octopus will see them as normal slaves.

Octopus also supports different shards that runs on different databases, like if you have a PostgreSQL Shard, and the master database is MySQL, no problem, Octopus will handle this for you ;-), just specify in the config file and all will work: