"private" installation of postgres

Started by Scott Ribeover 15 years ago12 messagesgeneral
Jump to latest
#1Scott Ribe
scott_ribe@killerbytes.com

Assume I want to install an instance of postgres such that it cannot interfere with another install, or even be visible to other apps. Is this all I need to do:

- install pg somewhere within my own directory
- init the db somewhere within my own directory
- disallow IP connections
- set the socket directory somewhere within my own directory

Or is there a doc on this somewhere?

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#2John R Pierce
pierce@hogranch.com
In reply to: Scott Ribe (#1)
Re: "private" installation of postgres

On 09/07/10 5:15 PM, Scott Ribe wrote:

Assume I want to install an instance of postgres such that it cannot interfere with another install, or even be visible to other apps. Is this all I need to do:

- install pg somewhere within my own directory
- init the db somewhere within my own directory
- disallow IP connections
- set the socket directory somewhere within my own directory

Or is there a doc on this somewhere?

I'm pretty sure the socket directory is hard coded in the source, I
don't think you can override it even with ./configure

#3Rodrigo Gonzalez
rjgonzale@estrads.com.ar
In reply to: John R Pierce (#2)
Re: "private" installation of postgres

It is defined in postgresql.conf

unix_socket_directory = '/var/run/postgresql'

On Tue, 07 Sep 2010 17:20:24 -0700
John R Pierce <pierce@hogranch.com> wrote:

Show quoted text

On 09/07/10 5:15 PM, Scott Ribe wrote:

Assume I want to install an instance of postgres such that it
cannot interfere with another install, or even be visible to other
apps. Is this all I need to do:

- install pg somewhere within my own directory
- init the db somewhere within my own directory
- disallow IP connections
- set the socket directory somewhere within my own directory

Or is there a doc on this somewhere?

I'm pretty sure the socket directory is hard coded in the source, I
don't think you can override it even with ./configure

#4Joshua J. Kugler
joshua@eeinternet.com
In reply to: John R Pierce (#2)
Re: "private" installation of postgres

On Tuesday 07 September 2010, John R Pierce elucidated thus:

On 09/07/10 5:15 PM, Scott Ribe wrote:

Assume I want to install an instance of postgres such that it
cannot interfere with another install, or even be visible to other
apps. Is this all I need to do:

- install pg somewhere within my own directory
- init the db somewhere within my own directory
- disallow IP connections
- set the socket directory somewhere within my own directory

Or is there a doc on this somewhere?

I'm pretty sure the socket directory is hard coded in the source, I
don't think you can override it even with ./configure

postgresql.conf:

unix_socket_directory = '/var/run/postgresql'

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/ �ID 0x73B13B6A

#5Greg Sabino Mullane
greg@turnstep.com
In reply to: Scott Ribe (#1)
Re: "private" installation of postgres

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Assume I want to install an instance of postgres such
that it cannot interfere with another install,
or even be visible to other apps. Is this all I need to do:

- install pg somewhere within my own directory
- init the db somewhere within my own directory
- disallow IP connections
- set the socket directory somewhere within my own directory

Yep, that should do it. I do this all the time for testing
various programs. Set the socket with pg_ctl -o "-k newsocketdir"

- --
Greg Sabino Mullane greg@turnstep.com
End Point Corporation http://www.endpoint.com/
PGP Key: 0x14964AC8 201009072027
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEAREDAAYFAkyG2JsACgkQvJuQZxSWSsg8igCg+CkN8v3NeKtQzIobEG6wP1gD
k08AnAivO5e77TMOMcTlitPNXNyhg5wr
=hgpw
-----END PGP SIGNATURE-----

#6John R Pierce
pierce@hogranch.com
In reply to: Joshua J. Kugler (#4)
Re: "private" installation of postgres

On 09/07/10 5:24 PM, Joshua J. Kugler wrote:

I'm pretty sure the socket directory is hard coded in the source, I
don't think you can override it even with ./configure

postgresql.conf:

unix_socket_directory = '/var/run/postgresql'

for some reason, I'm remembering that last time I looked, there were
places where this value wasn't being used. but then again, maybe I'm
thinking of something else entirely different and am just confused.
wouldn't be the first time.

#7Scott Ribe
scott_ribe@killerbytes.com
In reply to: John R Pierce (#6)
Re: "private" installation of postgres

On Sep 7, 2010, at 6:30 PM, John R Pierce wrote:

for some reason, I'm remembering that last time I looked, there were places where this value wasn't being used. but then again, maybe I'm thinking of something else entirely different and am just confused. wouldn't be the first time.

Well, unless I hear definitively, I'll consider that something I need to test. Of course there's also an option to specify the default when building the source, I expect *that* should work, and as far as I'm concerned there would be no problem doing it that way.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#8Scott Ribe
scott_ribe@killerbytes.com
In reply to: Greg Sabino Mullane (#5)
Re: "private" installation of postgres

On Sep 7, 2010, at 6:28 PM, Greg Sabino Mullane wrote:

Yep, that should do it. I do this all the time for testing
various programs. Set the socket with pg_ctl -o "-k newsocketdir"

Thanks :-)

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: John R Pierce (#6)
Re: "private" installation of postgres

John R Pierce <pierce@hogranch.com> writes:

On 09/07/10 5:24 PM, Joshua J. Kugler wrote:

I'm pretty sure the socket directory is hard coded in the source, I
don't think you can override it even with ./configure

postgresql.conf:
unix_socket_directory = '/var/run/postgresql'

for some reason, I'm remembering that last time I looked, there were
places where this value wasn't being used.

The client side is obviously not going to know what is in the server's
config file, so you're going to have to specify that path every time you
connect. Depending on what you are doing, you might want to build a
version of libpq that defaults to assuming the nondefault socket
location rather than /tmp. If so, edit DEFAULT_PGSOCKET_DIR in
src/include/pg_config_manual.h.

Personally, though, I think it's easier to change the default port
number and not worry about sharing /tmp. Changing the port is a good
idea anyway to avoid any possible conflicts on shared memory IDs.

regards, tom lane

#10Scott Ribe
scott_ribe@killerbytes.com
In reply to: Tom Lane (#9)
Re: "private" installation of postgres

On Sep 7, 2010, at 7:09 PM, Tom Lane wrote:

Personally, though, I think it's easier to change the default port
number and not worry about sharing /tmp. Changing the port is a good
idea anyway to avoid any possible conflicts on shared memory IDs.

I was planning on changing the default port number (I forgot to state that in my email), but also moving the socket dir just to be really sure.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice

#11Joshua J. Kugler
joshua@eeinternet.com
In reply to: Scott Ribe (#10)
Re: "private" installation of postgres

On Tuesday 07 September 2010, Scott Ribe elucidated thus:

On Sep 7, 2010, at 7:09 PM, Tom Lane wrote:

Personally, though, I think it's easier to change the default port
number and not worry about sharing /tmp. Changing the port is a
good idea anyway to avoid any possible conflicts on shared memory
IDs.

I was planning on changing the default port number (I forgot to state
that in my email), but also moving the socket dir just to be really
sure.

If you do a private socket dir, and connect via that, you don't even
have to listen on a TCP port at all.

j

--
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/ �ID 0x73B13B6A

#12Scott Ribe
scott_ribe@killerbytes.com
In reply to: Joshua J. Kugler (#11)
Re: "private" installation of postgres

On Sep 8, 2010, at 1:39 PM, Joshua J. Kugler wrote:

If you do a private socket dir, and connect via that, you don't even
have to listen on a TCP port at all.

Right, but it's hardwired in that the IP port number is used as part of the domain socket name, and according to Tom also used somehow in shared memory segments.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice