1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Upgrading a PostgreSQL Cluster</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Server Setup and Operation"
16
HREF="runtime.html"><LINK
18
TITLE="Shutting Down the Server"
19
HREF="server-shutdown.html"><LINK
21
TITLE="Preventing Server Spoofing"
22
HREF="preventing-server-spoofing.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Shutting Down the Server"
57
HREF="server-shutdown.html"
66
TITLE="Server Setup and Operation"
74
>Chapter 17. Server Setup and Operation</TD
80
TITLE="Server Setup and Operation"
89
TITLE="Preventing Server Spoofing"
90
HREF="preventing-server-spoofing.html"
105
>17.6. Upgrading a <SPAN
111
> This section discusses how to upgrade your database data from one
115
> release to a newer one.
121
> major versions are represented by the
122
first two digit groups of the version number, e.g., 8.4.
126
> minor versions are represented by the
127
third group of version digits, e.g., 8.4.2 is the second minor
128
release of 8.4. Minor releases never change the internal storage
129
format and are always compatible with earlier and later minor
130
releases of the same major version number, e.g., 8.4.2 is compatible
131
with 8.4, 8.4.1 and 8.4.6. To update between compatible versions,
132
you simply replace the executables while the server is down and
133
restart the server. The data directory remains unchanged —
134
minor upgrades are that simple.
147
internal data storage format is subject to change, thus complicating
148
upgrades. The traditional method for moving data to a new major version
149
is to dump and reload the database. Other methods are available,
153
> New major versions also typically introduce some user-visible
154
incompatibilities, so application programming changes might be required.
155
All user-visible changes are listed in the release notes (<A
158
>); pay particular attention to the section
159
labeled "Migration". If you are upgrading across several major
160
versions, be sure to read the release notes for each intervening
164
> Cautious users will want to test their client applications on the new
165
version before switching over fully; therefore, it's often a good idea to
166
set up concurrent installations of old and new versions. When
170
> major upgrade, consider the
171
following categories of possible changes:
182
> The capabilities available for administrators to monitor and control
183
the server often change and improve in each major release.
190
> Typically this includes new SQL command capabilities and not changes
191
in behavior, unless specifically mentioned in the release notes.
198
> Typically libraries like <SPAN
202
functionality, again unless mentioned in the release notes.
209
> System catalog changes usually only affect database management tools.
213
>Server C-language API</DT
216
> This involves changes in the backend function API, which is written
217
in the C programming language. Such changes affect code that
218
references backend functions deep inside the server.
228
NAME="UPGRADE-METHODS-PGDUMP"
229
>17.6.1. Upgrading Data via <SPAN
235
> To dump data from one major version of <SPAN
239
reload it in another, you must use <SPAN
243
level backup methods will not work. (There are checks in place that prevent
244
you from using a data directory with an incompatible version of
248
>, so no great harm can be done by
249
trying to start the wrong server version on a data directory.)
252
> It is recommended that you use the <SPAN
259
> programs from the newer version of
263
>, to take advantage of enhancements
264
that might have been made in these programs. Current releases of the
265
dump programs can read data from any server version back to 7.0.
268
> These instructions assume that your existing installation is under the
271
>/usr/local/pgsql</TT
272
> directory, and that the data area is in
275
>/usr/local/pgsql/data</TT
276
>. Substitute your paths
286
> If making a backup, make sure that your database is not being updated.
287
This does not affect the integrity of the backup, but the changed
288
data would of course not be included. If necessary, edit the
289
permissions in the file <TT
291
>/usr/local/pgsql/data/pg_hba.conf</TT
293
(or equivalent) to disallow access from everyone except you.
295
HREF="client-authentication.html"
297
> for additional information on
303
To back up your database installation, type:
316
If you need to preserve OIDs (such as when using them as
317
foreign keys), then use the <TT
320
> option when running
327
> To make the backup, you can use the <SPAN
331
command from the version you are currently running. For best
332
results, however, try to use the <SPAN
340
since this version contains bug fixes and improvements over older
341
versions. While this advice might seem idiosyncratic since you
342
haven't installed the new version yet, it is advisable to follow
343
it if you plan to install the new version in parallel with the
344
old version. In that case you can complete the installation
345
normally and transfer the data later. This will also decrease
352
> Shut down the old server:
360
On systems that have <SPAN
363
> started at boot time,
364
there is probably a start-up file that will accomplish the same thing. For
369
might find that this works:
374
>/etc/rc.d/init.d/postgresql stop</KBD
380
> for details about starting and
387
> If restoring from backup, rename or delete the old installation
388
directory. It is a good idea to rename the directory, rather than
389
delete it, in case you have trouble and need to revert to it. Keep
390
in mind the directory might consume significant disk space. To rename
391
the directory, use a command like this:
396
>mv /usr/local/pgsql /usr/local/pgsql.old</KBD
399
(Be sure to move the directory as a single unit so relative paths
406
> Install the new version of <SPAN
412
HREF="install-procedure.html"
420
> Create a new database cluster if needed. Remember that you must
421
execute these commands while logged in to the special database user
422
account (which you already have if you are upgrading).
424
CLASS="PROGRAMLISTING"
427
>/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data</KBD
435
> Restore your previous <TT
448
> Start the database server, again using the special database user
451
CLASS="PROGRAMLISTING"
454
>/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data</KBD
462
> Finally, restore your data from backup with:
467
>/usr/local/pgsql/bin/psql -d postgres -f <TT
490
> The least downtime can be achieved by installing the new server in
491
a different directory and running both the old and the new servers
492
in parallel, on different ports. Then you can use something like:
495
CLASS="PROGRAMLISTING"
496
>pg_dumpall -p 5432 | psql -d postgres -p 5433</PRE
498
to transfer your data.
506
NAME="UPGRADING-METHODS-OTHER"
507
>17.6.2. Non-Dump Upgrade Methods</A
511
HREF="pgupgrade.html"
514
installation to be migrated in-place from one major
518
> version to the next. Upgrades can be
519
performed in minutes.
522
> It is also possible to use certain replication methods, such as
526
>, to create a standby server with the updated version of
530
>. This is possible because Slony supports
531
replication between different major versions of
535
>. The standby can be on the same computer or
536
a different computer. Once it has synced up with the master server
537
(running the older version of <SPAN
541
switch masters and make the standby the master and shut down the older
542
database instance. Such a switch-over results in only several seconds
543
of downtime for an upgrade.
552
SUMMARY="Footer navigation table"
563
HREF="server-shutdown.html"
581
HREF="preventing-server-spoofing.html"
591
>Shutting Down the Server</TD
605
>Preventing Server Spoofing</TD
b'\\ No newline at end of file'