Francisco Olarte <folarte@peoplecall.com> writes:
>> 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.
> 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.
I think relying on port for this purpose is misguided anyway.
We've had requests in the past to let one postmaster listen on
multiple different port numbers; I think the only reason it's
not happened yet is nobody got excited enough to write a patch.
Likewise, inet_server_addr() seems a bit shaky as a server
identity value, since it's already possible to have a postmaster
listening on multiple IP addresses.
If you're trying to identify an installation uniquely, the
machine name and data_directory are probably the best key.
Getting a suitably unique machine name might be tricky.
For localhost connections, though, you could ignore that.
regards, tom lane