Unable to start mongodb as a service - Exception; Collection does not have UUID in KVCatalog
The problem can be solved by:
- Backing-up all the databases (using
mongodump
) - Removing every file in
/data/db
, due to their incompatibility with the newer version:rm -rf /data/db/*
- Restarting the MongoDB service
- Restoring all the databases (using
mongorestore
)
I have met similiar problem with admin db, when upgrade from old mongodb 3.4 to 4.2.
Solution is to mongodump all dbs and delete /var/lib/mongodb, then mongorestore all dbs back.
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.users, terminating
2019-09-24T21:59:55.274+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-09-24T21:59:55.274+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-09-24T21:59:55.274+0000 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-09-24T21:59:55.274+0000 I CONTROL [initandlisten] now exiting
2019-09-24T21:59:55.274+0000 I CONTROL [initandlisten] shutting down with code:100
The cause of problem: mongodb 4.2 will add userId with UUID value in system.user collection. Hope this will help.
When upgrading another mongo db, I met the exact same problem as yours on startup_log, it seems I did not stop the mongodb when delete the /var/lib/mongodb folder, after stop mongod and delete the /var/lib/mongodb and upgrade to 4.2, error goes away.