升级MongoDB至2.6后出现ClientCursorMonitor异常,服务无法启动
Hey there, let's work through fixing your MongoDB startup problem after that unexpected upgrade from 2.4.10 to 2.6.10 when you updated Ubuntu packages. I'll break this down into actionable steps based on the clues you gave (space issues + auth changes in 2.6).
First, let's get the complete error details because truncated logs only tell part of the story. Run one of these commands depending on your Ubuntu version:
- For systemd-based Ubuntu (16.04+):
journalctl -u mongod -n 50 - For older Ubuntu (upstart):
cat /var/log/mongodb/mongod.log | tail -50
This will show you the exact failure reason—whether it's still space-related, auth-related, or something else.
smallFiles configuration is working You added smallFiles:true to fix the space issue, but let's make sure it's set up correctly for MongoDB 2.6:
- Open your MongoDB config file (usually
/etc/mongodb.confor/etc/mongod.conf):sudo nano /etc/mongodb.conf - Look for the
smallFilesline—make sure it's not commented out (no#at the start) and is set totrue. For 2.6, this is a top-level option, not nested in astorageblock (that came later in 3.x+). - Check that your disk actually has enough space now:
The data directory should have at least a few hundred MB free for MongoDB to start.df -h /var/lib/mongodb
MongoDB 2.6 introduced SCRAM-SHA-1 as the default auth mechanism, but it still supports the old MONGODB-CR from 2.4. However, there are a few gotchas that can break startup:
- If you had users created in the
admindatabase in 2.4, 2.6 might have trouble loading them if the credentials aren't upgraded. - If your application is still using the old auth method, you might need to adjust either the app or the MongoDB user credentials.
Here's how to troubleshoot this:
- Temporarily disable auth to start MongoDB:
- Edit your config file again, find the
auth=trueline, comment it out (add a#at the start) or change it toauth=false. - Save the file and try starting MongoDB:
sudo service mongodb start
- Edit your config file again, find the
- If it starts, upgrade your user credentials:
- Open the MongoDB shell:
mongo - Switch to the admin database:
use admin - List all existing users to see which need upgrading:
db.system.users.find().pretty() - Upgrade each user to the 2.6-compatible format (this converts their password hash to work with both old and new auth mechanisms):
Repeat this for every user in thedb.adminCommand({upgradeUser: "your-username-here"})admindatabase.
- Open the MongoDB shell:
- Re-enable auth and restart:
- Go back to your config file, uncomment/set
auth=trueagain. - Restart MongoDB:
sudo service mongodb restart
- Go back to your config file, uncomment/set
Sometimes package updates can mess with file ownership. Make sure MongoDB has access to its data and log directories:
- Check data directory permissions:
It should showls -ld /var/lib/mongodbmongodb:mongodbas the owner. If not, fix it:sudo chown -R mongodb:mongodb /var/lib/mongodb - Do the same for the log directory:
sudo chown -R mongodb:mongodb /var/log/mongodb
Once you've worked through these steps, your MongoDB should start up properly. If you hit a specific error in the logs, feel free to share that and we can dig deeper.
内容的提问来源于stack exchange,提问作者noobie

