On Sun, 3 Apr 2022 at 17:50, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> On Sun, Apr 3, 2022 at 8:36 AM Francisco Olarte <folarte@peoplecall.com> wrote:
>>
>> On Sun, 3 Apr 2022 at 16:50, Wong Simon <thbytwo@live.cn> wrote:
>> > If I run multiple instances on one server with local socket, how can I distinguish them?I think the port is need.
>> You distinguish them by the socket NAME whose "extension" is the port
>> as a decimal string. The socket name is derived from the port option,
>> but it is not a port. It's clearly specified:
> Resorting to string parsing is never desirable, nor is it necessary here.
Socket name seems not to be accessible, as let per a cursory look at
the docs, anyway, but I just looked for unix and for socket in the
index.
And as extension must be port, you are right, no info there.
>> But if you just need to distinguish instance on diferent ports, query
>> the "port" configuration parameter, IIRC this is unique ( although may
>> be you can somehow reuse it with careful usage of listen_addresses and
>> unix_socket_directories ).
> Per the docs It is indeed single-valued. I don't know what "reuse" would mean in this context but both sockets and
IPhave a specific usage of this setting's value that the DBA cannot alter.
Port is single valued, what I meant is I'm not sure if using
socket_dir=/socka, listen_addr=127.0.0.1, data_dir=/dataA and
port=5432 plus socket_dir=/sockb, listen_addr=127.0.0.2,
data_dir=/datab and port=5432 would let you start two correctly
functioning instances in the same machine. In my usage postgres
normally behaves as expected, does not bother doing extra checks, just
listens where it is told to and hums along ( I know of some stupid
programs which, in a situation like this, have code to check if there
is another process listening in the same port, where there is no
transport address collision at all ).
Francisco Olarte.