Re: Multiple logical databases - Mailing list pgsql-hackers

From Chris Campbell
Subject Re: Multiple logical databases
Date
Msg-id 41E24F06-4015-49B4-82ED-3BB0DF2DFBC9@bignerdranch.com
Whole thread Raw
In response to Re: Multiple logical databases  ("Mark Woodward" <pgsql@mohawksoft.com>)
Responses Re: Multiple logical databases
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Multiple logical databases
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Passing arguments to views