0
root@instance $ systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-03-05 02:57:55 UTC; 10s ago
  Process: 1116 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
  Process: 1111 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)

Mar 05 02:57:54 instance-1 systemd[1]: Starting PostgreSQL database server...
Mar 05 02:57:55 instance-1 systemd[1]: postgresql.service: control process exited, code=exited status=1
Mar 05 02:57:55 instance-1 systemd[1]: Failed to start PostgreSQL database server.
Mar 05 02:57:55 instance-1 systemd[1]: Unit postgresql.service entered failed state.
Mar 05 02:57:55 instance-1 systemd[1]: postgresql.service failed.

I did about the same steps listed here: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-7

I installed everything as root user, should I install as other user?

# pg_ctl reload
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
Mzq
  • 1,796
  • 4
  • 30
  • 65

1 Answers1

2

For run postgresql need to Switch user to postgres

Su postgres 

And

Pg_ctl start 
Hasan Barary
  • 812
  • 8
  • 8
  • but I still can't do `sudo -u postgres systemctl start postgresql`, if switch to user `postgres`, seems I need to do a bunch of other setups https://stackoverflow.com/questions/14948406/how-to-start-postgres-server – Mzq Mar 05 '18 at 03:47
  • End up just changed to a different VM, everthing just worked. Not sure if it is me messed up settings without notice or the google cloud instance issue. New VM is not gcloud instance. – Mzq Mar 15 '18 at 04:10