You are not logged in.

#1 2012-09-23 10:50:19

lothar_m
Member
From: Cyberspace
Registered: 2010-04-25
Posts: 32

[SOLVED] Postgresql and systemd - Unable to start or enable service

I'm trying to run postgresql in a pure systemd machine.

i've done a fresh install of postgresql using pacman as instructed in the wiki. However when i try to start the service i get the following:

user@frodo:~$ sudo systemctl start postgresql.service
Failed to issue method call: Unit postgresql.service failed to load: No such file or directory. See system logs and 'systemctl status postgresql.service' for details.

user@frodo:~$ sudo systemctl status postgresql.service
postgresql.service
          Loaded: error (Reason: No such file or directory)
          Active: inactive (dead)

So it seems the package has no systemd service files included. Did anyone got around to make one of these?

Last edited by lothar_m (2012-09-26 22:01:21)


“Clearly, Field Marshal Haig is about to make yet another gargantuan effort to move his drinks cabinet six inches closer to Berlin.”

Offline

#2 2012-09-23 11:00:51

Teho
Member
Registered: 2010-01-30
Posts: 200

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

The PostgreSQL package on [testing] has a service file for systemd.

Offline

#3 2012-09-23 11:35:44

lothar_m
Member
From: Cyberspace
Registered: 2010-04-25
Posts: 32

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

Thanks. I've reinstalled the package from testing.

However i'm still unable to start the postgresql server. this time it goes like this:

user@frodo:~$ sudo systemctl start postgresql.service
Job failed. See system journal and 'systemctl status' for details.

user@frodo:~$ systemctl status postgresql.service
postgresql.service - PostgreSQL database server
          Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
          Active: failed (Result: exit-code) since Sun, 23 Sep 2012 12:21:38 +0100; 2min 36s ago
         Process: 631 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)
          CGroup: name=systemd:/system/postgresql.service

here's the content of /etc/conf.d/postgres and /usr/lib/systemd/system/postgresql.service

##
## Parameters to be passed to postgresql
##
## Default data directory location
PGROOT="/var/lib/postgres"
## Passed to initdb if necessary
INITOPTS="--locale en_US.UTF-8"
## Default log file location
PGLOG="/var/log/postgresql.log"
## Additional options to pass via pg_ctl's '-o' option
#PGOPTS=""
[Unit]
Description=PostgreSQL database server
After=network.target

[Service]
Type=forking
TimeoutSec=120
User=postgres
Group=postgres

Environment=PGROOT=/var/lib/postgres
Environment=PGLOG=/var/log/postgresql.log

SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid

ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data
ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
ExecStop=  /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast

# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres, so adjust it downward
OOMScoreAdjust=-200

[Install]
WantedBy=multi-user.target

“Clearly, Field Marshal Haig is about to make yet another gargantuan effort to move his drinks cabinet six inches closer to Berlin.”

Offline

#4 2012-09-23 17:52:27

z0id
Member
From: Romania
Registered: 2010-02-02
Posts: 122

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

Uncomment PGROOT in /etc/conf.d/postgresql.
EDIT: nevermind big_smile

Last edited by z0id (2012-09-23 17:55:30)


/usr/bin/drinking

Offline

#5 2012-09-23 18:25:53

lothar_m
Member
From: Cyberspace
Registered: 2010-04-25
Posts: 32

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

z0id wrote:

Uncomment PGROOT in /etc/conf.d/postgresql.
EDIT: nevermind big_smile

Yeah... thanks anyway wink


“Clearly, Field Marshal Haig is about to make yet another gargantuan effort to move his drinks cabinet six inches closer to Berlin.”

Offline

#6 2012-09-26 21:11:38

lothar_m
Member
From: Cyberspace
Registered: 2010-04-25
Posts: 32

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

Up


“Clearly, Field Marshal Haig is about to make yet another gargantuan effort to move his drinks cabinet six inches closer to Berlin.”

Offline

#7 2012-09-26 21:55:26

lothar_m
Member
From: Cyberspace
Registered: 2010-04-25
Posts: 32

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

well, i've managed to fix the problem.

it seems that the wiki is missing a couple of steps. so i manually done the following:

i) create the data directory (acordingly  with the PGROOT variable set before in the config file)

user@frodo:~$ sudo mkdir /var/lib/postgres/data

ii) set /var/lib/postgres/data ownership to user 'postgres'


iii) As user 'postgres' start the database.

user@frodo:~$ sudo -i -u postgres
[postgres@frodo ~]$ initdb  -D '/var/lib/postgres/data'

iv) start the service as root

user@frodo:~$ sudo systemctl start postgresql.service

that should be it.

Issuing a systemctl status should return

user@frodo:~$ sudo sudo systemctl status postgresql.service
postgresql.service - PostgreSQL database server
          Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled)
          Active: active (running) since Wed, 26 Sep 2012 22:50:09 +0100; 6s ago
         Process: 11187 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (code=exited, status=0/SUCCESS)
         Process: 11183 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
        Main PID: 11193 (postgres)
          CGroup: name=systemd:/system/postgresql.service
                  ├ 11193 /usr/bin/postgres -D /var/lib/postgres/data
                  ├ 11198 postgres: checkpointer process   
                  ├ 11199 postgres: writer process   
                  ├ 11200 postgres: wal writer process   
                  ├ 11201 postgres: autovacuum launcher process   
                  └ 11202 postgres: stats collector process   

Sep 26 22:50:08 frodo postgres[11187]: LOG:  database system was shut down at 2012-09-26 22:49:13 WEST
Sep 26 22:50:08 frodo postgres[11187]: LOG:  database system is ready to accept connections
Sep 26 22:50:08 frodo postgres[11187]: LOG:  autovacuum launcher starte

Last edited by lothar_m (2012-12-30 09:52:52)


“Clearly, Field Marshal Haig is about to make yet another gargantuan effort to move his drinks cabinet six inches closer to Berlin.”

Offline

#8 2014-05-21 18:16:10

jlgasparrini
Member
Registered: 2014-05-21
Posts: 1

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

Thanks 'u @lothar_m
Your solution works for me! smile

Offline

#9 2014-05-21 21:41:03

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Postgresql and systemd - Unable to start or enable service

Closing this two year old thead


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB