Mongodb 安装错误汇总

  1. Failed to restart mongod.service: Unit mongod.service not found.

解决方法:

Most probably unit mongodb.service is masked. Use following command to unmask it.

sudo systemctl unmask mongodb

and re-run

sudo service mongod start
 vagrant@homestead:~$ sudo service mongod restart
Failed to restart mongod.service: Unit mongod.service not found.
vagrant@homestead:~$ ^C
vagrant@homestead:~$ sudo systemctl unmask mongodb
Removed symlink /etc/systemd/system/mongodb.service.
vagrant@homestead:~$ sudo service mongod start
vagrant@homestead:~$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Thu -- :: UTC; 5s ago
Docs: https://docs.mongodb.org/manual
Main PID: (mongod)
Tasks:
Memory: 37.9M
CPU: 85ms
CGroup: /system.slice/mongod.service
└─ /usr/bin/mongod --config /etc/mongod.conf Oct :: homestead systemd[]: Started MongoDB Database Server.
Oct :: homestead mongod[]: --25T03::52.045+ I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 spe
lines -/ (END)

相关知识点:

屏蔽和取消屏蔽单位

我们的服务管理部分如何停止或禁用服务所看到的,但systemd还具有自动或手动标记机作为完全无法启动,通过其链接到的能力/dev/null 。 这就是所谓的掩蔽单元,并且可能用mask命令:

sudo systemctl mask nginx.service

这将防止Nginx服务自动或手动启动,只要它被屏蔽。

如果选中list-unit-files ,你会看到该服务现已被列为蒙面:

systemctl list-unit-files
. . .

kmod-static-nodes.service              static
ldconfig.service static
mandb.service static
messagebus.service static
nginx.service masked
quotaon.service static
rc-local.service static
rdisc.service disabled
rescue.service static . . .

如果您尝试启动服务,您将看到如下所示的消息:

sudo systemctl start nginx.service
Failed to start nginx.service: Unit nginx.service is masked.

要再次揭露一个单元,使其可以使用,只要使用unmask命令:

sudo systemctl unmask nginx.service

这将使单元返回到先前的状态,允许它被启动或启用。

上一篇:使用Typescript重构axios(五)——实现基础功能:处理请求的header


下一篇:使用Typescript重构axios(二十)——请求取消功能:实现第一种使用方式