Most tutorials were installing both postgresql and postgresql-server:
$ sudo yum install postgresql postgresql-server
Installed:
postgresql.x86_64 0:9.2.24-1.amzn2.0.1
postgresql-server.x86_64 0:9.2.24-1.amzn2.0.1
Dependency Installed:
postgresql-libs.x86_64 0:9.2.24-1.amzn2.0.1
The programs are installed here:
$ which psql
/usr/bin/psql
$ which postgres
/usr/bin/postgres
At this point, most tutorials go into initdb
and pg_ctl start
$ cd '/usr/lib'
$ service postgresql initdb
Hint: the preferred way to do this is now "postgresql-setup initdb"
$ sudo postgresql-setup initdb
[sudo] password for CORP\layne.sadler:
Initializing database ... OK
$ systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to usr/lib/systemd/system/postgresql.service.
$ systemctl start postgresql
[18:47:32] /usr/bin ☯ systemctl status postgresql
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-05 18:47:32 EST; 7s ago
Process: 25559 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
Process: 25553 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 25562 (postgres)
CGroup: /system.slice/postgresql.service
├─25562 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
├─25564 postgres: logger process
├─25566 postgres: checkpointer process
├─25567 postgres: writer process
├─25568 postgres: wal writer process
├─25569 postgres: autovacuum launcher process
└─25570 postgres: stats collector process
$ passwd postgres
note: /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
**STUCK**
$postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
$ psql
psql: FATAL: role "CORP\layne.sadler" does not exist
$ sudo pg_ctl -D postgresql-setup initdb
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
# can't seem to login as su despite other sudo commands working
Notes:
- The OS claims to be rhel fedora centos
but doesn't have the rhel-release
libraries.
- It seems like epel-release
and dnf
are blocked from install.
- ^^^ postgres installation instructions want the above tools.
Asked by LayneSadler
(148 rep)
Mar 5, 2020, 11:28 PM
Last activity: Jul 28, 2025, 05:04 PM
Last activity: Jul 28, 2025, 05:04 PM