Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXnHx-0002t0-RZ for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2019 14:18:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iXnHw-0001Nw-LU for pgsql-general@arkaria.postgresql.org; Thu, 21 Nov 2019 14:18:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXnHw-0001Nj-8p for pgsql-general@lists.postgresql.org; Thu, 21 Nov 2019 14:18:28 +0000 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXnHt-0002nN-Bq for pgsql-general@lists.postgresql.org; Thu, 21 Nov 2019 14:18:27 +0000 Received: by mail-oi1-x244.google.com with SMTP id j7so3324141oib.3 for ; Thu, 21 Nov 2019 06:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=bHVjkXR4ZCh0EwDbufhfiQDQtHsuTi35BXU1fQeeY4s=; b=VWln7BD3iAI1/qm6/8kGOJ0ab3hHTw9U22jbEHJqO8j5noXDD/AGpH1AkR3p9+gneS +Q1fb8qZKRLIbkxqaCUZgK50znKCojOkbT/h7RCNJexuyl7BasBilFrWNujUT8WnAzmU HS+THdGyej8D5MTpFBmq5KBTQWj3LiMSOxmN/MORe5Msn7cXZWqp+VQGL4RzhBcLuRYE 2m4Dew3oCbaZMlZ1/3mNTzTSRrLVor0MQxsFTpkukummsL1B04SvBp/EGSKQAeLl5SRY /kz1XMxZ4NTs/+d0YHIFAqSH5hVDoRuyF2Fxb/qjQea7EgKBZPO2OWZw1zlWS5cMVVa9 rVug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=bHVjkXR4ZCh0EwDbufhfiQDQtHsuTi35BXU1fQeeY4s=; b=k/0YKgDdRCmGvvc7l+bpwDc9DdCBgE1gl6K337/m3yB6f/kIcPxAhb+Cuvpdz1kqGP IEjDV0+nmZs/tRBV+q3npJY2qe2SGYPdPipVmCroHe6Sc8nfS8jYlOjFEyJPcLZ6yxto OZsY7Vpc2kqcDBGk67TzevencNUXd9W7YjwqZoM89KcZSlebZO5bCitIGhIUq6t9SHju 3wy51Vbo49uqjOqMtg6YlRnXDCWIbEH8gXOR/1000tQta8erwjLOr9U9NRtBfZylHyzL HgtgeGqP86GcrjdTYR7T5wOeHVLWawW9UIjop2GnvTBOCEalRtkxleWQOizDwZ+j1Sxr lYZQ== X-Gm-Message-State: APjAAAU7DPQCULveC83GxewEwjbxEldx5/nA0YGrHt9NlaSppWknz1MB HrXIU+twonSX2r4KXYqqzU26Mrke0/QO6Q== X-Google-Smtp-Source: APXvYqyPF86OU816QMX0UrJJ5tm6JSHajZSaZJg0sp6lAlTURDIjRrYyJHobk96yNg2EUlu3nSy0Vg== X-Received: by 2002:aca:5696:: with SMTP id k144mr7973868oib.87.1574345903355; Thu, 21 Nov 2019 06:18:23 -0800 (PST) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id i195sm920751oib.55.2019.11.21.06.18.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Nov 2019 06:18:22 -0800 (PST) Subject: Re: Isolation of multiple databse instances provided by a single postgres server To: pgsql-general@lists.postgresql.org References: <20191120220353.GA24554@panix.com> <20191121115549.GA3417@panix.com> From: Ron Message-ID: Date: Thu, 21 Nov 2019 08:18:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191121115549.GA3417@panix.com> Content-Type: multipart/alternative; boundary="------------F17A752502C9658EC4CA6047" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F17A752502C9658EC4CA6047 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/21/19 5:55 AM, stan wrote: > On Wed, Nov 20, 2019 at 04:24:40PM -0600, Ron wrote: >> On 11/20/19 4:03 PM, stan wrote: >>> I am working on a fairly small application to use for managing a companies >>> business. >>> >>> I have a "production" instance hosted by one of the cloud providers, and 2 >>> other instances. This is fairly new to me. In the past, I have created >>> applications by keeping a set of scripts that can be used to rebuild the >>> database, and pg_dump to restore the date. Based on some recommendations I >>> am using pg_basebackup to backup the production instance nightly. My >>> background is primarily Oracle. I realize looking at the way pg_basebackup >>> works that multiple database instances, provided by one server are actually >>> stored in the same physical OS files. >>> >>> >>> We have traditionally (in the Postgres world) had a sandbox, that we used >>> for upgrades, and testing development methodologies, and this seems to be >>> supported pretty well by pg_dump. >>> >>> Now that I know "too much" I am concerned about hosting the sandbox on the >>> same Postgres instance. >> What specifically do you mean by "instance"??? (I know what it means in the >> SQL Server world, and in Postgres all the databases accessible via a single >> $PGDATA are called a *cluster*.) > Sorry for my incorrect terminology. I am probably confused about the > technology here. Let me try to explain what I think I understand. > > It seems to me that I can have one Postgres "server" running listening on a > single port on a single machine. It appears that the data files for this > "server" are managed internally by the Postgres server instance, and I > have no control of what is stored where in them. In an Oracle world, I can > create tablespaces, which have a relationship to OS files, and I can > explicitly control what objects are stored in which tablespaces (OS file), Same in Postgres. https://www.postgresql.org/docs/9.6/sql-createtablespace.html CREATE TABLESPACEtablespace_name [ OWNER {new_owner | CURRENT_USER | SESSION_USER } ] LOCATION 'directory' [ WITH (tablespace_option =value [, ... ] ) ] > thus, for example, when I do a hot backup, I put a specific tablespaces in > backup mode, and can then safely copy this OS file (yes I have to properly > deal with archive logs). Thus I would be somewhat comfortable have to > distinct "instance: provided by that one Oracle "server". There's no ability to backup a single tablespace in Postgres, because the purpose behind them is not the same in Oracle and Postgres. > It appears to me that, within this one Postgres "instance", there are 2 > levels of "isolation", which are database, and schemas. Is this correct? Yes, but ... schema in Postgres are /different/ from Oracle schema.  In Postgres, the CREATE SCHEMA command creates a schema, whereas CREATE USER creates a schema in Oracle. > If > so, how does this cores pond to physical on disk storage? It corresponds not at all. The directory that a table's files go in is solely dependent on the tablespace it lives in (typically "pg_default", who's location is $PGDATA). >>> Recognizing that this is a fairly small application, what are wiser folks >>> than I recommendations? >>> >>> Should I run the sandbox from different Postgres server, possibly even on a >>> different machine? Is pg_dump still good way to move the production >>> instance to the sandbox, and perhaps even the other way around? >> Running CAT, STG, UAT, DEV, etc on different VMs is certainly one solution, >> isolating them from each other. > Makes sense. >> OTOH, you can initdb multiple clusters on the same host, accessing them via >> different $PGDATA variables and port numbers. > That is consistent with what I thought I understood. > > Thanks for taking time to educate me. -- Angular momentum makes the world go 'round. --------------F17A752502C9658EC4CA6047 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 11/21/19 5:55 AM, stan wrote:
On Wed, Nov 20, 2019 at 04:24:40PM -0600, Ron wrote:
On 11/20/19 4:03 PM, stan wrote:
I am working on a fairly small application to use for managing a companies
business.

I have a "production" instance hosted by one of the cloud providers, and 2
other instances. This is fairly new to me. In the past, I have created
applications by keeping a set of scripts that can be used to rebuild the
database, and pg_dump to restore the date. Based on some recommendations I
am using pg_basebackup to backup the production instance nightly. My
background is primarily Oracle. I realize looking at the way pg_basebackup
works that multiple database instances, provided by one server are actually
stored in the same physical OS files.


We have traditionally (in the Postgres world) had a sandbox, that we used
for upgrades, and testing development methodologies, and this seems to be
supported pretty well by pg_dump.

Now that I know "too much" I am concerned about hosting the sandbox on the
same Postgres instance.
What specifically do you mean by "instance"??? (I know what it means in the
SQL Server world, and in Postgres all the databases accessible via a single
$PGDATA are called a *cluster*.)
Sorry for my incorrect terminology. I am probably confused about the
technology here. Let me try to explain what I think I understand.

It seems to me that I can have one Postgres "server" running listening on a
single port on a single machine. It appears that the data files for this
"server" are managed internally by the Postgres server instance, and I
have no control of what is stored where in them. In an Oracle world, I can
create tablespaces, which have a relationship to OS files, and I can
explicitly control what objects are stored in which tablespaces (OS file),

Same in Postgres.

https://www.postgresql.org/docs/9.6/sql-createtablespace.html

CREATE TABLESPACE tablespace_name
    [ OWNER { new_owner | CURRENT_USER | SESSION_USER } ]
    LOCATION 'directory'
    [ WITH ( tablespace_option = value [, ... ] ) ]


thus, for example, when I do a hot backup, I put a specific tablespaces in
backup mode, and can then safely copy this OS file (yes I have to properly
deal with archive logs). Thus I would be somewhat comfortable have to
distinct "instance: provided by that one Oracle "server".

There's no ability to backup a single tablespace in Postgres, because the purpose behind them is not the same in Oracle and Postgres.


It appears to me that, within this one Postgres "instance", there are 2
levels of "isolation", which are database, and schemas. Is this correct? 

Yes, but ... schema in Postgres are different from Oracle schema.  In Postgres, the CREATE SCHEMA command creates a schema, whereas CREATE USER creates a schema in Oracle.

If
so, how does this cores pond to physical on disk storage?

It corresponds not at all.

The directory that a table's files go in is solely dependent on the tablespace it lives in (typically "pg_default", who's location is $PGDATA).

Recognizing that this is a fairly small application, what are wiser folks
than I recommendations?

Should I run the sandbox from different Postgres server, possibly even on a
different machine? Is pg_dump still  good way to move the production
instance to the sandbox, and perhaps even the other way around?
Running CAT, STG, UAT, DEV, etc on different VMs is certainly one solution,
isolating them from each other.
 Makes sense.
OTOH, you can initdb multiple clusters on the same host, accessing them via
different $PGDATA variables and port numbers.
That is consistent with what I thought I understood.

Thanks for taking time to educate me.

--
Angular momentum makes the world go 'round.
--------------F17A752502C9658EC4CA6047--