How to install MongoDB 6 on Fedora 37
Mongodb 6 installation on Fedora Linux 37. Article shows lacking fragment of official docs and two steps after installation that are presented in extremely simple way in comparison to other sources.
Daniel Gustaw
• 2 min read
In official docs there is instruction only for Redhat
Install MongoDB Community Edition on Red Hat or CentOS — MongoDB Manual
and it contains $releasever
in repository file. But on fedora $releasever
is not defined. So to fix it you can check url
https://repo.mongodb.org/yum/redhat/
and see that higest version of redhat is 9. Because of Fedora is experimental polygon of Redhat you can derive conclusion that it should works if you use redhat repository on fedora like this:
sudo tee /etc/yum.repos.d/mongodb-org-6.0.repo<<EOF
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
EOF
Now you can install by
sudo dnf install -y mongodb-org
so there are two assumptions that are correct:
- using redhat repo for fedora works
- using dnf for yum repos works
Now you have to start mongod
service
sudo systemctl start mongod
And you can connect with mongodb by mongosh
Mongosh is better than mongo
command because of colors and autocompletion, so use mongosh
instead of mongo
.
Mongo compass
To browse mongo in graphic mode you will probably choose compass. Following after
Download and Install Compass — MongoDB Compass
you can download rpm
packages
wget https://downloads.mongodb.com/compass/mongodb-compass-1.35.0.x86_64.rpm
and install it
sudo dnf install -y mongodb-compass-1.35.0.x86_64.rpm
Enable Mongo Replica Set locally
Replication described here:
Replication — MongoDB Manual
is required by prisma
so I am enabling it locally.
In file /etc/mongod.conf
you have to replace
#replication:
by
replication:
replSetName: "rs0"
then reload mongod
service
sudo systemctl restart mongod
Login to database by mongosh
and use command
rs.initiate()
then you can confirm changes by
rs.status()
If you experiencing more complications there is great article with advanced config
How To Configure a MongoDB Replica Set on Ubuntu 20.04 | DigitalOcean
Other articles
You can find interesting also.
The impact of indexing on search performance in MySQL database
Using indexes speeds up searches and increases table size while slowing down modifications. The article shows how to profile queries and measure the impact of indexes on search performance.
Daniel Gustaw
• 15 min read
Xss attack using script style and image
Learn how to infect a page using an XSS attack with the script, style, or image tags. You can see how to replace the content of the page with your own even without javascript.
Daniel Gustaw
• 4 min read
Telegram Bot in Typescript
Learn how to create a bot on Telegram, add command listening to it, and configure notification sending.
Daniel Gustaw
• 3 min read