I installed Ubuntu14.04 on the virtual machine VirtualBox and then encountered an error while deploying MongoDB.
Environment:
- System: Ubuntu (AMD64 server version) on VirtualBox, memory 256MB, dual core CPU.
- HDD: 8GB ext4 File System (. VDI), already used 64.5%
- Internet connection is OK, software source has been updated
Problem:
When installing Mongo-server
$ sudo apt-get install Mongodb-server
After that, the MongoDB service cannot be started
$ sudo service MongoDB start #why error?
Restart the virtual machine multiple times, delete the configuration file and reload Mongo-server multiple times
$ sudo apt-get remove–purge mongodb-server
$ sudo apt-get install Mongodb-server
Invalid.
Analysis:
Check the configuration file/etc/mongodb.conf, according to the information to trace to several directories, suspicious error items are:
- Insufficient space, prompt to use--smallfiles parameter
- Log directory permissions are insufficient, Access denied
The adjustment is still more cumbersome.
Attempt to manually start the Mongod process, reporting the error of space and permissions
$ mongod–f/etc/mongodb.conf #权限错误
$ sudo mongod–f/etc/mongodb.conf #空间不够
Looking at/etc/group and/etc/passwd, there are already mongodb-related items that indicate that the MONGODB account has been established.
Weigh:
The right to modify the default log directory and data files directly still may cause problems. Don't want to tangle on the level of directory permissions. by/etc/passwd know, MongoDB's hometown in/home/mongodb, then let it go back to the hometown.
Method:
Build MongoDB's home, and give it property
$ sudo mkdir–p/home/mongodb
$ sudo chown mongodb:mongodb/home/mongodb
Adjust profile, point to home, add parameter
$sudo vim/etc/mongodb.conf
...
Dbpath=/home/mongodb
Logpath=/home/mongodb/mongo.log
Smallfiles=true
...
Restart again. After this adjustment, MongoDB services have been properly maintained
$ sudo service MongoDB [start|restart|status]
Copyright notice: This article by Llorch in CSDN debut, Creative Commons,by+sa. Reprint needs to retain the author's name and source, after the amendment should be issued in accordance with this license.
MongoDB Configuration in Ubuntu14.04