Thread: Issues starting database for the first time on Linux

Issues starting database for the first time on Linux

From
Isaac Braham
Date:
I'm following the instructions for setting up Postgres 11 on my Linux machine. I'm new to database management, and just need to run a postgres server to link up to a client on another machine, nothing complicated (hopefully).

I'm following the long version, but will use the short version of the documentation to describe where I've got to.

./configure
make
su
make install

> All the above was done through the repository installer on Linux (Manjaro).

adduser postgres

> Not sure why or how, but I found a user 'postgres' already existed on my system, so left it there.

mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

> No apparent problem here, the text output ends with "Success. You can now start the database server using: pg_ctl -D /usr/local/pgsql/data -l logfile start"

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &

>I presume this is a similar instruction to the above (just specifying the path to the binary), either way - nothing I try here works
pg_ctl -D /usr/local/pgsql/data -l logfile start - leads to "waiting for server to start..../bin/sh: logfile: Permission denied stopped waiting pg_ctl: could not start server"

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & - leads to "[1] 2996 [postgres@desk ~]$ -bash: logfile: Permission denied"

postgres -D /usr/local/pgsql/data (starting it in the foreground) - leads to

2019-12-04 10:07:57.604 GMT [3005] LOG:  listening on IPv6 address "::1", port 5432
2019-12-04 10:07:57.604 GMT [3005] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2019-12-04 10:07:57.606 GMT [3005] FATAL:  could not create lock file "/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
2019-12-04 10:07:57.606 GMT [3005] LOG:  database system is shut down

Why am I getting permission denied at every turn, I've tried to follow the instructions to the letter?

Re: Issues starting database for the first time on Linux

From
Tom Lane
Date:
Isaac Braham <isaac.o.braham@gmail.com> writes:
...
> chown postgres /usr/local/pgsql/data
> su - postgres
> /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

> pg_ctl -D /usr/local/pgsql/data -l logfile start - leads to "waiting
> for server to start..../bin/sh: logfile: Permission denied stopped
> waiting pg_ctl: could not start server"

Apparently, you haven't got sufficient privilege to create "logfile".
Given that you just did "su - postgres", that seems to mean that
whatever directory is recorded as being postgres' home directory
(look in /etc/passwd to find out) isn't writable by postgres.
Or, maybe there already is a "logfile" there, but it's not
writable by postgres.  Anyway, get the permissions straightened out,
or tell it to write to a log file located someplace else.

            regards, tom lane



Re: Issues starting database for the first time on Linux

From
"David G. Johnston"
Date:
On Wed, Dec 4, 2019 at 3:47 AM Isaac Braham <isaac.o.braham@gmail.com> wrote:
I'm following the instructions for setting up Postgres 11 on my Linux machine. I'm new to database management, and just need to run a postgres server to link up to a client on another machine, nothing complicated (hopefully).
 
I'd highly recommend you use a packaged installation instead of installing from source.

David J.