Skip to content

Commit

Permalink
Recreated metadata.json and fixed syntax of the README.md files.
Browse files Browse the repository at this point in the history
also made some improvements to the Makefiles.
  • Loading branch information
Markus Korn committed Sep 2, 2011
1 parent 23e6523 commit dbf6ed0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 32 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ dist: clean
mkdir -p $(BUILD_DIR)
for i in $(DIRS); do make -C $$i $@; done

metadata.json:
for i in $(DIRS); do make -C $$i $@; done

clean:
-rm -r $(BUILD_DIR)
3 changes: 2 additions & 1 deletion mongodb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ clean:
-rm metadata.json
-rm $(DIST)

metadata.json: clean
metadata.json:
-rm $@
knife cookbook metadata -o .. $(COOKBOOK)

dist: clean metadata.json
Expand Down
70 changes: 40 additions & 30 deletions mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,95 @@ The cookbook aims to be platform independant, but is best tested on debian squez

# DEFINITIONS:

This cookbook contains a definition *mongodb_instance* which can be used to configure
This cookbook contains a definition `mongodb_instance` which can be used to configure
a certain type of mongodb instance, like the default mongodb or various components
of a sharded setup.

For examples see the USAGE section below.

# ATTRIBUTES:

* *mongodb[:dbpath]* - Location for mongodb data directory, defaults to "/var/lib/mongodb"
* *mongodb[:logpath]* - Path for the logfiles, default is "/var/log/mongodb"
* *mongodb[:port]* - Port the mongod listens on, default is 27017
* *mongodb[:client_role]* - Role identifing all external clients which should have access to a mongod instance
* *mongodb[:cluster_role_prefix]* - Name prefix for all roles used to identify
* `mongodb[:dbpath]` - Location for mongodb data directory, defaults to "/var/lib/mongodb"
* `mongodb[:logpath]` - Path for the logfiles, default is "/var/log/mongodb"
* `mongodb[:port]` - Port the mongod listens on, default is 27017
* `mongodb[:client_role]` - Role identifing all external clients which should have access to a mongod instance
* `mongodb[:cluster_role_prefix]` - Name prefix for all roles used to identify
all members of a mongodb cluster.
* *mongodb[:shard_name]* - Name of a shard, default is "default"
* *mongodb[:sharded_collections]* - Define which collections are sharded
* `mongodb[:shard_name]` - Name of a shard, default is "default"
* `mongodb[:sharded_collections]` - Define which collections are sharded

# USAGE:

To install and run a single mongodb instance, simply add

include_recipe "mongodb::default"
```ruby
include_recipe "mongodb::default"
```

to your recipe. This will run the mongodb instance as configured by your distribution.
By changing the dbpath, logpath and port settings (see ATTRIBUTES) for this node
you will be able to change this defaults.
If you would like to tweak more settings, simply use the *mongodb_instance*
If you would like to tweak more settings, simply use the `mongodb_instance`
definition, like

mongodb_instance "mongodb" do
port node['application']['port']
end
```ruby
mongodb_instance "mongodb" do
port node['application']['port']
end
```

This definition also allows you to run another mongod instance with a different
name on the same node

mongodb_instance "my_instance" do
port node['mongodb']['port'] + 100
dbpath "/data/"
end
```ruby
mongodb_instance "my_instance" do
port node['mongodb']['port'] + 100
dbpath "/data/"
end
```

The result is a new system service with

```shell
/etc/init.d/my_instance <start|stop|restart|status>
```

If you would like to add your mongodb instance to a replicaset all you have to
do is adding *mongodb::replicaset* to the node's run_list and make sure to add
do is adding `mongodb::replicaset` to the node's run_list and make sure to add
one ore more roles with the same prefix to all members of the replicaset. This
prefix has to be defined in *mongodb[:cluster_role_prefix]* . For example you
prefix has to be defined in `mongodb[:cluster_role_prefix]` . For example you
could create a role called "my_replicaset" and add this role to the run_list of
all nodes which should be in the replicaset. finally you only have to define
*mongodb[:cluster_role_prefix]* for all nodes in this cluster. This way they are
`mongodb[:cluster_role_prefix]` for all nodes in this cluster. This way they are
able to find each other.

Configure sharding is a bit more complicated, because you need a few more
components, but the idea is the same: identification of the members with their
different internal roles (mongos, configserver, etc.) is done via
*mongodb[:cluster_role_prefix]* and a *mongodb[:shard_name]*
`mongodb[:cluster_role_prefix]` and a `mongodb[:shard_name]`

Let's have a look at a simple sharding setup, consisting of two shard servers, one
config server and one mongos.

First we would like to configure the two shards. For doing so, just use
*mongodb::shard* in the node's run_list and define a unique *mongodb[:shard_name]*
`mongodb::shard` in the node's run_list and define a unique `mongodb[:shard_name]`
for each of these two nodes, say "shard1" and "shard2".

Then configure a node to act as a config server - by using the *mongodb::configserver*
Then configure a node to act as a config server - by using the `mongodb::configserver`
recipe.

And finally you need to configure the mongos. This can be done by using the
*mongodb::mongos* recipe. The mongos needs some special configuration, as these
`mongodb::mongos` recipe. The mongos needs some special configuration, as these
mongos are actually doing the configuration of the whole sharded cluster.
Most importantly you need to define a set of *mongodb[:sharded_collections]*
Most importantly you need to define a set of `mongodb[:sharded_collections]`
The value of this attribute should look like

{
"test.addressbook": "name",
"mydatabase.calendar": "date"
}
```javascript
{
"test.addressbook": "name",
"mydatabase.calendar": "date"
}
```

Now mongos will automatically enable sharding for the "test" and the "mydatabase"
database. Also the "addressbook" and the "calendar" collection will be sharded,
Expand All @@ -99,7 +109,7 @@ important to distinguish the different shards.

This is esp. important when you want to replicate shards. The setup is not much
different to the one described above. all you have to do is adding the
*mongodb::replicaset* recipe to all shard nodes, and make sure that all shard
`mongodb::replicaset` recipe to all shard nodes, and make sure that all shard
nodes which should be in the same replicaset have the same shard name.

# LICENSE and AUTHOR:
Expand Down
2 changes: 1 addition & 1 deletion mongodb/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
},
"maintainer": "edelight GmbH",
"long_description": "",
"version": "1.1.0",
"version": "0.9.0",
"recommendations": {
},
"recipes": {
Expand Down

0 comments on commit dbf6ed0

Please sign in to comment.