1

MongoDb run fine with the default settings.

The issue occurs when I change the default log path in cat /etc/mongod.conf to the below:

systemLog: destination: file logAppend: true path: /var/www/logs/mongodb/mongod.log 

Below are my steps to install and start mongod

While the installation shows successful mongod fails to start after log path update in the /etc/mongod.conf.

cat /etc/yum.repos.d/mongodb-org.repo

[mongodb-org-6.0] name=MongoDB Repository #baseurl=https://repo.mongodb.org/yum/redhat//mongodb-org/6.0/x86_64/ baseurl=https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/6.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc 

#Script to install and run mongod

echo "Installing mongodb" sudo yum install -y mongodb-org mkdir -p "$log_location/mongodb" sudo systemctl start mongod echo "Status mongodb" sudo systemctl status mongod --no-pager 

Output:

Installing mongodb MongoDB Repository 5.8 kB/s | 9.4 kB 00:01 Package mongodb-org-4.0.28-1.el8.x86_64 is already installed. Dependencies resolved. ========================================================================================================================================================================================= Package Architecture Version Repository Size ========================================================================================================================================================================================= Upgrading: mongodb-org x86_64 6.0.1-1.el8 mongodb-org-6.0 11 k mongodb-org-tools x86_64 6.0.1-1.el8 mongodb-org-6.0 11 k Installing dependencies: cyrus-sasl x86_64 2.1.27-6.el8_5 baseos 96 k mongodb-database-tools x86_64 100.6.0-1 mongodb-org-6.0 48 M mongodb-mongosh x86_64 1.5.4-1.el8 mongodb-org-6.0 41 M mongodb-org-database x86_64 6.0.1-1.el8 mongodb-org-6.0 11 k mongodb-org-database-tools-extra x86_64 6.0.1-1.el8 mongodb-org-6.0 16 k Transaction Summary ========================================================================================================================================================================================= Install 5 Packages Upgrade 2 Packages Total download size: 89 M Downloading Packages: (1/7): mongodb-mongosh-1.5.4.x86_64.rpm 51 MB/s | 41 MB 00:00 (2/7): mongodb-database-tools-100.6.0.x86_64.rpm 50 MB/s | 48 MB 00:00 (3/7): mongodb-org-database-6.0.1-1.el8.x86_64.rpm 43 kB/s | 11 kB 00:00 (4/7): mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64.rpm 66 kB/s | 16 kB 00:00 (5/7): mongodb-org-6.0.1-1.el8.x86_64.rpm 44 kB/s | 11 kB 00:00 (6/7): mongodb-org-tools-6.0.1-1.el8.x86_64.rpm 41 kB/s | 11 kB 00:00 (7/7): cyrus-sasl-2.1.27-6.el8_5.x86_64.rpm 6.5 kB/s | 96 kB 00:14 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 5.8 MB/s | 89 MB 00:15 MongoDB Repository 660 B/s | 1.7 kB 00:02 Importing GPG key 0x64C3C388: Userid : "MongoDB 6.0 Release Signing Key <[email protected]>" Fingerprint: 39BD 841E 4BE5 FB19 5A65 400E 6A26 B1AE 64C3 C388 From : https://www.mongodb.org/static/pgp/server-6.0.asc Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64 1/9 Installing : mongodb-org-database-6.0.1-1.el8.x86_64 2/9 Installing : mongodb-mongosh-1.5.4-1.el8.x86_64 3/9 Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64 4/9 Installing : cyrus-sasl-2.1.27-6.el8_5.x86_64 4/9 Running scriptlet: cyrus-sasl-2.1.27-6.el8_5.x86_64 4/9 Running scriptlet: mongodb-database-tools-100.6.0-1.x86_64 5/9 Installing : mongodb-database-tools-100.6.0-1.x86_64 5/9 Running scriptlet: mongodb-database-tools-100.6.0-1.x86_64 5/9 Upgrading : mongodb-org-tools-6.0.1-1.el8.x86_64 6/9 Upgrading : mongodb-org-6.0.1-1.el8.x86_64 7/9 Cleanup : mongodb-org-4.0.28-1.el8.x86_64 8/9 Cleanup : mongodb-org-tools-4.0.28-1.el8.x86_64 9/9 Running scriptlet: mongodb-org-tools-4.0.28-1.el8.x86_64 9/9 Verifying : cyrus-sasl-2.1.27-6.el8_5.x86_64 1/9 Verifying : mongodb-database-tools-100.6.0-1.x86_64 2/9 Verifying : mongodb-mongosh-1.5.4-1.el8.x86_64 3/9 Verifying : mongodb-org-database-6.0.1-1.el8.x86_64 4/9 Verifying : mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64 5/9 Verifying : mongodb-org-6.0.1-1.el8.x86_64 6/9 Verifying : mongodb-org-4.0.28-1.el8.x86_64 7/9 Verifying : mongodb-org-tools-6.0.1-1.el8.x86_64 8/9 Verifying : mongodb-org-tools-4.0.28-1.el8.x86_64 9/9 Upgraded: mongodb-org-6.0.1-1.el8.x86_64 mongodb-org-tools-6.0.1-1.el8.x86_64 Installed: cyrus-sasl-2.1.27-6.el8_5.x86_64 mongodb-database-tools-100.6.0-1.x86_64 mongodb-mongosh-1.5.4-1.el8.x86_64 mongodb-org-database-6.0.1-1.el8.x86_64 mongodb-org-database-tools-extra-6.0.1-1.el8.x86_64 Complete! Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details. Status mongodb ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2022-09-05 06:36:08 UTC; 75ms ago Docs: https://docs.mongodb.org/manual Process: 33739 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=1/FAILURE) Process: 33736 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 33735 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 33733 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Sep 05 06:36:08 DKERP systemd[1]: Starting MongoDB Database Server... Sep 05 06:36:08 DKERP mongod[33739]: about to fork child process, waiting until server is ready for connections. Sep 05 06:36:08 DKERP mongod[33740]: forked process: 33741 Sep 05 06:36:08 DKERP mongod[33739]: ERROR: child process failed, exited with error number 1 Sep 05 06:36:08 DKERP mongod[33739]: To see additional information in this output, start without the "--fork" option. Sep 05 06:36:08 DKERP systemd[1]: mongod.service: Control process exited, code=exited status=1 Sep 05 06:36:08 DKERP systemd[1]: mongod.service: Failed with result 'exit-code'. Sep 05 06:36:08 DKERP systemd[1]: Failed to start MongoDB Database Server. 

One suggestion was to start after trying this command sudo systemctl daemon-reload however that too did not work for me.

Unfortunately, nothing shows in the logs as evident from below output:

[root@vultr ~]# grep log /etc/mongod.conf # where to write logging data. logAppend: true path: /var/www/logs/mongodb/mongod.log [root@vultr ~]# cat /var/www/logs/mongodb/mongod.log | wc -l cat: /var/www/logs/mongodb/mongod.log: No such file or directory 0 

I'm doing mongo 6 on centos8

[root@vultr ~]# uname -a Linux DKERP 4.18.0-408.el8.x86_64 #1 SMP Mon Jul 18 17:42:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux [root@vultr ~]# hostnamectl Static hostname: DKERP Icon name: computer-vm Chassis: vm Machine ID: c07ca36f4c37437f8c6c6cbb7d73daf1 Boot ID: 83ee4a5872024054be50448423a9f5e7 Virtualization: microsoft Operating System: CentOS Stream 8 CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-408.el8.x86_64 Architecture: x86-64 

Removed the fork option from configuration file and here is the details debug:

[root@vultr ~]# journalctl -xe Sep 05 10:20:26 DKERP systemd[1]: Starting MongoDB Database Server... -- Subject: Unit mongod.service has begun start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit mongod.service has begun starting up. Sep 05 10:20:26 DKERP mongod[34825]: 2022-09-05T10:20:26.596+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/www/logs/mongodb/mongod.log" Sep 05 10:20:26 DKERP systemd[1]: mongod.service: Control process exited, code=exited status=1 Sep 05 10:20:26 DKERP dbus-daemon[775]: [system] Activating via systemd: service name='org.fedoraproject.Setroubleshootd' unit='setroubleshootd.service' requested by ':1.239' (uid=0 pi> Sep 05 10:20:26 DKERP systemd[1]: mongod.service: Failed with result 'exit-code'. -- Subject: Unit failed -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- The unit mongod.service has entered the 'failed' state with result 'exit-code'. Sep 05 10:20:26 DKERP systemd[1]: Failed to start MongoDB Database Server. -- Subject: Unit mongod.service has failed -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit mongod.service has failed. -- -- The result is failed. Sep 05 10:20:26 DKERP systemd[1]: Starting SETroubleshoot daemon for processing new SELinux denial logs... -- Subject: Unit setroubleshootd.service has begun start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit setroubleshootd.service has begun starting up. Sep 05 10:20:26 DKERP sudo[34814]: pam_unix(sudo:session): session closed for user root Sep 05 10:20:27 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd' Sep 05 10:20:27 DKERP systemd[1]: Started SETroubleshoot daemon for processing new SELinux denial logs. -- Subject: Unit setroubleshootd.service has finished start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit setroubleshootd.service has finished starting up. -- -- The start-up result is done. Sep 05 10:20:28 DKERP setroubleshoot[34827]: AnalyzeThread.run(): Cancel pending alarm Sep 05 10:20:28 DKERP dbus-daemon[775]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.917' (uid=995 pid=34827 comm="/usr/libexec/platfo> Sep 05 10:20:28 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged' Sep 05 10:20:29 DKERP setroubleshoot[34827]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0> Sep 05 10:20:29 DKERP setroubleshoot[34827]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. ***** Plugin catchall (100. confidence) suggests ************************** If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'mongod' --raw | audit2allow -M my-mongod # semodule -X 300 -i my-mongod.pp Sep 05 10:20:29 DKERP setroubleshoot[34827]: AnalyzeThread.run(): Set alarm timeout to 10 

I then decided to temporarily disable selinux however, I still get the below error:

[root@vultr ~]# journalctl -xe Sep 05 10:26:43 DKERP systemd[1]: Started SETroubleshoot daemon for processing new SELinux denial logs. -- Subject: Unit setroubleshootd.service has finished start-up -- Defined-By: systemd -- Support: https://access.redhat.com/support -- -- Unit setroubleshootd.service has finished starting up. -- -- The start-up result is done. Sep 05 10:26:43 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm Sep 05 10:26:43 DKERP dbus-daemon[775]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.949' (uid=995 pid=34922 comm="/usr/libexec/platfo> Sep 05 10:26:44 DKERP dbus-daemon[775]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged' Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0> Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. ***** Plugin catchall (100. confidence) suggests ************************** If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'mongod' --raw | audit2allow -M my-mongod # semodule -X 300 -i my-mongod.pp Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10 Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. For complete SELinux messages run: sealert -l 8a0> Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes. ***** Plugin catchall (100. confidence) suggests ************************** If you believe that mongod should be allowed read access on the memory.limit_in_bytes file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'mongod' --raw | audit2allow -M my-mongod # semodule -X 300 -i my-mongod.pp Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10 Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Cancel pending alarm Sep 05 10:26:44 DKERP setroubleshoot[34922]: failed to retrieve rpm info for /sys/fs/cgroup/memory/memory.limit_in_bytes Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from getattr access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes. For complete SELinux mes> Sep 05 10:26:44 DKERP setroubleshoot[34922]: SELinux is preventing /usr/bin/mongod from getattr access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes. ***** Plugin catchall (100. confidence) suggests ************************** If you believe that mongod should be allowed getattr access on the memory.limit_in_bytes file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'mongod' --raw | audit2allow -M my-mongod # semodule -X 300 -i my-mongod.pp Sep 05 10:26:44 DKERP setroubleshoot[34922]: AnalyzeThread.run(): Set alarm timeout to 10 

Can you please suggest how can I get mongod to run?

10
  • Sep 05 06:36:08 DKERP mongod[33739]: To see additional information in this output, start without the "--fork" option. Commented Sep 5, 2022 at 10:16
  • @ArtemS.Tashkinov updated the Original post without the fork option with more detailed logs. Commented Sep 5, 2022 at 10:22
  • Sep 05 10:20:26 DKERP mongod[34825]: 2022-09-05T10:20:26.596+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/www/logs/mongodb/mongod.log" Commented Sep 5, 2022 at 10:23
  • @ArtemS.Tashkinov I have zeroed in on the problem and updated the original post -> The issue occurs when I change the default log path in cat /etc/mongod.conf to a custom location. Can you please suggest? Commented Sep 5, 2022 at 11:38
  • I zeroed the issue for you 2 hours ago. I wonder why you need to put the log file into /var/www - that's the wrong location for it. Commented Sep 5, 2022 at 12:25

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.