- Overview - What is the mongodb module?
- Module Description - What does this module do?
- Setup - The basics of getting started with mongodb
- Usage - The class and defined types available for configuration
- Requirements
- Limitations - OS compatibility, etc.
- Contributing to the mongodb module
This module installs and makes basic configs for mongodb. That includes mongod and mongos. Out-of-the-box the defaults are set to install a mongodb version 2.4.x. If you want to use 2.6 see the setup examples below.
MongoDB, is an open-source document database, and the leading NoSQL database. This module can be used to set up a simple standalone DB or all components for a full sharding cluster.
What mongodb affects:
- repos/packages/services/basic configuration files for MongoDB
What mongodb NOT affects:
- internal configuration of your MongoDB cluster, like Sharding Members and so on
Starting with a mongodb server with replSet. This will install a 2.4.x version MongoDB:
include mongodb
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 50']
}
class { 'mongodb':
package_name => 'mongodb-org',
logdir => '/var/log/mongodb/',
# only debian like distros
old_servicename => 'mongod'
}
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 50']
}
Holy shit, I work in an enterprise environment. I need an specific version. So on a RHEL like system it would look like this:
# mongodb 2.6.x
class { 'mongodb':
package_name => 'mongodb-org',
package_ensure => '2.6.2-1',
logdir => '/var/log/mongodb/',
# only debian like distros
old_servicename => 'mongod'
}
# mongodb 2.4.x
class { 'mongodb':
package_ensure => '2.4.10-mongodb_1',
logdir => '/var/log/mongodb/'
}
Now we change the run as user and logdir path.
class { 'mongodb':
run_as_user => mongod,
run_as_group => wheel,
logdir => '/nfsshare/mymongologs/'
}
mongodb::mongod {
'my_mongod_instanceX':
mongod_instance => 'mongodb1',
mongod_replSet => 'mongoShard1',
mongod_add_options => ['slowms = 20']
}
And here is a more complex example of building a mongo sharding cluster 4 nodes (3 of them config server) with 4 shards in replication.
node mongo_sharding_default {
# Install MongoDB
include mongodb
# Install the MongoDB shard server
mongodb::mongod { 'mongod_Shard1':
mongod_instance => 'Shard1',
mongod_port => 27019,
mongod_replSet => 'Shard1',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard2':
mongod_instance => 'Shard2',
mongod_port => 27020,
mongod_replSet => 'Shard2',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard3':
mongod_instance => 'Shard3',
mongod_port => 27021,
mongod_replSet => 'Shard3',
mongod_shardsvr => 'true'
}
mongodb::mongod { 'mongod_Shard4':
mongod_instance => 'Shard4',
mongod_port => 27022,
mongod_replSet => 'Shard4',
mongod_shardsvr => 'true'
}
# Install the MongoDB Loadbalancer server
mongodb::mongos { 'mongos_shardproxy':
mongos_instance => 'mongoproxy',
mongos_port => 27017,
mongos_configServers => 'mongo1.my.domain:27018,mongo2.my.domain:27018,mongo3.my.domain:27018'
}
}
# This three nodes are shard members and run a mongoS
node 'mongo1.my.domain',
'mongo2.my.domain',
'mongo3.my.domain' inherits mongo_sharding_default {
# Install the MongoDB config server
include mongodb
mongodb::mongod { 'mongod_config':
mongod_instance => 'shardproxy',
mongod_port => 27018,
mongod_replSet => '',
mongod_configsvr => 'true'
}
}
# This node is just a shard member
node 'mongo4.my.domain' inherits mongo_sharding_default { }
This module installs mongodb from the repo with class mongodb
.
The redis service(s) are configured with the defined type redis::server
.
This class installs mongodb packages and makes basic install configurations.
It does not configure any mongo services. This is done by defined type
mongodb::mongod
and mongodb::mongos
.
Most global parameters are set in params.pp and should fit the most use cases. But you can also set them, when including class mongodb.
Parameters within mongodb
:
Default is '/var/lib' (string). This is the root directory where the mongo instances will create their own subdirectories.
Default is dbdir
.
Default on Redhat '/var/log/mongo' and on Debian '/var/log/mongodb'.
Number of days to keep the logfiles.
Default is 'installed' . Here you can choose the version to be installed.
Default is true (boolean). Choose if this module should manage the repos needed to install the mongodb packages.
Default is 64000 (integer). Number of allowed filehandles. See recommendations
Default is 64000 (integer). See recommendations
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). The user the mongod is run with.
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). The group the mongod is run with.
Default on Redhat is 'mongod' and on Debian 'mongodb' (string). Name of the origin mongodb package service. his will be deactivated.
Used to configure mongoD instances. You can setup multiple mongodb servers on the same node. See the setup examples.
**Parameters within mongodb::mongod
Despription of mongd service (shard1, config, etc) (required)
Default is '' (empty string). So listen in all.
Listen port (defaul: 27017)
Name of ReplSet (optional)
Enable/Disable service at boot (default: true)
Start/Stop service (default: true)
Is config server true/false (default: false)
Is shard server true/false (default: false)
Enable/Disable log file appending (default: true)
Enable/Disable REST api (default: true)
Enable/Disable fork of mongod process (default: true)
Enable/Disable auth true/false (default: false)
Keyfile contents. Your random string/false (default: false)
Select the database engine (default: wiredTiger)
Use monit monitoring for mongod instances (default: false)
Array. Each field is "key" or "key=value" for parameters for config file
Used to configure mongoS instances. You can setup multiple mongodb proxy servers on the same node. See the setup examples.
**Parameters within mongodb::mongos
Despription of mongd service (shard1, config, etc) (required)
Listen ip (defaul: emtpy, so listen in all)
Listen port (defaul: 27017)
String with comma seperated list of config servers (optional)
Enable/Disable service at boot (default: true)
Start/Stop service (default: true)
Enable/Disable log file appending (default: true)
Enable/Disable fork of mongod process (default: true)
Keyfile contents. Your random string/false (default: false)
Array. Each field is "key" or "key=value" for parameters for config file
- puppetlabs-stdlib
- yo61-logrotate
- puppetlabs-apt ( only for Debian/Ubuntu )
- facter > 1.6.2
- puppet > 2.6.2
On Redhat distributions you need the EPEL or RPMforge repository, because Graphite needs packages, which are not part of the default repos.
This module is tested on CentOS 6.5 and should also run without problems on
- RHEL/CentOS/Scientific 6+
- Debian 6+
- Ubunutu 10.04 and newer
Echocat modules are open projects. So if you want to make this module even better, you can contribute to this module on Github.