Unable to run mongoDB after installation - linux

I'm On fedora 34 and trying to install mongoDB on this machine.
I followed installation instruction from official Docs from here. Everything installed correctly, but now i'm unable to start the service.
I executed sudo systemctl start mongod and it showed
root#fedora /v/l/mongodb [100]# systemctl start mongod
Job for mongod.service failed because the control process exited with error code.
See "systemctl status mongod.service" and "journalctl -xeu mongod.service" for details.
This is the source for mongod.service in /usr/lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=-f /etc/mongod.conf"
EnvironmentFile=-/etc/sysconfig/mongod
ExecStart=/usr/bin/mongod $OPTIONS
ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb
ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb
ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb
PermissionsStartOnly=true
PIDFile=/var/run/mongodb/mongod.pid
Type=forking
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
I think problem begins here
12 ExecStart=/usr/bin/mongod $OPTIONS
I'm a noob in systemd and daemons and services
This is the log from systemctl status mongod.service
root#fedora /v/l/mongodb [1]# systemctl status mongod.service
× mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2021-08-01 11:18:36 IST; 16min ago
Docs: https://docs.mongodb.org/manual
Process: 8116 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8117 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8118 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8119 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
CPU: 149ms
Aug 01 11:18:36 fedora systemd[1]: Starting MongoDB Database Server...
Aug 01 11:18:36 fedora mongod[8119]: about to fork child process, waiting until server is ready for connections.
Aug 01 11:18:36 fedora mongod[8122]: forked process: 8122
Aug 01 11:18:36 fedora mongod[8119]: ERROR: child process failed, exited with 14
Aug 01 11:18:36 fedora mongod[8119]: To see additional information in this output, start without the "--fork" option.
Aug 01 11:18:36 fedora systemd[1]: mongod.service: Control process exited, code=exited, status=14/n/a
Aug 01 11:18:36 fedora systemd[1]: mongod.service: Failed with result 'exit-code'.
Aug 01 11:18:36 fedora systemd[1]: Failed to start MongoDB Database Server.

Your mongodb exited with status code 14 as systemctl status says.
Here you can find the answer

Related

Systemd enabled services not starting at boot anymore

I made some custom systemd services long time ago, all have the same configuration (except for the ExecStart of course)
This configuration worked for years, I have ubuntu up and running since version 18.04 LTS, but now looks like some of these systemd services aren't starting at boot at all, the configuration is as follow (myapp.service):
[Unit]
Description="myapp"
After=syslog.target network-online.target
Wants=network-online.target
[Service]
Restart=always
RestartSec=10
User=root
Group=root
WorkingDirectory=/opt/myapp
ExecStart=/usr/local/bin/myapp
KillMode=control-group
[Install]
WantedBy=multi-user.target
The service is enabled:
$ sudo systemctl enable myapp
Created symlink /etc/systemd/system/multi-user.target.wants/myapp.service → /lib/systemd/system/myapp.service.
If i do "systemctl status myapp" after a reboot:
● myapp.service - "myapp"
Loaded: loaded (/lib/systemd/system/myapp.service; enabled; vendor preset: enabled)
Active: inactive (dead)
If i do "journalctl -u myapp -f" after a reboot:
Jan 13 12:10:06 myhost systemd[1]: Started myapp.
Jan 17 07:15:03 myhost systemd[1]: Stopping myapp...
Jan 17 07:15:09 myhost systemd[1]: Stopped myapp.
What's wrong with my configuration?
If I manually start /usr/local/bin/myapp there are no errors on the script and I've also tried running it with tmux, now it's 3 days running in bg and no errors. But systemd just won't start it after a reboot.
Today, i've also tried to install a new service that require a systemd config, the package is zram-config and by default it is enabled at boot.
But after a: apt install zram-config && sudo reboot:
$ sudo systemctl status zram-config
● zram-config.service - Initializes zram swaping
Loaded: loaded (/lib/systemd/system/zram-config.service; enabled; vendor preset: enabled)
Active: inactive (dead)
but if now i do:
$ sudo systemctl start zram-config
$ sudo systemctl status zram-config
● zram-config.service - Initializes zram swaping
Loaded: loaded (/lib/systemd/system/zram-config.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2020-01-27 12:25:55 CET; 1s ago
Process: 5541 ExecStart=/usr/bin/init-zram-swapping (code=exited, status=0/SUCCESS)
Main PID: 5541 (code=exited, status=0/SUCCESS)
Jan 27 12:25:55 myhost systemd[1]: Starting Initializes zram swaping...
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=4ac5c2cd-0c68-4f6d-a5c0-d8f91a509c71
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=83a4f201-d591-4222-89a6-5bc5aebedef4
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=1f6f742e-6fb8-4332-b226-bf6918f7ee28
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=a5509c55-46f5-4112-8fe1-68171f31409e
Jan 27 12:25:55 myhost systemd[1]: Started Initializes zram swaping.
I really don't understand what's wrong with systemd on my Ubuntu install, is it better I do a fresh reinstall of whole OS?
Thanks
Check the full output of journalctl for a message about cycles, like:
Job <your.service> deleted to break ordering cycle starting with <something else>
I had the similar issue. It was due to ordering cycles, which was very hard to debug and fix.

I can't start SonarQube in CENTOS 7 because the PIDs keeps on changing rapidly

I am trying to Integrating Jenkins 2 and SonarQube 6.7.3 on centos 7 due to this tutorial:
https://www.youtube.com/watch?v=osc0j_Z1x0w
I install and config all software like: java, PostgreSQL, SonarQube,... I am really confused how to start sonar correctly in order to be able open sonar dashboard on Firefox by http://localhost:9000/ now i can't open it because the sonar service not started correctly and PID keeps on changing rapidly :
[root#localhost ~]# service sonar status
SonarQube is running (36211).
[root#localhost ~]# service sonar status
SonarQube is not running.
[root#localhost ~]# service sonar status
SonarQube is running (36602).
[root#localhost ~]# service sonar status
SonarQube is running (36602).
[root#localhost ~]# service sonar status
SonarQube is not running.
[root#localhost ~]# service sonar status
SonarQube is running (36993).
[root#localhost ~]# service sonar status
SonarQube is running (36993).
[root#localhost ~]#
sonar can't be opened on FireFox
I start and enable PostgreSQL by this commands :
[root#localhost ~]# systemctl start postgresql-9.6
[root#localhost ~]# systemctl enable postgresql-9.6
[root#localhost ~]# systemctl status postgresql-9.6
● postgresql-9.6.service - PostgreSQL 9.6 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.6.service; enabled;
vendor preset: disabled)
Active: active (running) since Mon 2018-05-07 11:44:12 +0430; 1h 26min ago
Docs: https://www.postgresql.org/docs/9.6/static/
***Main PID: 1288 (postmaster)***
CGroup: /system.slice/postgresql-9.6.service
├─1288 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
├─1626 postgres: logger process
├─1630 postgres: checkpointer process
├─1631 postgres: writer process
├─1632 postgres: wal writer process
├─1633 postgres: autovacuum launcher process
└─1634 postgres: stats collector process
May 07 11:43:57 localhost.localdomain systemd[1]: Starting PostgreSQL 9.6
database server...
May 07 11:44:11 localhost.localdomain postmaster[1288]: < 2018-05-07
11:44:11.217 +0430 > LOG: redir...ess
May 07 11:44:11 localhost.localdomain postmaster[1288]: < 2018-05-07
11:44:11.217 +0430 > HINT: Futu...g".
May 07 11:44:12 localhost.localdomain systemd[1]: Started PostgreSQL 9.6
database server.
Hint: Some lines were ellipsized, use -l to show in full.
when I run the command again systemctl status postgresql-9.6 the output is the same as last run with Main PID: 1288 (postmaster) :
[root#localhost ~]# systemctl status postgresql-9.6
● postgresql-9.6.service - PostgreSQL 9.6 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.6.service; enabled;
vendor preset: disabled)
Active: active (running) since Mon 2018-05-07 11:44:12 +0430; 1h 29min ago
Docs: https://www.postgresql.org/docs/9.6/static/
***Main PID: 1288 (postmaster)***
CGroup: /system.slice/postgresql-9.6.service
├─1288 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
├─1626 postgres: logger process
├─1630 postgres: checkpointer process
├─1631 postgres: writer process
├─1632 postgres: wal writer process
├─1633 postgres: autovacuum launcher process
└─1634 postgres: stats collector process
May 07 11:43:57 localhost.localdomain systemd[1]: Starting PostgreSQL 9.6
database server...
May 07 11:44:11 localhost.localdomain postmaster[1288]: < 2018-05-07
11:44:11.217 +0430 > LOG: redir...ess
May 07 11:44:11 localhost.localdomain postmaster[1288]: < 2018-05-07
11:44:11.217 +0430 > HINT: Futu...g".
May 07 11:44:12 localhost.localdomain systemd[1]: Started PostgreSQL 9.6
database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root#localhost ~]#
but when I start and run sonar, the outputs are different and Main PID keeps on changing rapidly :
[root#localhost ~]# systemctl start sonar
[root#localhost ~]# systemctl enable sonar
[root#localhost ~]# systemctl status sonar
● sonar.service - SonarQube service
Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset:
disabled)
Active: active (running) since Mon 2018-05-07 13:19:57 +0430; 6s ago
Process: 121807 ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
(code=exited, status=0/SUCCESS)
Process: 121850 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
(code=exited, status=0/SUCCESS)
***Main PID: 121893 (wrapper)***
CGroup: /system.slice/sonar.service
├─121893 /opt/sonarqube/bin/linux-x86-64/./wrapper /opt/sonarqube/bin/linux-x86-64/../../conf...
└─121895 java -Dsonar.wrapped=true -Djava.awt.headless=true -Xms8m -
Xmx32m -Djava.library.pat...
May 07 13:19:56 localhost.localdomain systemd[1]: sonar.service
holdoff time over, scheduling restart.
May 07 13:19:56 localhost.localdomain systemd[1]: Starting SonarQube
service...
May 07 13:19:56 localhost.localdomain sonar.sh[121850]: Starting
SonarQube...
May 07 13:19:56 localhost.localdomain sonar.sh[121850]: PID:
May 07 13:19:56 localhost.localdomain sonar.sh[121850]:
"/opt/sonarqube/bin/linux-x86-64/./wrapper" "...be"
May 07 13:19:57 localhost.localdomain sonar.sh[121850]: Started
SonarQube.
May 07 13:19:57 localhost.localdomain systemd[1]: Started SonarQube
service.
Hint: Some lines were ellipsized, use -l to show in full.
[root#localhost ~]#
the previous command Main PID: 121893 (wrapper) and the other command is Main PID: 123382 (wrapper)
[root#localhost ~]# systemctl status sonar
● sonar.service - SonarQube service
Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset:
disabled)
Active: active (running) since Mon 2018-05-07 13:21:11 +0430; 3s ago
Process: 123296 ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
(code=exited, status=0/SUCCESS)
Process: 123339 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
(code=exited, status=0/SUCCESS)
***Main PID: 123382 (wrapper)***
CGroup: /system.slice/sonar.service
├─123382 /opt/sonarqube/bin/linux-x86-64/./wrapper
/opt/sonarqube/bin/linux-x86-64/../../conf...
├─123384 java -Dsonar.wrapped=true -Djava.awt.headless=true -Xms8m -
Xmx32m -Djava.library.pat...
└─123411 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-
0.b14.el7_4.x86_64/jre/bin/java -XX:+UseCo...
May 07 13:21:10 localhost.localdomain systemd[1]: sonar.service
holdoff time over, scheduling restart.
May 07 13:21:10 localhost.localdomain systemd[1]: Starting SonarQube
service...
May 07 13:21:10 localhost.localdomain sonar.sh[123339]: Starting
SonarQube...
May 07 13:21:10 localhost.localdomain sonar.sh[123339]: PID:
May 07 13:21:10 localhost.localdomain sonar.sh[123339]:
"/opt/sonarqube/bin/linux-x86-64/./wrapper" "...be"
May 07 13:21:11 localhost.localdomain sonar.sh[123339]: Started
SonarQube.
May 07 13:21:11 localhost.localdomain systemd[1]: Started SonarQube
service.
Hint: Some lines were ellipsized, use -l to show in full.

systemd cannot run service after running commands

I tried to run systemd using the commands systemctl enable photogrid.service & systemctl start photogrid.service in ubuntu 16
The nodejs app itself can run as expected. The service is to ensure that application will auto-start when application crash or server reboot.
The service apparently did not start. So I key in systemctl status photogrid.service to see what happened, the below is what I got from the terminal.
● photogrid.service - Photogrid
Loaded: loaded (/lib/systemd/system/photogrid.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2016-11-09 04:35:36 UTC; 7s ago
Process: 27523 ExecStart=/usr/local/bin/node /home/ubuntu/photogrid/app.js (code=exited, status=203/EXEC)
Main PID: 27523 (code=exited, status=203/EXEC)
Nov 09 04:35:36 ip-172-31-34-151 systemd[1]: photogrid.service: Main process exited, code=exited, status=203/EXEC
Nov 09 04:35:36 ip-172-31-34-151 systemd[1]: photogrid.service: Unit entered failed state.
Nov 09 04:35:36 ip-172-31-34-151 systemd[1]: photogrid.service: Failed with result 'exit-code'.
This the script that I wrote for the service under the path /lib/systemd/system/photogrid.service
[Unit]
Description=Photogrid
[Service]
Type=simple
Restart=always
RestartSec=10
Environment=NODE_ENV=production
ExecStart=/usr/local/bin/node /home/ubuntu/photogrid/app.js
[Install]
WantedBy=multi-user.target
Basically under ExecStart make sure you point to the correct nodejs executable. For my case it was in a different folder and not /usr/local/bin/node, to check where is your node executable. (Assuming you confirm you have downloaded and install it correctly in linux) use command which node to give you path direction.

reinstall nginx if i delete /etc/nginx in centos server how to reinstall it again i am new in centos and nginx

i install nginx in my remote server but i done some error in my nginx.conf file and could not able to revert back
so it tried to remove my nginx and reconfigure it
so i used these step which is given in the link to delete my nginx
http://www.ehowstuff.com/how-to-remove-uninstall-nginx-on-centos-7-rhel-7-oracle-linux-7/
then i use yum remove nginx and again reinstall it
but when i try sudo systemctl start nginx or [root#lotto nginx]# service nginx start
its showing
Job for nginx.service failed because the control process exitenter code hereed with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
when i am using
[root#lotto nginx]# systemctl status nginx.service
showing
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
Jul 01 07:48:44 lotto systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 01 07:48:44 lotto nginx[30832]: nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
Jul 01 07:48:44 lotto nginx[30832]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 01 07:48:44 lotto systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 01 07:48:44 lotto systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jul 01 07:48:44 lotto systemd[1]: Unit nginx.service entered failed state.
Jul 01 07:48:44 lotto systemd[1]: nginx.service failed.
and [root#lotto nginx]# journalctl -xe
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
uninstall
yum remove nginx
install
In CentOS , you should using yum install ; instead of apt-get install in Ubuntu.
at last I found out the solutions by my self
I used nginx -t which shows that I don't have any syntax error in my code
Then I use
user nobody; // in my nginx.conf
This solved my problem
Thanks everyone for your help!

initializing systemctl status mariadb.service

I'm trying to initialize the mysql service, with camando systemctl mariadb.service status, but the below error occurs, already uninstalled and installed twice, but the error persists.
systemctl status mariadb.service
● mariadb.service - MariaDB 10.0 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Seg 2016-03-14 17:51:49 BRT; 15s ago
Process: 6303 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 6074 ExecStartPost=/usr/libexec/mysql-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 6073 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 6020 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 5987 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 6073 (code=exited, status=0/SUCCESS)
Mar 14 17:51:45 siad01-pc systemd[1]: Starting MariaDB 10.0 database server...
Mar 14 17:51:46 siad01-pc mysqld_safe[6073]: 160314 17:51:46 mysqld_safe Log....
Mar 14 17:51:47 siad01-pc mysqld_safe[6073]: 160314 17:51:47 mysqld_safe Sta...l
Mar 14 17:51:48 siad01-pc mysqld_safe[6073]: 160314 17:51:48 mysqld_safe mys...d
Mar 14 17:51:48 siad01-pc systemd[1]: mariadb.service: control process exit...=1
Mar 14 17:51:49 siad01-pc systemd[1]: Failed to start MariaDB 10.0 database...r.
Mar 14 17:51:49 siad01-pc systemd[1]: Unit mariadb.service entered failed state.
Mar 14 17:51:49 siad01-pc systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root#siad01-pc ~]#
OK, I solved the problem.
I had to remove mysql, mariadb
yum remove mysql
Then I removed /var/lib/mysql and then reinstalled mariadb, mariadb-server, mysql and mysql-server.
then i reinstalled mariadb
Its that simple

Resources