MongoDB not starting properly on Ubuntu 18.04.2 LTS - linux

root#HangoutRoot:/Bot# sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-06-08 08:57:25 PDT; 5s ago
Docs: https://docs.mongodb.org/manual
Process: 2241 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
Main PID: 2241 (code=exited, status=48)
Jun 08 08:57:25 HangoutRoot systemd[1]: Started MongoDB Database Server.
That's what I get when I check the status of the mongodb server using sudo systemctl status mongod

Try this command : sudo systemctl enable mongod
After this:
run this command
sudo service mongod restart
If this still do not work I think reinstalling mongo would be a better solution.
To re-install mongo follow the the process of accepted answer from this link:
https://askubuntu.com/questions/884541/cant-start-mongodb-service

Related

restarting problem on my database mongodb

I've got a problem with my mongo db (my OS is ubuntu), i tried to restart my mongodb but when i execute the command
systemctl restart mongod
the status of mongodb respond with
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset>
Active: failed (Result: exit-code) since Thu 2023-02-09 10:11:18 CET; 8s a>
Docs: https://docs.mongodb.org/manual
Process: 11215 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=ex>
Main PID: 11215 (code=exited, status=14)
CPU: 29ms
I restarted because i've got a problem with my web app, the path of my database doesn't work when i tried to execute the command :
mongod --dbpath ./db
i executed this command on my server file which contain the file ./db

mongod.service - MongoDB Database Server - Main PID: 4565 (code=exited, status=48)

my question is similar like this
but all the answer of given here are not working for me ? My etc/mongod.conf file like this and start the server
bindIp: 127.0.0.1,<sameserverIP>,<anotherServerIp>
If i run systemctl status mogod i got following response:
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2022-12-27 14:12:42 +0545; 2min 36s ago
Docs: https://docs.mongodb.org/manual
Process: 5493 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
Main PID: 5493 (code=exited, status=48)
and if i change my etc/mongod.conf file like this and restart server
bindIp: 127.0.0.1,<sameserverIP>
then the mongodb server will work fine here is the output of systemctl status mongod
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-12-27 13:47:45 +0545; 10s ago
Docs: https://docs.mongodb.org/manual
Main PID: 4608 (mongod)
Memory: 211.8M
CGroup: /system.slice/mongod.service
└─4608 /usr/bin/mongod --config /etc/mongod.conf
I tried checking journal also using this command journalctl -u mongod
Dec 27 14:12:42 178-79-149-108.ip.linodeusercontent.com systemd[1]: Started MongoDB Database Server.
Dec 27 14:12:42 178-79-149-108.ip.linodeusercontent.com systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Dec 27 14:12:42 178-79-149-108.ip.linodeusercontent.com systemd[1]: mongod.service: Failed with result 'exit-code'.
This mongo server is installed in linode ubuntu 2020.04 lts from linode marketplace and mongodb version is 5.0.14. i want to give access to only 4 ipaddress in this mongodb can any one help me fix this issue?

Mongodb - how to restart mongodb that you just killed in Linux?

How can I restart mongodb that I just killed in Linux?
Before killing:
$ service mongodb status
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2017-01-03 08:41:16 GMT; 4h 5min ago
Docs: man:mongod(1)
Main PID: 1036 (mongod)
Tasks: 10
Memory: 61.0M
CPU: 1min 1.636s
CGroup: /system.slice/mongodb.service
└─1036 /usr/bin/mongod --config /etc/mongodb.conf
So I wanted to stop/ kill it for a while for other programs:
$ sudo kill 1036
$ service mongodb status
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:mongod(1)
But how can I start it again?
I'm on Ubuntu 16.04.
EDIT:
$ systemctl start mongod
Failed to start mongod.service: Unit mongod.service not found.
EDIT 2:
Get this error below when I have the other program running on mondodb. so I killed that program and it works as before.
$ sudo systemctl start mongodb
$ service mongodb status
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-01-03 13:05:19 GMT; 9s ago
Docs: man:mongod(1)
Process: 21732 ExecStart=/usr/bin/mongod --config /etc/mongodb.conf (code=exited, status=48)
Main PID: 21732 (code=exited, status=48)
Ubuntu 16.04 LTS
sudo systemctl start mongodb
Not only for MongoDB, but for any application installed, you can use
sudo systemctl start <app_name>
sudo systemctl restart <app_name>
Seems like you are using systemd
Try:
systemctl start mongod -> Start the service
systemctl status mongod -> Status of service
systemctl restart mongod -> restart the service
systemctl reload mongod -> reload the service
You checked status with :
service mongod status
so this should start mongod:
service mongod start
so this should stop mongod:
sudo service mongod stop
It works at my end.
for missing permissions:
sudo service mongod start

mongodb service on debian

I have installed monogodb with this procedure :
Mongodb on Debian
The service mongod is running.
$ service mongod status
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled)
Active: active (running) since Fri 2016-11-04 09:29:04 CET; 1 weeks 5 days ago
Main PID: 957 (mongod)
CGroup: /system.slice/mongod.service
└─957 /usr/bin/mongod --quiet --config /etc/mongod.conf
Nov 04 09:29:04 serv01 systemd[1]: Started High-performance, schema-free document-oriented database.
I didn't find the init script of this instance :
$ service --status-all | grep mon
[ + ] smartmontools
and whereis mongod:
mongod: /usr/bin/mongod /etc/mongod.conf /usr/share/man/man1/mongod.1.gz
Where is the mongod init script stored?

Unable to start postgresql service on CentOS 7

Unable to start postgresql-9.5 on CentOS 7.
I followed this page - https://wiki.postgresql.org/wiki/YUM_Installation - for installing the database server on CentOS.
I tried the same after setting setenforce 0, and that did not help either.
I am doing all operations as root.
systemctl start postgresql-9.5.service
Job for postgresql-9.5.service failed because the control process exited with error
code. See "systemctl status postgresql-9.5.service" and "journalctl -xe" for details.
And here is what I get for status -
Redirecting to /bin/systemctl status postgresql-9.5.service
● postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2016-02-18 15:20:30 EST; 2min 28s ago
Process: 15041 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
Feb 18 15:20:30 myserver systemd[1]: Starting PostgreSQL 9.5 database server...
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1
Feb 18 15:20:30 myserver systemd[1]: Failed to start PostgreSQL 9.5 database server.
Feb 18 15:20:30 myserver systemd[1]: Unit postgresql-9.5.service entered failed state.
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service failed.
And the contents of the different conf files are as follows -
[root#myserver /]# cat /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /usr/lib/tmpfiles.d/postgresql-9.5.conf
d /var/run/postgresql 0755 postgres postgres -
[root#myserver /]# cat /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /etc/alternatives/pgsql-ld-conf
/usr/pgsql-9.5/lib/
[root#myserver /]# cat /var/lib/alternatives/pgsql-ld-conf
auto
/etc/ld.so.conf.d/postgresql-pgdg-libs.conf
/usr/pgsql-9.5/share/postgresql-9.5-libs.conf
950
Googled for the error that I am seeing.
A number of folks have seen the same error, and the underlying cause is different in each case. Reading through those posts, it is not clear that I am seeing any of the already reported causes.
Make sure you have installed all packages correctly and updated yum repository sections [base] and [updates] before installation as it mentioned in the guide . We have CentOS 7 with PostgreSQL 9.5 and it works perfectly fine with following steps:
vi /etc/yum.repos.d/CentOS-Base.repo
yum localinstall http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
yum list postgres*
yum install -y postgresql95-server.x86_64 postgresql95-contrib.x86_64 postgresql95-libs.x86_64
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5.service
systemctl start postgresql-9.5.service
and finally, systemctl status postgresql-9.5.service should show you something like this:
postgresql-9.5.service - PostgreSQL 9.5 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled)
Active: active (running) since Fri 2016-02-19 00:01:13 UTC; 6min ago
Process: 10809 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
Process: 10802 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 10811 (postgres)
CGroup: /system.slice/postgresql-9.5.service
├─10811 /usr/pgsql-9.5/bin/postgres -D /var/lib/pgsql/9.5/data
├─10812 postgres: logger process
├─10814 postgres: checkpointer process
├─10815 postgres: writer process
├─10816 postgres: wal writer process
├─10817 postgres: autovacuum launcher process
└─10818 postgres: stats collector process
The most common issue is that the database cluster was not initialized. You can initialize it easily by running the postgresql-XX-setup script with the initdb command, e.g.
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
Then start the Postgres service, e.g.
sudo systemctl start postgresql-11
These steps helped me on our test server.
Connect your server via SSH.
Then switch user:
sudo su - postgres
Check Postgres status:
pg_ctl status
Stop DB:
pg_ctl stop
Check if no server processes exist:
ps axf | grep postg
Start Postgres service:
sudo systemctl start postgresql.service
OR
sudo systemctl start postgresql
Then check status:
systemctl status postgresql.service ИЛИ systemctl status postgresql

Resources