Enable/Configure Oplog on standalone mongodb version 5

Hi Team,

I want to configure oplog on stand-alone mongo DB server. I have very basic idea of Mongo DB as admin. Need all your help to resolve this.

I am trying to do below steps but mongodb service is not starting after adding the below parameters on mongo.conf file.

replication:
   oplogSizeMB: 1024
   replSetName: rs0

There is no particular error but services are unable to start.

Let me know if any other steps to be done before this.

Welcome to the MongoDB Community @Swarup_Dey !

Please share some more details on your environment:

  • O/S version

  • How you are starting mongod

Since you are using a configuration file, I assume you have also set a systemLog.path location. There should be more informative log messages indicating the reason the mongod process was unable to start successfully.

Regards,
Stennie

Hi Stennie,

Thanks for your reply.

O/S version:

[root@UATMONGODB etc]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.5 (Ootpa)
  • How you are starting mongod:
systemctl start mongod
Details:
[root@UATMONGODB etc]# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-10-13 11:18:13 +08; 3h 22min ago
     Docs: https://docs.mongodb.org/manual
  Process: 6965 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 6963 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 6961 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 6958 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 6969 (mongod)
   Memory: 173.2M
   CGroup: /system.slice/mongod.service
           └─6969 /usr/bin/mongod -f /etc/mongod.conf

Conf File:

[mongo@UATMONGODB ~]$ cat /etc/mongod.conf
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/
net:
   tls:
      FIPSMode: true
# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  quiet: false
  path: /mongo/log/mongod.log

# Where and how to store data.
storage:
  dbPath: /mongo/datadir
  journal:
    enabled: true
#  engine:
#  wiredTiger:


# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27077
  bindIp: 10.10.10.10  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.


security:
  authorization: "enabled"
  javascriptEnabled: false

setParameter:
 enableLocalhostAuthBypass: false

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

Thanks
Swarup

Got generic error while starting after adding mentioned replica parameters.

[root@UATMONGODB etc]# systemctl start mongod
Job for mongod.service failed because the control process exited with error code.
See "systemctl status mongod.service" and "journalctl -xe" for details.
[root@UATMONGODB etc]# journalctl -xe
Oct 13 10:21:17 UATMONGODB.katmb.com.my mongod[1229696]: try '/usr/bin/mongod --help' for more information
Oct 13 10:21:17 UATMONGODB.katmb.com.my systemd[1]: mongod.service: Control process exited, code=exited status=2
Oct 13 10:21:17 UATMONGODB.katmb.com.my 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'.
Oct 13 10:21:17 UATMONGODB.katmb.com.my 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.
Oct 13 10:21:18 UATMONGODB.katmb.com.my dbus-daemon[1104]: [system] Successfully activated service 'org.fedoraproject.Setroubleshootd'
Oct 13 10:21:20 UATMONGODB.katmb.com.my setroubleshoot[1229698]: AnalyzeThread.run(): Cancel pending alarm
Oct 13 10:21:20 UATMONGODB.katmb.com.my setroubleshoot[1229698]: failed to retrieve rpm info for /sys/fs/cgroup/memory/memory.limit_in_bytes
Oct 13 10:21:20 UATMONGODB.katmb.com.my dbus-daemon[1104]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.349488' (uid=993 pid=1229698 comm="/usr/>
Oct 13 10:21:21 UATMONGODB.katmb.com.my dbus-daemon[1104]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged'
Oct 13 10:21:21 UATMONGODB.katmb.com.my setroubleshoot[1229698]: SELinux is preventing /usr/bin/mongod from open access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes. For complete SELi>
Oct 13 10:21:21 UATMONGODB.katmb.com.my setroubleshoot[1229698]: SELinux is preventing /usr/bin/mongod from open 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 open 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

Oct 13 10:21:21 UATMONGODB.katmb.com.my setroubleshoot[1229698]: AnalyzeThread.run(): Set alarm timeout to 10
Oct 13 10:21:21 UATMONGODB.katmb.com.my setroubleshoot[1229698]: AnalyzeThread.run(): Cancel pending alarm
Oct 13 10:21:22 UATMONGODB.katmb.com.my setroubleshoot[1229698]: failed to retrieve rpm info for /sys/fs/cgroup/memory/memory.limit_in_bytes
Oct 13 10:21:22 UATMONGODB.katmb.com.my setroubleshoot[1229698]: SELinux is preventing /usr/bin/mongod from getattr access on the file /sys/fs/cgroup/memory/memory.limit_in_bytes. For complete S>
Oct 13 10:21:22 UATMONGODB.katmb.com.my setroubleshoot[1229698]: 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

Oct 13 10:21:22 UATMONGODB.katmb.com.my setroubleshoot[1229698]: AnalyzeThread.run(): Set alarm timeout to 10

Hi @Swarup_Dey,

Did you install MongoDB using the official packages? What specific version of MongoDB 5.x server did you install?

SELinux policies should be setup as part of the packaged installation, but can also be configured manually per Configure SELinux.

If you happen to be using an older MongoDB 5.0.x release I would strongly recommend installing the most recent patch release (currently 5.0.13) as there have been several important stability fixes. Patch releases do not introduce any backward-breaking or compatibility changes. Please review Release Notes for MongoDB 5.0 for more details.

Can you please have a look at this MongoDB log file? It should have some more relevant error messages.

Thanks,
Stennie

1 Like

Hi Stennie,

I have installed mongodb with below repository.

[root@UATMONGODB yum.repos.d]# cat mongodb-org-5.0.repo
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

MongoDB version currently is 5.0.6.
We have make seLinux permission. Do you think we still require selenux policy to be applied ?

We will try to installed patch but that’s gonna take a while with downtime approval.
But do you think this older version has any effect on the replication/oplog setup?

** selinux is set to Permissive.

[root@UATMONGODB /]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 33