Mongodb Service Not Running in Fedora

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:

  1. Check the file permissions inside your database folder

    1. note you need to be in your dbpath folder mine was
      /var/lib/mongo I went to cd /var/lib
    2. I ran ls -l mongo
  2. 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



Leave a reply



Submit