Installation on RHEL / Rocky / AlmaLinux
We declare MongoDB's official YUM/DNF repository, then install the
mongodb-org meta-package. Important point: the repository is indexed only by
RHEL major version (8, 9, 10), which is why the baseurl above is
hard-coded to 9 rather than $releasever — on Fedora, dnf would resolve
$releasever to a Fedora number (40, 41, 42…) and the repository would return
a 404 error. Adjust the 9 to your major version if you are on RHEL 8 or 10.
Native Fedora is not an officially supported MongoDB platform: if you work on Fedora, the simplest path is to use Docker (see the corresponding Docker page).
A notable peculiarity of the Red Hat family: the default data directory is
/var/lib/mongo (and not /var/lib/mongodb as on Debian). Since SELinux
is enabled, if you move dbPath, remember to apply the right context
(semanage fcontext / restorecon).
Security
Out of the box, MongoDB starts without authentication and mongod listens
only on 127.0.0.1. That is safe locally, but not enough as soon as the
machine is reachable from the network. Never expose port 27017 until you
have, in /etc/mongod.conf, enabled security.authorization (after creating
an administrative user) and restricted net.bindIp to the interfaces you
actually need. A MongoDB instance left open without authentication is routinely
scanned and compromised within minutes.