1

Trying to install postgres on Amazon Workspace Linux but struggling for these reasons:

  • 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.

$ 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                                                                                          

^ This gets me to a promising point because it mentions some amzn packages. And most tutorials were installing both postgresql and postgresql-server.

$ which psql
/usr/bin/psql


$ which postgres
/usr/bin/postgres

At this point, most tutorials go into initdb and pg_ctl <path> 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

  • 3
    Solutions go into the answer box at the bottom of the page. It's perfectly fine to self-answer your own questions. Doing so would allow you to accept the answer (after a slight delay), which would mark the issue as resolved. I will remove the "SOLVED" tagging from the title, and I suggest that you move the solution into a proper answer. – Kusalananda Mar 5 at 23:53
  • 1
    According to your output, the postgresql server is running and the database is already initialized (/var/lib/pgsql/data). To connect to postgresql, try this as root: su -c "psql" postgres. This will invoke the psql client using the user postgres (IIRC, that is the default user those packages would be using). – GracefulRestart Mar 6 at 19:53
0

CentOS (Community ENTerprise Operating System) is a community (re)build of RHEL (Red Hat Enterprise Linux), with changed branding and some other details. It strives at being binary fully compatible, down to bug-for-bug. It doesn't have access to the RHEL package repositories, it uses their own. EPEL (Extra Packages for Enterprise Linux) is a Fedora project that offers packages for RHEL/CentOS that RHEL doesn't carry.

I don't know where the "dnf is blocked from install" comes from. Note that in RHEL/CentOS dnf is relatively new (I believe an alternative starting with version 7), perhaps only the (legacy) yum is available? You could try yum install dnf if you need it. Depending on your exact version of CentOS, it might not be there at all.

The last error message you cite is quite clear: Postgres can't find/read it's configuration. Check carefully that the setup is done correctly. A wrong file name somewhere can derail everything.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.