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

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Steve Langlois <steve(dot)langlois(at)tavve(dot)com>, "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-19 21:58:41
Message-ID: ba696b74-8978-5892-9476-cf28ae4e2a27@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/19/2016 02:49 PM, Steve Langlois wrote:
> Using Postgres 9.2 with CentOS7.
>
>
> 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

How are you starting Postgres?

If from system init script then the directory made be set there.
See below also.

>
> I know I can change permissions of /var/run of course but I want to
> change the location of the lock file to a directory I already have
> access to. So I really want to change the default location of the lock
> file to something other than /var/run. I've checked the options to
> initdb as well as looking at the various files in the data directory,
> pg_hba.conf, pg_ident.conf, etc.

https://www.postgresql.org/docs/9.2/static/runtime-config-connection.html

unix_socket_directory (string)

Specifies the directory of the Unix-domain socket on which the
server is to listen for connections from client applications. The
default is normally /tmp, but can be changed at build time. This
parameter can only be set at server start.

In addition to the socket file itself, which is named .s.PGSQL.nnnn
where nnnn is the server's port number, an ordinary file named
.s.PGSQL.nnnn.lock will be created in the unix_socket_directory
directory. Neither file should ever be removed manually.

This parameter is irrelevant on Windows, which does not have
Unix-domain sockets.

>
> Thank you.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-07-19 22:01:09 Re: Is it possible to control the location of the lock file when starting postgres?
Previous Message Steve Langlois 2016-07-19 21:56:48 Re: Is it possible to control the location of the lock file when starting postgres?