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

相关文章
相关标签/搜索