一、安装
1.sudo vim /etc/apt/sources.list ,and include the following line:
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
2.sudo apt-get update
3.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
4.sudo apt-get install mongodb-10gen
5. Post-Installation
Now, MongoDB is installed, started, and auto start MongoDB script is generated to “/etc/init/mongo” and
“/etc/init.d/mongo“. In addition, all MongoDB files are copied to “/usr/bin” folder.
/etc/mongodb.conf文件默认配置:
dbpath=/var/lib/mongodb logpath=/var/log/mongodb/mongodb.log logappend=true #port = 27017
表示数据库文件存放在/var/lib/mongodb
二、启动
安装后会随系统自动启动,可以执行重启(但有我的系统start,stop,restart均有问题尚未有解决办法,只能重启这个ubuntu系统)
sudo service mongodb restart
三、修复:
mongod --repair
sudo rm /var/lib/mongodb/mongodb.lock