On Feb 3, 2006, at 08:05, Mark Woodward wrote:

Using the "/etc/hosts" file or DNS to maintain host locations for is a
fairly common and well known practice, but there is no such mechanism for "ports." The problem now becomes a code issue, not a system administration
issue.

What if you assigned multiple IPs to a machine, then used ipfw (or something) to forward connections to port 5432 for each IP to the proper IP and port?

You could use /etc/hosts or DNS to give each IP a host name, and use it in your code.

For example (this only does forwarding for clients on localhost, but you get the idea), you could set up:

Host      IP:port          Forwards to
--------  ---------------  -----------------
db_one    127.0.1.1:5432   192.168.1.5:5432
db_two    127.0.1.2:5432   192.168.1.6:5432
db_three  127.0.1.3:5432   192.168.1.6:5433
fb_four   127.0.1.4:5432   16.51.209.8:8865

You could reconfigure the redirection by changing the ipfw configuration -- you wouldn't change your client code at all. It would continue to use a connection string of "... host=db_one", but you'd change 127.0.1.1:5432 to forward to the new IP/port.

Or use pgpool. :)

- Chris


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org

Reply via email to