You are not logged in.
I'm trying to start the postgresql service on my systemd installation. I've followed the instructions on the wiki. First I installed the package postgresql, then I uncommented the PGROOT line in the configuration file.
When I try to run systemctl start postgresql, I get the following:
# systemctl start postgresql
Job for postgresql.service failed. See 'systemctl status postgresql.service' and 'journalctl -n' for details.
# systemctl status postgresql
postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled)
Active: failed (Result: exit-code) since Sun, 2012-10-28 14:08:48 CET; 34s ago
Process: 12687 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/postgresql.service
Oct 28 14:08:48 nemesis systemd[1]: Starting PostgreSQL database server...
Oct 28 14:08:48 nemesis postgres[12687]: "/var/lib/postgres/data" is missing or empty. Use a command like
Oct 28 14:08:48 nemesis postgres[12687]: su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
Oct 28 14:08:48 nemesis postgres[12687]: with relevant options, to initialize the database cluster.
Oct 28 14:08:48 nemesis systemd[1]: Failed to start PostgreSQL database server.
Oct 28 14:08:48 nemesis systemd[1]: Unit postgresql.service entered failed state
I tried doing what it suggested to me:
# su - postgres -c "initdb --locale en_US.UTF-8 -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 database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
creating directory /var/lib/postgres/data ... initdb: could not create directory "/var/lib/postgres/data": Permission denied
I also tried with the directory that was set in the configuration file, with similar results:
# su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres'"
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 database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
fixing permissions on existing directory /var/lib/postgres ... initdb: could not change permissions of directory "/var/lib/postgres": Operation not permitted
I don't know what to try next. I'm not sure what it needs me to do that it can't do itself. I've never worked with any kind of database system, I'm just installing PostgreSQL to start tinkering with it a bit for some pet projects.
Thanks for your time
Last edited by robrene (2012-10-28 13:24:52)
Offline
Whelp, stupid me. Right after posting I managed to fix it myself. I'll post the solution and leave it here in case other people run into the same problem. The solution was to change the owner of the PGROOT directory and then running the initdb command again:
# chown -R postgres:postgres /var/lib/postgres/
# su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
Offline