我使用以下命令卸载了 mongo:
sudo apt-get purge mongodb-org
sudo apt-get autoremove
sudo rm /etc/apt/sources.list.d/mongodb.list
然后使用以下命令再次安装:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
sudo echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
我收到以下错误:
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mongod, action "start" failed.
dpkg: error processing package mongodb-org-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
我该如何解决这个问题?我想安装一个稳定版本的 Mongo。
答案1
以下是我为成功安装所执行的步骤:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
sudo rm /etc/apt/sources.list.d/mongodb-org*
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org=3.2.4 mongodb-org-server=3.2.4 mongodb-org-shell=3.2.4 mongodb-org-mongos=3.2.4 mongodb-org-tools=3.2.4
sudo mkdir /data/db
sudo chown -R mongodb:mongodb /data
编辑
/etc/mongod.conf
并更改dbPath
为/data/db
。编辑
/lib/systemd/system/mongod.service
:[Unit] Description= Documentation=man:mongod(1) After=network.target [Service] Type=forking User=mongodb Group=mongodb RuntimeDirectory=mongod PIDFile=/var/run/mongod/mongod.pid ExecStart=/usr/bin/mongod -f /etc/mongod.conf --pidfilepath /var/run/mongod/mongod.pid --fork TimeoutStopSec=5 KillMode=mixed [Install] WantedBy=multi-user.target
那么它就可以工作了。