解決方法:node
Most probably unit mongodb.service is masked. Use following command to unmask it. sudo systemctl unmask mongodb and re-run sudo service mongod start
1 vagrant@homestead:~$ sudo service mongod restart 2 Failed to restart mongod.service: Unit mongod.service not found. 3 vagrant@homestead:~$ ^C 4 vagrant@homestead:~$ sudo systemctl unmask mongodb 5 Removed symlink /etc/systemd/system/mongodb.service. 6 vagrant@homestead:~$ sudo service mongod start 7 vagrant@homestead:~$ sudo service mongod status 8 ● mongod.service - MongoDB Database Server 9 Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled) 10 Active: active (running) since Thu 2018-10-25 03:50:52 UTC; 5s ago 11 Docs: https://docs.mongodb.org/manual 12 Main PID: 6669 (mongod) 13 Tasks: 19 14 Memory: 37.9M 15 CPU: 85ms 16 CGroup: /system.slice/mongod.service 17 └─6669 /usr/bin/mongod --config /etc/mongod.conf 18 19 Oct 25 03:50:52 homestead systemd[1]: Started MongoDB Database Server. 20 Oct 25 03:50:52 homestead mongod[6669]: 2018-10-25T03:50:52.045+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 spe 21 lines 1-13/13 (END)
相關知識點:nginx
咱們的服務管理部分如何中止或禁用服務所看到的,但systemd
還具備自動或手動標記機做爲徹底沒法啓動,經過其連接到的能力/dev/null
。 這就是所謂的掩蔽單元,而且可能用mask
命令:mongodb
sudo systemctl mask nginx.service
這將防止Nginx服務自動或手動啓動,只要它被屏蔽。spa
若是選中list-unit-files
,你會看到該服務現已被列爲蒙面:vagrant
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 . . .
若是您嘗試啓動服務,您將看到以下所示的消息:rest
sudo systemctl start nginx.service
Failed to start nginx.service: Unit nginx.service is masked.
要再次揭露一個單元,使其能夠使用,只要使用unmask
命令:code
sudo systemctl unmask nginx.service
這將使單元返回到先前的狀態,容許它被啓動或啓用。blog