Re: Is it possible to control the location of the lock file when starting postgres?

From: Steve Langlois <steve(dot)langlois(at)tavve(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is it possible to control the location of the lock file when starting postgres?
Date: 2016-07-20 17:44:33
Message-ID: CY1PR0701MB1932CD152689FC0324DE11A787080@CY1PR0701MB1932.namprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Langlois <steve(dot)langlois(at)tavve(dot)com> writes:

> I ran
> + /usr/bin/initdb --pgdata=/usr/xxx/databases/pgsql/data --auth=ident
> without issue however when I try to start the database it complains about the lockfile.
> FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied

I was able to resolve this issue using -k /tmp with postmaster:

postmaster -k "/tmp" -D "/usr/xxx/databases/pgsql/data"

In postgresql.conf I have

listen_addresses = 'localhost'
unix_socket_directories = '/tmp'

However when I try to connect with psql

[13:27:08 slanglois(at)tron data]$ psql postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

The lock file is in /tmp

[13:28:02 slanglois(at)tron data]$ ls -al /tmp/.*PGSQL*
srwxrwxrwx 1 slanglois eng 0 Jul 20 13:19 /tmp/.s.PGSQL.5432
-rw------- 1 slanglois eng 59 Jul 20 13:19 /tmp/.s.PGSQL.5432.lock

even though I have the following in pg_hba.conf

local all all trust

I tried to specify the host but it still doesn't connect

[13:32:24 slanglois(at)tron data]$ psql -h localhost postgres
psql: FATAL: no pg_hba.conf entry for host "::1", user "slanglois", database "postgres", SSL off

To get it to connect I have to add the following to pg_hba.conf

host all all ::1/128 trust

I was going to put this under a new subject but it seems to me like it is still related to the lock file being expected in /var/run/postgres when it is trying to connect even though I changed it to /tmp.

Why is the local connection not working without having to add host ::1/128 to the pg_hba.conf file. I thought specifying local all all trust would allow any local connection.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sameer Kumar 2016-07-20 18:02:17 Re: pg_dump without any SET command in header of output plain text sql file
Previous Message Tom Lane 2016-07-20 17:40:01 Re: pg_dump without any SET command in header of output plain text sql file