This set of steps worked for me on a Fedora 22 virtual machine. Hopefully they work for you as well. =) I picked 9.2 as the first one to fix. 9.1 worked exactly the same.
Fortunately, the init script included in PostgreSQL source releases is fully LSB compliant, which is pretty much a requirement for legacy systemd integration.
Your first step should be to properly configure the init script in contrib/start-scripts/linux
for your particular environment setup.
Once that is finished, copy the the edited file into /etc/rc.d/init.d/postgresql92
, and execute the command systemctl daemon-reload
to force systemd to re-read the unit files and directories containing the files.
Immediately following that, run the command systemctl enable postgresql92
. Once that is done, you should see a message like this:
[root@test ~]# systemctl enable postgresql92
postgresql92.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig postgresql92 on
[root@test ~]#
Which indicates that systemd did actually register the init script, and that it created all the necessary symlinks to start at boot.
Following that, you should be able to start the service with systemctl start postgresql92
And then check on the status of the process with systemctl status postgresql92
Which should look something like this:
[root@test ~]# systemctl status postgresql92
● postgresql92.service - SYSV: PostgreSQL RDBMS
Loaded: loaded (/etc/rc.d/init.d/postgresql92)
Active: active (exited) since Sat 2015-09-05 08:13:34 UTC; 1min 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 16665 ExecStart=/etc/rc.d/init.d/postgresql92 start (code=exited, status=0/SUCCESS)
Sep 05 08:13:34 test systemd[1]: Starting SYSV: PostgreSQL RDBMS...
Sep 05 08:13:34 test su[16666]: (to postgresql) root on none
Sep 05 08:13:34 test systemd[1]: Started SYSV: PostgreSQL RDBMS.
Sep 05 08:13:34 test postgresql92[16665]: Starting PostgreSQL: ok
[root@test ~]#
And, finally, double-check by using psql
on the running instance.
[postgresql@test bin]$ ./psql -U postgresql template1
psql (9.2.13)
Type "help" for help.
template1=# SELECT * FROM version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.2.13 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4), 64-bit
(1 row)
template1=# \q
[postgresql@test bin]$
The SysVinit to systemd Cheat Sheet, the Compatibility with SysV, and the ArchLinux Wiki's systemd entry should help you figure out how to wrangle systemd better too.
Hope that helps. =)