Database Reference
In-Depth Information
you specify the --logpath option when running it in the background. But there are a
few extra settings to be aware of. To enable verbose logging, start the mongod process
with the -vvvvv option (the more v 's, the more verbose the output). This is handy if,
for instance, you need to debug some code and want to log every query. But do be
aware that verbose logging will make your logs quite large and may affect server
performance.
Next you can start mongod with the --logappend option. This will append to an
existing log rather than overwriting it.
Finally, if you have a long-running MongoDB process, you may want to write a
script that periodically rotates the log files. MongoDB provides the logrotate com-
mand for this purpose. Here's how to run it from the shell:
> use admin
> db.runCommand({logrotate: 1})
Sending the SIGUSR1 signal to the process also runs the logrotate command. Here's
how to send that signal to process number 12345:
$ kill -SIGUSR1 12345
10.2.2
Monitoring tools
Here I describe the monitoring commands and tools that ship with MongoDB.
D ATABASE COMMANDS
Three database commands reveal MongoDB's internal state. These underlie all
MongoDB monitoring applications.
serverStatus
The output to the serverStatus command is a veritable embarrassment of riches.
Among the statistics tracked are page faults, B-tree access rates, open connections,
and total inserts, updates, queries, and deletes. An abridged sample of the server-
Status command output is shown next:
> use admin
> db.runCommand({serverStatus: 1})
{
"host" : "ubuntu",
"version" : "1.8.0",
"process" : "mongod",
"uptime" : 246562,
"localTime" : ISODate("2011-03-13T17:01:37.189Z"),
"globalLock" : {
"totalTime" : 246561699894,
"lockTime" : 243,
"ratio" : 9.855545289656455e-10,
"currentQueue" : {
"total" : 0,
"readers" : 0,
"writers" : 0
},
},
Search WWH ::




Custom Search