Ubuntu安裝MongoDB

第一次接觸mongo,記錄在安裝mongo的過程當中的踩坑過程mongodb

執行下面的命令安裝mongo,在啓動時,報錯。shell

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
apt-get update
apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
service mongod start

報錯信息以下ubuntu

Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.

命令行輸入journalctl -xe查看詳細的錯誤信息socket

1月 30 16:03:11 yang mongod[10520]: utility, e.g. service mongod start
1月 30 16:03:11 yang mongod[10520]: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
1月 30 16:03:11 yang mongod[10520]: Since the script you are attempting to invoke has been converted to an
1月 30 16:03:11 yang mongod[10520]: Upstart job, you may also use the start(8) utility, e.g. start mongod
1月 30 16:03:11 yang mongod[10520]: start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
1月 30 16:03:11 yang systemd[1]: mongod.service: Control process exited, code=exited status=1
1月 30 16:03:11 yang systemd[1]: Failed to start mongod.service.
-- Subject: Unit mongod.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mongod.service has failed.
-- 
-- The result is failed.
1月 30 16:03:11 yang systemd[1]: mongod.service: Unit entered failed state.
1月 30 16:03:11 yang systemd[1]: mongod.service: Failed with result 'exit-code'

發現致使啓動失敗的緣由是.net

Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused

經過百度找到了解決的方法命令行

命令行輸入下面兩條命令,mongo就能夠正常啓動了。code

sudo dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

雖然mongo啓動成功了,可是上面兩條命令作了哪些事情,是什麼意思?經過百度,我找到了下面的一片博客http://blog.csdn.net/quqi99/article/details/45100933  這篇博客基本能解決個人疑問。server

相關文章
相關標籤/搜索