You are not logged in.

#1 2017-01-26 06:41:00

code_master5
Member
Registered: 2017-01-26
Posts: 9

Unable to start postgresql.service!

I'm trying to set up postgresql as instructed <a>here</a>.
After performing

[postgres@BitBox ~]$ initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data'
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgres/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

pg_ctl -D /var/lib/postgres/data -l logfile start

successfully, I returned to the my regular user using exit command.

[postgres@BitBox ~]$ exit
logout

Then, while trying to start postgresql.service, I got the following error:

[code_master5@BitBox ~]$ sudo systemctl start postgresql.service
Failed to start postgresql.service: Unit postgresql.service not found.

I'm not even getting the status of the service:

[code_master5@BitBox ~]$ sudo systemctl status postgresql.service
Unit postgresql.service could not be found.

Please help me out. I'm stuck!

Offline

#2 2017-01-26 08:27:56

ayekat
Member
Registered: 2011-01-17
Posts: 1,633

Re: Unable to start postgresql.service!

Please paste the output of

pacman -Ql postgresql | grep systemd

Last edited by ayekat (2017-01-26 08:28:22)


pkgshackscfgblag

Offline

#3 2017-01-26 13:11:47

code_master5
Member
Registered: 2017-01-26
Posts: 9

Re: Unable to start postgresql.service!

[code_master5@BitBox UrlShortenerApi]$ pacman -Ql postgresql | grep systemd
postgresql /usr/lib/systemd/
postgresql /usr/lib/systemd/system/
postgresql /usr/lib/systemd/system/postgresql.service

Offline

#4 2017-01-26 13:17:44

ayekat
Member
Registered: 2011-01-17
Posts: 1,633

Re: Unable to start postgresql.service!

Hmm, that is odd. Perhaps it is masked, or otherwise modified/null.

What is the output of these commands?

find /etc/systemd/system /run/systemd/system -name 'postgresql.service'
ls -ld /usr/lib/systemd/system/postgresql.service
cat /usr/lib/systemd/system/postgresql.service

pkgshackscfgblag

Offline

#5 2017-01-26 15:37:11

code_master5
Member
Registered: 2017-01-26
Posts: 9

Re: Unable to start postgresql.service!

Sorry for late replies. Due to bad weather I'm facing connection problems.

[code_master5@BitBox ~]$ find /etc/systemd/system /run/systemd/system -name 'postgresql.service'
/etc/systemd/system/multi-user.target.wants/postgresql.service
[code_master5@BitBox ~]$ ls -ld /usr/lib/systemd/system/postgresql.service
-rw-r--r-- 1 root root 834 Nov  8 00:20 /usr/lib/systemd/system/postgresql.service
[code_master5@BitBox ~]$ cat /usr/lib/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target

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

Environment=PGROOT=/var/lib/postgres

SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
RuntimeDirectory=postgresql
RuntimeDirectoryMode=755

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

# Additional security-related features
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Last edited by code_master5 (2017-01-26 15:38:33)

Offline

#6 2017-01-26 15:51:06

loqs
Member
Registered: 2014-03-06
Posts: 18,970

Re: Unable to start postgresql.service!

Removing the use of sudo what is the output of

$ systemctl status postgresql.service

If that fails what is the output of

$ type systemctl

Offline

#7 2017-01-26 16:19:42

code_master5
Member
Registered: 2017-01-26
Posts: 9

Re: Unable to start postgresql.service!

[code_master5@BitBox ~]$ systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor pre
   Active: active (running) since Thu 2017-01-26 18:11:05 IST; 3h 29min ago
  Process: 337 ExecStart=/usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120 (cod
  Process: 328 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=
 Main PID: 340 (postgres)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/postgresql.service
           ├─340 /usr/bin/postgres -D /var/lib/postgres/data
           ├─344 postgres: checkpointer process   
           ├─345 postgres: writer process   
           ├─346 postgres: wal writer process   
           ├─347 postgres: autovacuum launcher process   
           └─348 postgres: stats collector process   

Warning: Journal has been rotated since unit was started. Log output is incomplete
[code_master5@BitBox ~]$ type systemctl
systemctl is hashed (/usr/bin/systemctl)

Last edited by code_master5 (2017-01-26 16:20:34)

Offline

#8 2017-01-26 16:25:33

code_master5
Member
Registered: 2017-01-26
Posts: 9

Re: Unable to start postgresql.service!

Hey! I figured it out! Thank you very much @ayekat @loqs and ARCH forum.
I simply deleted the postgresql-9.6.service file and restarted the system.
I guess it replaced it with postgresql.service file. Somehow it worked.

Hey can anyone please explain me why it worked? and what is the meaning of output:

[code_master5@BitBox ~]$ type systemctl
systemctl is hashed (/usr/bin/systemctl)

Thanks again...

Offline

#9 2017-01-26 19:51:21

loqs
Member
Registered: 2014-03-06
Posts: 18,970

Re: Unable to start postgresql.service!

code_master5 wrote:

I simply deleted the postgresql-9.6.service file and restarted the system.

postgresql-9.6.service has not been mentioned before.

code_master5 wrote:

what is the meaning of output:

[code_master5@BitBox ~]$ type systemctl
systemctl is hashed (/usr/bin/systemctl)

Means systemctl has been recorded by the hash command.  The man pages for type and hash have more details,  might also see the man page for the shell you use as type is provided as a shell builtin.

Offline

#10 2017-01-27 06:22:34

code_master5
Member
Registered: 2017-01-26
Posts: 9

Re: Unable to start postgresql.service!

Thanks @loqs for reply.
I'm really sorry because I really didn't know that any postgresql-9.6.service file existed and I simply do not know how it came there! I simply took hint from your and other replies and digged into systemd folder. Then I just tried to start postgresql-9.6.service, which again failed. So, I just took a sort of risk here by deleting it as I didn't know what's gonna happen. Then I simply restarted system. Quite amazingly it worked!

Offline

Board footer

Powered by FluxBB