MongoDB service not running in Fedora
How to install mongodb and mongodb-server on fedora linux (verified on f16 & f17). All commands are intended to be run in a su session.
1) make sure you have no mongodb installation lying around
# yum erase mongodb
# yum erase mongo-10gen (if it is installed)
2) install from fedora yum repository
# yum --disablerepo=* --enablerepo=fedora,updates install mongodb mongodb-server
3) start mongod (mongodb daemon)
# systemctl start mongod.service
4) verify mongod is running
# systemctl status mongod.service
# tail /var/log/mongodb/mongodb.log
# nmap -p27017 localhost
or running client
# mongo
MongoDB shell version: 2.0.2
connecting to: test
> db.test.save( { a: 1 } )
> db.test.find()
{ "_id" : ObjectId("4fdf28f09d16204d66082fa3"), "a" : 1 }
5) customize configuration
# vim /etc/mongodb.conf
# systemctl restart mongod.service
6) make mongodb service automatically start at boot
# systemctl enable mongod.service
Update for Fedora 18
When started for the first time by systemd on a slow or loaded machine, mongod service might timeout before finishing its initialization, with systemd flagging the service as failed.
Symptoms:
# journalctl -xn
-- Unit mongod.service has begun starting up.
10:38:43 local mongod[24558]: forked process: 24560
10:38:43 local mongod[24558]: all output going to: /var/log/mongodb/mongodb.log
10:40:13 local systemd[1]: mongod.service operation timed out. Terminating.
10:40:13 local systemd[1]: Failed to start High-performance, schema-free document-oriented database.
-- Subject: Unit mongod.service has failed
Very easy cure, restart the service:
# systemctl restart mongod.service
this should finish the initialization successfully and leave the daemon in running state.
mongo command not working on fedora
So first I am on fedora 24.
I found this thread https://www.learntutors.com/install-mongodb-fedora-24/
The only thing I changed to make things work is the install command to the following
dnf install --allowerasing mongodb-org mongodb-org-server
This was so the mongodb package that ships with fedora 24 could be erased in favor of mongodb-org mongodb-org-server. Hope this helps someone else. cheers.
Mongodb service won't start
After running the repair I was able to start the mongod proccessor but as root, which meant that service mongod start
would not work. To repair this issue, I needed to make sure that all the files inside the database folder were owned and grouped to mongod. I did this by the following:
- Check the file permissions inside your database folder
- note you need to be in your dbpath folder mine was
/var/lib/mongo
I went tocd /var/lib
- I ran
ls -l mongo
- note you need to be in your dbpath folder mine was
- This showed me that databases were owned by root, which is wrong. I ran the following to fix this:
chown -R mongod:mongod mongo
. This changed the owner and group of every file in the folder to mongod. (If using the mongodb package,chown -R mongodb:mongodb mongodb
)
I hope this helps someone else in the future.
mongodb service is not starting up
Fixed!
The reason was the dbpath
variable in /etc/mongodb.conf
.
Previously, I was using mongodb 1.8, where the default value for dbpath was /data/db
.
The upstart job mongodb
(which comes with mongodb-10gen package) invokes the mongod
with --config /etc/mongodb.conf
option.
As a solution, I only had to change the owner of the /data/db
directory recursively.
Related Topics
Is There a Special Restriction on Commands Executed by Cron
Where Does Pp (Par) Unpack Add (-A) Files
Bash "Declare -A" Does Not Work on MACos
How to Send a Sequence of at Commands to a Serial Port in Bash
How to Do 'Ret' Instruction from Code at _Start in MACos? Linux
How to Run a Shell Script by Cron Job
String Comparison Not Working Properly
While Do Loop and Variables in a Bash Script
How to Use Code Completion into Eclipse with Opencv
History Command Works in a Terminal, But Doesn't When Written as a Bash Script
G++ Searches /Lib/../Lib/, Then /Lib/
Insert New Line to Bash Prompts
Splitting Gzipped Logfiles Without Storing the Ungzipped Splits on Disk
Using Bash Environment Variables from Within a Perl Script
Install Marklogic Centos Virtualbox Vm
How to Add a Custom Extended Attribute from Linux Kernel Space (I.E from a Custom System Call)