Postgresql server doesn't start - linux

[Ubuntu 16.04]
I installed postgresql 9.5 along with dependencies:
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common
sudo apt-get install postgresql-9.5 libpq-dev
When I want to run psql then I get:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
But /var/run/postgresql/ is empty. When I restart posgresql everything appears to be fine:
$ /etc/init.d/postgresql restart
[ ok ] Restarting postgresql (via systemctl): postgresql.service.
$ /etc/init.d/postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since wto 2016-09-27 16:18:26 CEST; 1min 15s ago
Process: 3076 ExecReload=/bin/true (code=exited, status=0/SUCCESS)
Process: 3523 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 3523 (code=exited, status=0/SUCCESS)
but if check ps aux there is not such PID (why??)
Total reinstalation doesn't help at all. How can I fix it?
Edit:
I've just noticed that then type /etc/init.d/postgresql force-reload postgresql, systemctl are alive awhile and then are killed automatically
Besides systemctl returns
postgresql.service loaded active exited PostgreSQL RDBMS
● postgresql#9.5-main.service loaded failed failed PostgreSQL Cluster 9.5-main
Why is it failed?

Related

Failing to start an app as service through systemd using userdata

I want to start my app as service from systemd but the app is not starting.
My unit file appstart.service looks like this:
[Unit]
Description=Application start
[Service]
Type=simple
User=ec2-user
ExecStart=/usr/bin/bash /home/ec2-user/project/restartScript.sh
SyslogIdentifier=App_start
[Install]
WantedBy=multi-user.target
RestartScript.sh should start the java app:
#!/bin/bash
export SPRING_PROFILES_ACTIVE="tst,development"
cd /home/ec2-user/project
pkill java
/usr/bin/java -jar /home/ec2-user/project/app.jar >>/home/ec2-user/project/web.log 2>>/home/ec2-user/project/web-error.log &
I am starting the app as a service this way using User Data on AWS EC2 instance:
#!/bin/bash
mkdir /home/ec2-user/project
cd /home/ec2-user/project
sudo wget -P /home/ec2-user/project/ https://tst.s3.eu-west-1.amazonaws.com/app.jar
chown -R ec2-user:ec2-user /home/ec2-user/project
sudo wget -P /home/ec2-user/project/ https://tst.s3.eu-west-1.amazonaws.com/restartScript.sh
sudo chmod 755 /home/ec2-user/project/restartScript.sh
cd /etc/systemd/system/
sudo wget /etc/systemd/system/ https://tst.s3.eu-west-1.amazonaws.com/appstart.service
sudo su
systemctl daemon-reload
systemctl enable appstart.service
systemctl start appstart.service
exit
The output I am getting when I start the EC2 instance this way is:
$ systemctl status appstart.service
● appstart.service - Application start
Loaded: loaded (/etc/systemd/system/appstart.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Thu 2022-08-25 13:35:52 UTC; 4min 19s ago
Process: 7328 ExecStart=/usr/bin/bash /home/ec2-user/project/restartScript.sh (code=exited, status=0/SUCCESS)
Main PID: 7328 (code=exited, status=0/SUCCESS)
Aug 25 13:35:52 ip-x-x-x-x.tst.local systemd[1]: Started Application start.
When I try to do
systemctl start appstart.service
Nothing changes. The application is not working.
Any idea why is this happening?
OS on the machine:
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
Nothing seems to be wrong with this, the service is running and the application runs and finishes successfully. The Active state of the service becomes inactive (dead) in case of failure it should be Failed and Main PID is (code=exited, status=0/SUCCESS).
To verify that the service is running correct, write this line somewhere in RestartScript.sh:
echo "Test" > test.txt
After starting the service you will find the created file near RestartScript.sh file.
I managed to resolve the issue by changing the WantedBy section in appstart.service file to default.target.

MongoDB not starting properly on Ubuntu 18.04.2 LTS

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

Falcon sensor fails to start the agent

I am trying to install falcon-sensor(version:4.16.0) on a Debian machine. When I try to start the agent it doesn't start up.
I checked the logs of falcon-sensor and here is what it says :
2019 unable to initialize dynamic libraries. (2309) [144]
I checked the log of falconctl and here is what it says :
Invalid file /opt/CrowdStrike/falconstore length: 0 (2277) [568]
I tried finding answers through googling but I could not find any.
Any help on this would be really helpful
Thanks in advance.
falcon-sensor has libssl.so.1.0.0 as dependency, but that version is missing on Debian Stretch (there is version 1.0.2).
I just created a symlink to the existing version:
ln -s libssl.so.1.0.2 /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
and now it works.
Make sure you performed the basic steps correctly:
1 ) Download falcon-sensor.rpm to your machine.
2 ) sudo yum install -y falcon-sensor.rpm .
3 ) sudo /opt/CrowdStrike/falconctl -s --cid=<Your-CID> .
4 ) service falcon-sensor start.
Check status:
[ec2-user#ip-172-21-80-18 ~]$ service falcon-sensor status
Redirecting to /bin/systemctl status falcon-sensor.service
● falcon-sensor.service - CrowdStrike Falcon Sensor
Loaded: loaded (/usr/lib/systemd/system/falcon-sensor.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-09-05 13:48:34 UTC; 1min 6s ago
Process: 2746 ExecStart=/opt/CrowdStrike/falcond (code=exited, status=0/SUCCESS)
Process: 2729 ExecStartPre=/opt/CrowdStrike/falconctl -g --cid (code=exited, status=0/SUCCESS)
Main PID: 2747 (falcond)
Tasks: 19
Memory: 4.5M
CGroup: /system.slice/falcon-sensor.service
├─2747 /opt/CrowdStrike/falcond
└─2749 falcon-sensor
systemd[1]: Starting CrowdStrike Falcon Sensor...
falconctl[2729]: cid="<Your-CID>".
falcond[2747]: starting
Started CrowdStrike Falcon Sensor.
falcon-sensor[2749]: No traceLevel set via falconctl defaulting to none
falcon-sensor[2749]: LogLevelUpdate: none = trace level 0.
View process:
ps -e | grep falcon-sensor
2749 ? 00:00:00 falcon-sensor
Notice that all commands should be executed with sudo Or else you see the error below:
$ service falcon-sensor restart #< --- No root permission
Redirecting to /bin/systemctl restart falcon-sensor.service
Failed to restart falcon-sensor.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status falcon-sensor.service' for details.
I follow install steps 1~3 below without issue, but have not get a CID, please let met know how to get it
1 ) Download falcon-sensor.rpm to your machine.
2 ) sudo yum install -y falcon-sensor.rpm .
3 ) sudo /opt/CrowdStrike/falconctl -s --cid=<Your-CID>
4 ) service falcon-sensor start.

how I can make rabbitmq-server auto start at boot time?(centos 7)

I have tried too many times,but I failed.
I run order in shell ,it works,but I write it to supervisor or /etc/rc.d/init.d/functions ,both failed!
/usr/sbin/rabbitmq-server start (shell works)
supervisor or /etc/rc.d/init.d/functions ,both failed!
RabbitMQ on Centos7 uses the systemd.
You have to enable the service:
sudo systemctl enable rabbitmq-server
Then try to reboot:
Last login: Tue Sep 5 07:51:49 2017 from 10.0.2.2
[vagrant#localhost ~]$ sudo systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2017-09-05 07:57:05 UTC; 20s ago
Main PID: 930 (beam.smp)
Status: "Initialized"
CGroup: /system.slice/rabbitmq-server.service
├─ 930 /usr/lib64/erlang/erts-9.0.4/bin/beam.smp -W w -A 64 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.11.902/ebin -noshell -n...
├─1317 /usr/lib64/erlang/erts-9.0.4/bin/epmd -daemon
├─2354 erl_child_setup 1024
├─2437 inet_gethost 4
└─2438 inet_gethost 4
EDIT
It is the same for 3.3.5, see here:
[vagrant#localhost ~]$ sudo systemctl status rabbitmq-server
● rabbitmq-server.service - LSB: Enable AMQP service provided by RabbitMQ broker
Loaded: loaded (/etc/rc.d/init.d/rabbitmq-server; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
[vagrant#localhost ~]$ sudo systemctl enable rabbitmq-server
rabbitmq-server.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig rabbitmq-server on
[vagrant#localhost ~]$ sudo reboot
➜ centos7 vagrant ssh
Last login: Tue Sep 5 08:04:37 2017 from 10.0.2.2
[vagrant#localhost ~]$ sudo systemctl status rabbitmq-server
● rabbitmq-server.service - LSB: Enable AMQP service provided by RabbitMQ broker
Loaded: loaded (/etc/rc.d/init.d/rabbitmq-server; bad; vendor preset: disabled)
Active: active (running) since Tue 2017-09-05 08:48:23 UTC; 9s ago
Docs: man:systemd-sysv-generator(8)
Process: 972 ExecStart=/etc/rc.d/init.d/rabbitmq-server start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/rabbitmq-server.service
├─1325 /bin/sh /etc/rc.d/init.d/rabbitmq-server start
├─1335 /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/sbin/rabbitmq-server
└─1339 /bin/sh /usr/sbin/rabbitmq-server
RabbitMQ version:
sudo rabbitmqctl status
Status of node rabbit#localhost ...
[{pid,1379},
{running_applications,[{rabbit,"RabbitMQ","3.3.5"},
Note:
You are using a very old RabbitMQ version, please consider to update it to the last one

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