pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedProblems setting up DB at a different location
3+ messages / 3 participants
[nested] [flat]
* Problems setting up DB at a different location
@ 2001-09-18 11:43 Sven Riedel <sven.riedel@tu-clausthal.de>
2001-09-19 04:13 ` Re: Problems setting up DB at a different location Oliver Elphick <olly@lfix.co.uk>
0 siblings, 1 reply; 3+ messages in thread
From: Sven Riedel @ 2001-09-18 11:43 UTC (permalink / raw)
To: pgsql-admin
Hi,
I'm trying to place a database on a different harddisk than the default one
PostgreSQL uses. I've read and followed the instructions of the User
Documentation Sections 6.1.1 and 10.2.
export PGDATA2="/data/db"
initlocation PGDATA2
so far, so good, everything worked.
But now, when I createdb mydb -D PGDATA2 from the commandline or
CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
from psql, I get the message
ERROR: Postmaster environment variable 'PGDATA2' not set
despite it being set, obviously. Trying to SET it again from within psql
resulted in being told that 'pgdata2' was not a valid option name.
This is PostgreSQL 7.1.2 from the Debian Linux distribution.
Can anyone point me to what I'm doing wrong?
Regs,
Sven
--
Sven Riedel sr@gimp.org
Osteroeder Str. 6 / App. 13 sven.riedel@tu-clausthal.de
38678 Clausthal "Call me bored, but don't call me boring."
- Larry Wall
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Problems setting up DB at a different location
2001-09-18 11:43 Problems setting up DB at a different location Sven Riedel <sven.riedel@tu-clausthal.de>
@ 2001-09-19 04:13 ` Oliver Elphick <olly@lfix.co.uk>
0 siblings, 0 replies; 3+ messages in thread
From: Oliver Elphick @ 2001-09-19 04:13 UTC (permalink / raw)
To: Sven Riedel <sven.riedel@tu-clausthal.de>; +Cc: pgsql-admin
Sven Riedel wrote:
>Hi,
>I'm trying to place a database on a different harddisk than the default one
>PostgreSQL uses. I've read and followed the instructions of the User
>Documentation Sections 6.1.1 and 10.2.
>
>export PGDATA2="/data/db"
>initlocation PGDATA2
>
>so far, so good, everything worked.
>But now, when I createdb mydb -D PGDATA2 from the commandline or
>CREATE DATABASE mydb WITH LOCATION = 'PGDATA2';
>from psql, I get the message
>
>ERROR: Postmaster environment variable 'PGDATA2' not set
>
>despite it being set, obviously. Trying to SET it again from within psql
>resulted in being told that 'pgdata2' was not a valid option name.
Was it set and exported in the postmaster's environment?
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Bring ye all the tithes into the storehouse, that
there may be meat in mine house, and prove me now
herewith, saith the LORD of hosts, if I will not open
you the windows of heaven, and pour you out a
blessing, that there shall not be room enough to
receive it." Malachi 3:10
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Problems setting up DB at a different location
@ 2001-09-19 02:07 Nick Fankhauser <nickf@ontko.com>
0 siblings, 0 replies; 3+ messages in thread
From: Nick Fankhauser @ 2001-09-19 02:07 UTC (permalink / raw)
To: Sven Riedel <sven.riedel@tu-clausthal.de>; pgsql-admin
Sven-
I am attaching an html file from our internal company documentation that may
help. We are running PostgreSQL 7.1.3 on Debian. The section in the html
file marked "Some general concepts and experiences we've had:" includes a
description of how we placed data in a separate area. (Most of the links in
this doc won't work because they refer to files that live behind our
firewall.)
One problem that I had was forgetting to use the "-" when doing "su -
postgres". The "-" ensures that you pick up any environment variables
defined in the postgres user's .profile
I hope this helps. I can offer further assistance if it does not.
-Nick
---------------------------------------------------------------------
Nick Fankhauser
nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788
doxpop - Court records at your fingertips - http://www.doxpop.com/
Attachments:
pgsql_local.html (text/html, 8.8K) download
<html>
<head>
<title>PostgreSQL Notes and Links</title>
</head>
<body>
<h1>PostgreSQL notes and links</h1>
<ul>
<li><a href = "#local">Local Notes</a>
<li><a href = "#concepts">Concepts & Conjecture</a>
<li><a href = "#links">Links to other documention</a>
</ul>
<br>
<br>
<a name = local><h2>Local Notes</h2></a>
<ul>
<li><h3>We have made the following changes in /etc/postgresql/postgresql.conf:</h3>
<ul>
<li><b>tcpip_socket = 1</b> (This allows us to connect via tcp/ip
which is required for JDBC, and also useful for separating our
database server from our web server. -see pg_hba below for more
on this.)
<li><b>shared_buffers = 4096</b> (An increase to allow more caching -
note that we had to increase SHMALL & SHMMAX for the Linux OS
to handle this. These should minimally be set to
(8192 * buffers)+512. To set SHMALL & SHMMAX in Debian (to 128K
in this example), do
this: echo 134217728 >/proc/sys/kernel/shmall ;
echo 134217728 >/proc/sys/kernel/shmmax )
<li><b>sort_mem = 2048</b> (This increases the space allocated in
RAM for sorts. it is measured in KB, so we have allocated 2MB.)<br><br>
</ul>
<li><h3>We have added this line to /etc/postgresql/pg_hba.conf:</h3>
<ul>
<li><b>host all 199.164.165.129 255.255.255.255 trust</b> This
line says that for <b>all</b> databases, if a request comes
from <b>199.164.165.129</b>, it should be allowed
(<b>trust</b>ed). The netmask of <b>255.255.255.255</b> could
be modified to allow a range of addresses to be trusted. This
line must be added to the host (database server) machine if
connections are to be allowed from anywhere other than
localhost.
</ul>
</ul>
<a name = concepts><h2>Some general concepts and experiences we've had:</h2></a>
<p>
There is one postmaster per database cluster. The postmaster uses
common system files/tables to maintain all databases in the cluster.
There is also a common write-ahead-log directory which serves all
databases in the cluster.
</p>
<p>
The initdb command creates the common system files, and we can
specify that they be placed anywhere. In our case, I have left these
common files in the default of /var/lib/postgres/data because it
makes sense to keep the WAL files & system tables on a different
disk from the data itself. The total initial space used by the
common files is about 20 MB at the outset, of which 16MB is the
first WAL file. initdb *must* be run by the postgres user.
[su ; su - postgres ; initdb]
</p>
<p>
The location of the common files may be specified (assuming an
initdb has been previously done for that location) when starting the
postmaster. By default, databases in the cluster are created in this
location as well, but it is possible to specify a different location
for each database in the cluster using the procedure below:
</p>
<p>
The initlocation command creates the data areas which may then be
used by the postmaster. In our case, we have created PGDATA_DEMO
(/data/pgdata_demo), and PGDATA_ALPHA (/data/pgdata_alpha).
[su - postgres ; initlocation PGDATA_DEMO ; initlocation
PGDATA_ALPHA ] We anticipate adding PGDATA_PROD and PGDATA_STAGING
later.
</p>
<p>
Note: The environment variables listed above must be defined and
exported in /var/lib/postgres/.profile before starting the
postmaster. It makes most sense to define all of these as step one.
</p>
<p>
The createdb command creates the databases themselves. The
postmaster must be running before this happens
[/etc/init.d/posgresql start]. We have created databases in the
locations noted above. [su ; /etc/init.d/postgresql start ;
su - postgres ; createdb demo -D PGDATA_DEMO ; createdb alpha -D
PGDATA_ALPHA] note that there are no '$' before the environment
variables.
</p>
<p>
To dump (export) a database, this command works:
[pg_dump demo >demo.dump]
</p>
<p>
To restore (import) a database, this command works:
[psql -d alpha -f demo.dump]
</p>
<p>
The two commands shown above exported the contents of demo &
reloaded them in alpha. These are fairly small (41Mb) databases.
It took about one minute to dump & restore. The created file is
simply an SQL file containing creates, inserts, etc... This means
we'll want to compress it before sending to tape.
</p>
<p>
WAL files are basically the same thing as redo logs in Oracle- they
are used to both buffer & record transactions against the database
tables, resulting in better IO performance and immediate logging of
transactions to ensure consistent recovery results. Each WAL file is
16 Mb, and when the current file is 75% full, a new WAL file is
created. We can control the number of WAL files initially created
and the space between checkpoints via parameters in
/etc/postgres/postgresql.conf. I don't yet know if there is any
limit on the number of WAL files or a mechanism for automatic
cycling or archiving. I've submitted several questions about
this to the pgsql-admin list.
</p>
<p>
The response I've gotten is that in v7.1.3, only 2-3 WAL files are
ever created. I'm a bit suspicious of the 2-3... it seems as if the
answer should be exactly one number, so take this information with a
grain of salt
</p>
<p>
Some observed behavior:
</p>
<p>
After creating the demo data & doing a dump/restore of it into alpha, we had three WAL files (D,E,F).
</p>
<p>
After restarting the postmaster, we had two WAL files (E,F).
</p>
<p>
My conjecture is that un-needed WAL files get cleaned out when a restart is done, but perhaps not in the normal course of events.
</p>
<p>
Doing a vacuum analyze on both databases did not cause a third WAL file to be created- conjecture: vacuum doesn't cause much impact on WAL files, *or* since I had recently done a vacuum on demo & alpha was created frm a dump, neither had much to be done.
</p>
<p>
We currently have plenty of space in /var for WAL files. After I recreated the databases using the procedure outlined above, we had recovered about 100 Mb. I'm pretty sure that in my confusion, I did an initdb for our designated data area and assumed that a createdb would then use the same area. Since the evidence is all gone, I'm not certain what happened, but regardless, the procedure above places everything where we want it.
</p>
<p>
<a name = links><h2>Useful links</h2></a>
Note: PDF files are cached locally & hence may become stale
<ul>
<li><a href = "http://fts.postgresql.org/db/mw/">Search the postgresql mailing list archive</a>
<li><a href = "http://www.postgresql.org/idocs/">Search the postgresql interactive documents</a>
</ul>
<ul>
<li><a href ="http://techdocs.postgresql.org/">Links to other user-created documentation (similar to the page you're looking at)</a>
</ul>
<ul>
<li><a href = "http://www.postgresql.org">The PostgreSQL site</a> (among the US mirrors, <a href = "http://postgresql.crimelabs.net/">postgresql.crimelabs.net</a> seems to be the fastest)
<li><a href = "gb_intro_wp.pdf">GreatBridge's PostgreSQL white paper (nice intro)</a>
<li><a href = "http://www.de.postgresql.org/users-lounge/limitations.html">Size limitations of PostgreSQL</a>
<li><a href = "pgsql_tutorial.pdf">v7.1 PostgreSQL tutorial</a>
<li><a href = "pgsql_user.pdf">v7.1 PostgreSQL user guide</a>
<li><a href = "pgsql_programmer_guide.pdf">v7.1 PostgreSQL programmer's guide</a>
<li><a href = "pgsql_admin.pdf">v7.1 PostgreSQL administration manual</a>
<li><a href = "pgsql_reference.pdf">v7.1 PostgreSQL reference manual</a>
<li><a href = "pgsql_developer.pdf">v7.1 PostgreSQL developer's guide</a>
<li><a href = "momjian_pgsql_book.pdf">Bruce Momjian's PostgreSQL book</a>
<li><a href = "gb_admin_tuning_wp.pdf">GreatBridge's PostgreSQL tuning white paper. Some specifics may apply to their
distribution only, but the concepts are still valid.)</a>
</ul>
<ul>
<li><a href = "http://java.sun.com/products/jdbc/">JDBC home page</a>
<li><a href = "http://java.sun.com/products/jdk/1.2/docs/api/java/sql/package-summary.html">API for java.sql</a>
<li><a href = "http://java.sun.com/docs/books/tutorial/jdbc/">JDBC tutorial</a>
</ul>
</body>
</html>
pgsql_local.html (text/html, 8.8K) download
<html>
<head>
<title>PostgreSQL Notes and Links</title>
</head>
<body>
<h1>PostgreSQL notes and links</h1>
<ul>
<li><a href = "#local">Local Notes</a>
<li><a href = "#concepts">Concepts & Conjecture</a>
<li><a href = "#links">Links to other documention</a>
</ul>
<br>
<br>
<a name = local><h2>Local Notes</h2></a>
<ul>
<li><h3>We have made the following changes in /etc/postgresql/postgresql.conf:</h3>
<ul>
<li><b>tcpip_socket = 1</b> (This allows us to connect via tcp/ip
which is required for JDBC, and also useful for separating our
database server from our web server. -see pg_hba below for more
on this.)
<li><b>shared_buffers = 4096</b> (An increase to allow more caching -
note that we had to increase SHMALL & SHMMAX for the Linux OS
to handle this. These should minimally be set to
(8192 * buffers)+512. To set SHMALL & SHMMAX in Debian (to 128K
in this example), do
this: echo 134217728 >/proc/sys/kernel/shmall ;
echo 134217728 >/proc/sys/kernel/shmmax )
<li><b>sort_mem = 2048</b> (This increases the space allocated in
RAM for sorts. it is measured in KB, so we have allocated 2MB.)<br><br>
</ul>
<li><h3>We have added this line to /etc/postgresql/pg_hba.conf:</h3>
<ul>
<li><b>host all xxx.xxx.xxx.xxx 255.255.255.255 trust</b> This
line says that for <b>all</b> databases, if a request comes
from <b>xxx.xxx.xxx.xxx</b>, it should be allowed
(<b>trust</b>ed). The netmask of <b>255.255.255.255</b> could
be modified to allow a range of addresses to be trusted. This
line must be added to the host (database server) machine if
connections are to be allowed from anywhere other than
localhost.
</ul>
</ul>
<a name = concepts><h2>Some general concepts and experiences we've had:</h2></a>
<p>
There is one postmaster per database cluster. The postmaster uses
common system files/tables to maintain all databases in the cluster.
There is also a common write-ahead-log directory which serves all
databases in the cluster.
</p>
<p>
The initdb command creates the common system files, and we can
specify that they be placed anywhere. In our case, I have left these
common files in the default of /var/lib/postgres/data because it
makes sense to keep the WAL files & system tables on a different
disk from the data itself. The total initial space used by the
common files is about 20 MB at the outset, of which 16MB is the
first WAL file. initdb *must* be run by the postgres user.
[su ; su - postgres ; initdb]
</p>
<p>
The location of the common files may be specified (assuming an
initdb has been previously done for that location) when starting the
postmaster. By default, databases in the cluster are created in this
location as well, but it is possible to specify a different location
for each database in the cluster using the procedure below:
</p>
<p>
The initlocation command creates the data areas which may then be
used by the postmaster. In our case, we have created PGDATA_DEMO
(/data/pgdata_demo), and PGDATA_ALPHA (/data/pgdata_alpha).
[su - postgres ; initlocation PGDATA_DEMO ; initlocation
PGDATA_ALPHA ] We anticipate adding PGDATA_PROD and PGDATA_STAGING
later.
</p>
<p>
Note: The environment variables listed above must be defined and
exported in /var/lib/postgres/.profile before starting the
postmaster. It makes most sense to define all of these as step one.
</p>
<p>
The createdb command creates the databases themselves. The
postmaster must be running before this happens
[/etc/init.d/posgresql start]. We have created databases in the
locations noted above. [su ; /etc/init.d/postgresql start ;
su - postgres ; createdb demo -D PGDATA_DEMO ; createdb alpha -D
PGDATA_ALPHA] note that there are no '$' before the environment
variables.
</p>
<p>
To dump (export) a database, this command works:
[pg_dump demo >demo.dump]
</p>
<p>
To restore (import) a database, this command works:
[psql -d alpha -f demo.dump]
</p>
<p>
The two commands shown above exported the contents of demo &
reloaded them in alpha. These are fairly small (41Mb) databases.
It took about one minute to dump & restore. The created file is
simply an SQL file containing creates, inserts, etc... This means
we'll want to compress it before sending to tape.
</p>
<p>
WAL files are basically the same thing as redo logs in Oracle- they
are used to both buffer & record transactions against the database
tables, resulting in better IO performance and immediate logging of
transactions to ensure consistent recovery results. Each WAL file is
16 Mb, and when the current file is 75% full, a new WAL file is
created. We can control the number of WAL files initially created
and the space between checkpoints via parameters in
/etc/postgres/postgresql.conf. I don't yet know if there is any
limit on the number of WAL files or a mechanism for automatic
cycling or archiving. I've submitted several questions about
this to the pgsql-admin list.
</p>
<p>
The response I've gotten is that in v7.1.3, only 2-3 WAL files are
ever created. I'm a bit suspicious of the 2-3... it seems as if the
answer should be exactly one number, so take this information with a
grain of salt
</p>
<p>
Some observed behavior:
</p>
<p>
After creating the demo data & doing a dump/restore of it into alpha, we had three WAL files (D,E,F).
</p>
<p>
After restarting the postmaster, we had two WAL files (E,F).
</p>
<p>
My conjecture is that un-needed WAL files get cleaned out when a restart is done, but perhaps not in the normal course of events.
</p>
<p>
Doing a vacuum analyze on both databases did not cause a third WAL file to be created- conjecture: vacuum doesn't cause much impact on WAL files, *or* since I had recently done a vacuum on demo & alpha was created frm a dump, neither had much to be done.
</p>
<p>
We currently have plenty of space in /var for WAL files. After I recreated the databases using the procedure outlined above, we had recovered about 100 Mb. I'm pretty sure that in my confusion, I did an initdb for our designated data area and assumed that a createdb would then use the same area. Since the evidence is all gone, I'm not certain what happened, but regardless, the procedure above places everything where we want it.
</p>
<p>
<a name = links><h2>Useful links</h2></a>
Note: PDF files are cached locally & hence may become stale
<ul>
<li><a href = "http://fts.postgresql.org/db/mw/">Search the postgresql mailing list archive</a>
<li><a href = "http://www.postgresql.org/idocs/">Search the postgresql interactive documents</a>
</ul>
<ul>
<li><a href ="http://techdocs.postgresql.org/">Links to other user-created documentation (similar to the page you're looking at)</a>
</ul>
<ul>
<li><a href = "http://www.postgresql.org">The PostgreSQL site</a> (among the US mirrors, <a href = "http://postgresql.crimelabs.net/">postgresql.crimelabs.net</a> seems to be the fastest)
<li><a href = "gb_intro_wp.pdf">GreatBridge's PostgreSQL white paper (nice intro)</a>
<li><a href = "http://www.de.postgresql.org/users-lounge/limitations.html">Size limitations of PostgreSQL</a>
<li><a href = "pgsql_tutorial.pdf">v7.1 PostgreSQL tutorial</a>
<li><a href = "pgsql_user.pdf">v7.1 PostgreSQL user guide</a>
<li><a href = "pgsql_programmer_guide.pdf">v7.1 PostgreSQL programmer's guide</a>
<li><a href = "pgsql_admin.pdf">v7.1 PostgreSQL administration manual</a>
<li><a href = "pgsql_reference.pdf">v7.1 PostgreSQL reference manual</a>
<li><a href = "pgsql_developer.pdf">v7.1 PostgreSQL developer's guide</a>
<li><a href = "momjian_pgsql_book.pdf">Bruce Momjian's PostgreSQL book</a>
<li><a href = "gb_admin_tuning_wp.pdf">GreatBridge's PostgreSQL tuning white paper. Some specifics may apply to their
distribution only, but the concepts are still valid.)</a>
</ul>
<ul>
<li><a href = "http://java.sun.com/products/jdbc/">JDBC home page</a>
<li><a href = "http://java.sun.com/products/jdk/1.2/docs/api/java/sql/package-summary.html">API for java.sql</a>
<li><a href = "http://java.sun.com/docs/books/tutorial/jdbc/">JDBC tutorial</a>
</ul>
</body>
</html>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-09-19 04:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-18 11:43 Problems setting up DB at a different location Sven Riedel <sven.riedel@tu-clausthal.de>
2001-09-19 04:13 ` Oliver Elphick <olly@lfix.co.uk>
2001-09-19 02:07 Re: Problems setting up DB at a different location Nick Fankhauser <nickf@ontko.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox