如何解决MongoDB启动时无法连接到Upstart的错误

来源:互联网 发布:mac os 系统修复 编辑:程序博客网 时间:2024/05/29 16:31
在Ubuntu 16.04 TLS系统上安装MongoDB,安装完成后使用service mongod start命令启动mongoDB失败,提示无法连接到Upstar的异常。
 
MongoDB启动异常重现
在使用如下命令启动MongoDB服务:
$ sudo service mongod start
系统提示如下错误信息:
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
 
查看MongoDB服务启动失败的原因
使用如下命令查看:
$journalctl -xe
可以看到详细的错误信息:
hxb@hxb:~$ journalctl -xe
-- Subject: mongod.service 单元已开始启动
-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- -- mongod.service 单元已开始启动。
3月 22 17:06:00 hxb mongod[3740]: Rather than invoking init scripts through /etc/
3月 22 17:06:00 hxb mongod[3740]: utility, e.g. service mongod start
3月 22 17:06:00 hxb mongod[3740]: initctl: 无法连接到 Upstart: Failed to connect to so
3月 22 17:06:00 hxb mongod[3740]: Since the script you are attempting to invoke h
3月 22 17:06:00 hxb mongod[3740]: Upstart job, you may also use the start(8) util
3月 22 17:06:00 hxb mongod[3740]: start: 无法连接到 Upstart: Failed to connect to sock
3月 22 17:06:00 hxb systemd[1]: mongod.service: Control process exited, code=exit
3月 22 17:06:00 hxb systemd[1]: Failed to start mongod.service.-- Subject: mongod.service 单元已失败
-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel--
 
解决无法连接到 Upstart的错误
使用如下命令:
hxb@hxb:~$ sudo dpkg-divert --local --rename --add /sbin/initctl正在添加 本地转移 /sbin/initctl 到 /sbin/initctl.
distribhxb@hxb:~$ ln -s /bin/true /sbin/initctlln: 无法创建符号链接'/sbin/initctl': 权限不够
hxb@hxb:~$ sudo ln -s /bin/true /sbin/initctl
 
重新启动MongoDB服务
使用如下命令:
hxb@hxb:~$ sudo service mongod start
 
检查MongoDB服务启动状态
使用如下命令:
hxb@hxb:~$ sudo service mongod status
mongod.service
Loaded: loaded (/etc/init.d/mongod; bad; vendor preset: enabled)
Active: active (exited) since 三 2017-03-22 17:11:12 CST; 7s ago
Docs: man:systemd-sysv-generator(8)
 
阅读全文
1 0
原创粉丝点击