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

如题所述

方法/步骤

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 start3月 22 17:06:00 hxb mongod[3740]: initctl: 无法连接到 Upstart: Failed to connect to so3月 22 17:06:00 hxb mongod[3740]: Since the script you are attempting to invoke h3月 22 17:06:00 hxb mongod[3740]: Upstart job, you may also use the start(8) util3月 22 17:06:00 hxb mongod[3740]: start: 无法连接到 Upstart: Failed to connect to sock3月 22 17:06:00 hxb systemd[1]: mongod.service: Control process exited, code=exit3月 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
5
检查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)
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网