I was testing the repair option on what was essential an empty database that had been created using an older version of mongoDB.
Sun Jun 13 14:18:45 Mongo DB : starting : pid = 3697 port =
27017 dbpath = /var/lib/mongodb master = 0 slave = 0 64-bit
Sun Jun 13 14:18:45 ****
Sun Jun 13 14:18:45 ****
Sun Jun 13 14:18:45 need to upgrade database admin with
pdfile version 4.5, new version: 4.5
Sun Jun 13 14:18:45 starting upgrade
Sun Jun 13 14:18:45
admin repairDatabase admin
Sun Jun 13 14:18:45 allocating new datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.ns, filling with zeroes...
Sun Jun 13 14:18:45 done allocating datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.ns, size: 16MB, took 0.006 secs
Sun Jun 13 14:18:45 allocating new datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.0, filling with zeroes...
Sun Jun 13 14:18:45 done allocating datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.0, size: 64MB, took 0.026 secs
Sun Jun 13 14:18:45 allocating new datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.1, filling with zeroes...
Sun Jun 13 14:18:45 building new index on { _id: 1 } for
admin.system.users
Sun Jun 13 14:18:45 Buildindex admin.system.users idxNo:0 {
name: "_id_", ns: "admin.system.users", key: { _id: 1 } }
Sun Jun 13 14:18:45 done for 0 records 0secs
Sun Jun 13 14:18:45 done allocating datafile
/var/lib/mongodb/$tmp_repairDatabase_0/admin.1, size: 128MB, took 0.052 secs
Sun Jun 13 14:18:45 finished checking dbs
Sun Jun 13 14:18:45
dbexit:
Sun Jun 13 14:18:45 shutdown: going to close listening
sockets...
Sun Jun 13 14:18:45 shutdown: going to flush oplog...
Sun Jun 13 14:18:45 shutdown: going to close sockets...
Sun Jun 13 14:18:45 shutdown: waiting for fs preallocator...
Sun Jun 13 14:18:45 shutdown: closing all files...
Sun Jun 13 14:18:45 closeAllFiles() finished
Sun Jun 13 14:18:45 shutdown: removing fs lock...
Sun Jun 13 14:18:45
dbexit: really exiting now
all looked good again
However when I started up the dbserver again, it would not start, complaining that the admin database files could not be found.
On investigation i discovered that the admin files had been placed in /var/lib/mongodb/ and not in /var/lib/mongodb/admin
moving them from the root to the ./admin directory solved the problem and the database server started up fine again.
It looks like there is an inconsistent use of the --directoryperdb default option between mongod and mongod --repair
I have checked the upstart files and its just using the /etc/mongodb.conf which does not specify this option.
Any Ideas?
/etc/mongodb.conf
# mongodb.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
#port = 27017
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
rest =true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0
# Diagnostic/debugging option
#nocursors = true
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
# Slave only: specify a single database to replicate
# or
#master = true
# Address of a server to pair with.
#pairwith = <server:port>
# Address of arbiter server.
#arbiter = <server:port>
# Automatically resync if slave data is stale
#autoresync
# Custom size for replication operation log.
#oplogSize = <MB>
# Size limit for in-memory storage of op ids.
#opIdMem = <bytes>