Issue
I have created a mongod configuration in /home/cluster1.conf
with the same port I used previously for etc/mongod.conf
.
I used to run etc/mongod.conf
as a sudo user but expect to run cluster1.conf
as user.
when I run cluster1.conf
as user, the process starts. I accessed it from mongo shell and did operations. But when I'm trying to access it from another vm from the same VPC, it failed.
I checked for systemctl status mongod
and it shows service is not running.
Why does systemctl status
shows it not running when it really does? How can I resolve this to create a replica set??
Solution
"when I run cluster1.conf
as user, the process starts." does not make much sense. cluster1.conf
is a configuration file, it does not start anything.
When you run systemctl status mongod
, then it typically shows
● mongod.service - MongoDB Database Server
Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2021-08-27 09:44:26 CEST; 2 weeks 3 days ago
Docs: https://docs.mongodb.org/manual
Main PID: 38710 (mongod)
Tasks: 28
Memory: 270.8M
CGroup: /system.slice/mongod.service
└─38710 /usr/bin/mongod -f /etc/mongod.conf
Check the service file /etc/systemd/system/mongod.service
there you see entry like
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
Which means, config file /etc/mongod.conf
is used (rather than /home/cluster1.conf
)
Answered By - Wernfried Domscheit