how to set postgresql 9.6.2 to autostart when built from source on CentOS 7
I've installed postgresql 9.6.2 from running from source. I performed the .configure
, make
and make install
commands, which installed the database perfectly. I then installed the user, created the db using createdb
command, and am able to log in locally to postgresql user to perform local sql queries.
My question is autostart. How do I set it up so autostart is working? the command service postgresql restart
errors saying no unit
. I also tried postgresql-9.6
, postgresql-9.6.2
, postgresql-962
, and several others to no avail.
how to I configure this? Thanks.
Solution 1:
When using systemd, you can use the following service unit file (e.g., at /etc/systemd/system/postgresql.service):
[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)
[Service]
Type=notify
User=postgres
ExecStart=/usr/pgsql-9.5/bin/pg_ctl -D /bd-01/pgsql/9.5/data -l logfile start
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
[Install]
WantedBy=multi-user.target