summaryrefslogtreecommitdiff
path: root/README
blob: 801e7a271cc6668e40c49e3d6ce6028bbda6b4d1 (plain)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 
Introduction ============ MongoDB is a high-performance, open source, schema-free document-oriented data store that's easy to deploy, manage and use. It's network accessible, written in C++ and offers the following features: 1. Collection oriented storage - easy storage of object-style data 1. Full index support, including on inner objects 2. Query profiling 3. Replication and fail-over support 4. Efficient storage of binary data including large objects (e.g. videos) 5. Auto-sharding for cloud-level scalability (Q209) High performance, scalability, and reasonable depth of functionality are the goals for the project. This is a metapackage that depends on all the mongodb parts. Installation ============ Get the charm-tools and bzr packages 1. sudo add-apt-repository ppa:juju/pkgs 2. sudo apt-get update 3. sudo apt-get install charm-tools bzr Set up the charm ================ 1. mkdir -p ~/tmp/juju/charms/oneiric 2. cd ~/tmp/juju/charms/oneiric 3. charm get mongodb Review the configurable options =============================== The MongoDB charm allows for certain values to be configurable via the config.yaml file. A sample of the default settings of the config.yaml file at the time of writing are as follows: options: dbpath: default: "/var/lib/mongodb" type: string description: The path where the data files will be kept. logpath: default: "/var/log/mongodb/mongodb.log" type: string description: The path where to send log data. logappend: default: True type: boolean description: Append log entries to existing log file bind_ip: default: "all" type: string description: IP address that mongodb should listen for connections. port: default: 27017 type: int description: Default MongoDB port journal: default: True type: boolean description: Enable journaling, http://www.mongodb.org/display/DOCS/Journaling cpu: default: False type: boolean description: Enables periodic logging of CPU utilization and I/O wait auth: default: False type: boolean description: Turn on/off security verbose: default: False type: boolean description: Verbose logging output objcheck: default: False type: boolean description: Inspect all client data for validity on receipt (useful for developing drivers) quota: default: False type: boolean description: Enable db quota management diaglog: default: 0 type: int description: Set oplogging level where n is 0=off (default), 1=W, 2=R, 3=both, 7=W+some reads nocursors: default: False type: boolean description: Diagnostic/debugging option nohints: default: False type: boolean description: Ignore query hints noscripting: default: False type: boolean description: Turns off server-side scripting. This will result in greatly limited functionality notablescan: default: False type: boolean description: Turns off table scans. Any query that would do a table scan fails noprealloc: default: False type: boolean description: Disable data file preallocation nssize: default: "default" type: string description: Specify .ns file size for new databases mms-token: default: "disabled" type: string description: Accout token for Mongo monitoring server mms-name: default: "disabled" type: string description: Server name for Mongo monitoring server mms-interval: default: "disabled" type: string description: Ping interval for Mongo monitoring server ( in number of seconds ) autoresync: default: False type: boolean description: Automatically resync if slave data is stale oplogSize: default: "default" type: string description: Custom size for replication operation log opIdMem: default: "default" type: string description: Size limit for in-memory storage of op ids replicaset: default: myset type: string description: Name of the replica set web_admin_ui: default: True type: boolean description: Replica Set Admin UI ( accessible via default_port + 1000 ) replicaset_master: default: auto type: string description: Replica Set master ( optional ). Possible values are 'auto' for automatic detection based on install time or 'host:port' to connect to 'host' on 'port' and register as a member. master: default: "self" type: string description: Who is the master DB. If not "self", put the Master DB here as "host:port" config_server_port: default: 27019 type: int description: Port number to use for the config-server config_server_dbpath: default: "/mnt/var/lib/mongodb/configsvr" type: string description: The path where the config server data files will be kept. config_server_logpath: default: "/mnt/var/log/mongodb/configsvr.log" type: string description: The path where to send config server log data. arbiter: default: "disabled" type: string description: Enable arbiter mode. Possible values are 'disabled' for no arbiter, 'enable' to become an arbiter or 'host:port' to declare another host as an arbiter. replicaset_master must be set for this option to work. mongos_logpath: default: "/mnt/var/log/mongodb/mongos.log" type: string description: The path where to send log data from the mongo router. mongos_port: default: 27021 type: int description: Port number to use for the mongo router extra_config_options: default: "none" type: string description: Extra options ( comma separated ) to be included ( at the end ) in the mongodb.conf file. extra_daemon_options: default: "none" type: string description: Extra options ( exactly as you would type them in the command line ) to be added via the command line to the mongodb daemon Where: 1. replicaset - ie: myreplicaset - Each replicaset has a unique name to distinguish it’s members from other replicasets available in the network. - The default value of myset should be fine for most single cluster scenarios. 2. web_admin_ui - MongoDB comes with a basic but very informative web user interface that provides health and status information on the database node as well as the cluster. - The default value of yes will start the Admin web UI on port 28017. 3. replicaset_master - If this node is going to be joining an existing replicaset, you can specify a member of that cluster ( preferably the master node ) so we can join the existing replicaset. - The value should be in the form of host[:port] - ie: hostname ( will connect to hostname on the default port of 27017 ) - ie: hostname:port ( will connect to hostname on port number <port> ) Most of the options in config.yaml have been modeled after the default configuration file for mongodb (normally in /etc/mongodb.conf) and should be familiar to most mongodb admins. Each option in this charm have a brief description of what it does. Deployment ========== Single Node ----------- Deploy the first MongoDB instance 1. cd ~/tmp/juju/charms 2. juju deploy --repository . local:oneiric/mongodb 3. juju expose mongodb Replica Sets ------------ Deploy the first MongoDB instance 1. cd ~/tmp/juju/charms 2. juju deploy --repository . local:oneiric/mongodb 3. juju expose mongodb Your deployment should look similar to this ( juju status ): machines: 0: dns-name: ec2-50-19-46-207.compute-1.amazonaws.com instance-id: i-3817fc5a instance-state: running state: running 1: dns-name: ec2-50-17-73-255.compute-1.amazonaws.com instance-id: i-90c822f2 instance-state: running state: running services: mongodb: charm: local:oneiric/mongodb-17 exposed: true relations: replica-set: mongodb units: mongodb/0: machine: 1 open-ports: - 27017/tcp - 28017/tcp public-address: ec2-50-17-73-255.compute-1.amazonaws.com relations: replica-set: state: up state: started In addition, the MongoDB web interface should also be accessible via the services’ public-address and port 28017 ( ie: http://ec2-50-17-73-255.compute-1.amazonaws.com:28017 ). (Optional)Change the replicaset name ------------------------------------ 1. juju set mongodb replicaset=<new_replicaset_name> Add one more nodes to your replicaset ------------------------------------- 1. juju add-unit mongodb Add multiple nodes to your replicaset ------------------------------------- 1. juju add-unit mongodb -n5 We now have a working MongoDB replica-set. Sharding -------- According the the mongodb documentation found on their website (http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/), one way of deploying a Shard Cluster is as follows: - deploy config servers - deploy a mongo shell (mongos) - deploy shards - connect the config servers to the mongo shell - add the shards to the mongo shell Using Juju we can deploy a sharded cluster using the following commands: - Bootstrap the environment --- juju bootstrap - Config Servers ( we'll deploy 3 of them ) --- juju deploy mongodb configsvr - Mongo Shell ( We just deploy one for now ) --- juju deploy mongodb mongos - Shards ( We'll deploy three replica-sets ) --- juju deploy mongodb shard1 -n3 --- juju deploy mongodb shard2 -n3 --- juju deploy mongodb shard3 -n3 - Connect the Config Servers to the Mongo shell (mongos) --- juju add-relation mongos:mongos configsvr:configsvr - Connect each Shard to the Mongo shell (mongos) --- juju add-realtion mongos:mongos shard1:database --- juju add-realtion mongos:mongos shard2:database --- juju add-realtion mongos:mongos shard3:database With the above commands, we should now have a three replica-set sharded cluster running. Using the default configuration, here are some details of our sharded cluster: - mongos is running on port 27021 - configsvr is running on port 27019 - the shards are running on the default mongodb port of 27017 - The web admin is turned on by default and accessible with your browser on port 28017 on each of the shards. To verify that your sharded cluster is running, connect to the mongo shell and run sh.status(): - mongo --host <mongos_host>:<mongos_port> - run sh.status() You should see your the hosts for your shards in the status output. Troubleshooting =============== 1. If your master/slave/replicaset deployment is not updating correctly, check the log files at /var/log/mongodb/mongodb.log to see if there is an obvious reason ( port not open etc.). 2. Ensure that TCP port 27017 is accessible from all of the nodes in the deployment. 3. If you are trying to access your MongoDB instance from outside your deployment, ensure that the service has been exposed ( juju expose mongodb ) 4. Make sure that the mongod process is running ( ps -ef | grep mongo ). 5. Try restarting the database ( restart mongodb ) 6. If all else fails, remove the data directory on the slave ( rm -fr /var/log/mongodb/data/* ) and restart the mongodb-slave daemon ( restart mongodb ). 7. The MongoDB website ( http://www.mongodb.org ) has a very good documentation section ( http://www.mongodb.org/display/DOCS/Home )