Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitebf57dd

Browse files
committed
Update permissions?
1 parent2004337 commitebf57dd

File tree

3 files changed

+87
-68
lines changed

3 files changed

+87
-68
lines changed

‎contrib/pg_upgrade/README

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ SSYYNNOOPPSSIISS
1212
data
1313

1414
DDEESSCCRRIIPPTTIIOONN
15-
pg_upgrade is a utility for upgrading from a previous
15+
ppgg__uuppggrraaddee is a utility for upgrading from a previous
1616
PostgreSQL release without reloading all the data. Not all
17-
PostgreSQL releases canbe handledthisway. Check the
17+
PostgreSQL releasescan usethisutility. Check the
1818
release notes for details about your version.
1919

20-
pg_upgrade must be run in two stages. In phase one you
21-
must runpg_upgrade with your old database installation in
22-
place. In phase two,pg_upgrade must be run on a freshly
23-
initdb'ed current install. In both phases, the same
24-
pg_upgrade script matching the newly installed version
20+
ppgg__uuppggrraaddee must be run in two stages. In phase one you
21+
must runppgg__uuppggrraaddee with your old database installation in
22+
place. In phase two,ppgg__uuppggrraaddee must be run on a freshly
23+
iinniittddbb'ed current install. In both phases, the same
24+
ppgg__uuppggrraaddee script matching the newly installed version
2525
must be used.
2626

2727
UUppggrraaddiinngg PPoossttggrreeSSQQLL wwiitthh ppgg__uuppggrraaddee
2828
1) Back up your existing data directory, preferably by
29-
making a complete dump withpg_dumpall.
29+
making a complete dump withppgg__dduummppaallll..
3030

3131
2) Copy the program _p_g_s_q_l_/_c_o_n_t_r_i_b_/_p_g___u_p_g_r_a_d_e_/_p_g___u_p_g_r_a_d_e
3232
from the current PostgreSQL distribution somewhere into
@@ -52,7 +52,7 @@ UUppggrraaddiinngg PPoossttggrreeSSQQLL wwiitthh ppgg_
5252
$$ mmaakkee iinnssttaallll
5353

5454
to install the _p_g___r_e_s_e_t_x_l_o_g utility which is needed by
55-
pg_upgrade.
55+
ppgg__uuppggrraaddee.
5656

5757
6) Run initdb to create a new template1 database contain-
5858
ing the system tables for the new release. Make sure you
@@ -76,7 +76,7 @@ PG_UPGRADE(1) PostgreSQL Client Applications PG_UPGRADE(1)
7676
alter pg_hba.conf temporarily.)
7777

7878
8) Change your working directory to the pgsql main direc-
79-
tory, and type:
79+
tory again, and type:
8080

8181
$$ ppgg__uuppggrraaddee --22
8282

@@ -92,12 +92,13 @@ PG_UPGRADE(1) PostgreSQL Client Applications PG_UPGRADE(1)
9292

9393
10) Carefully examine the contents of the upgraded
9494
databases. If you detect problems, you'll need to recover
95-
by restoring from your full pg_dump backup. You can delete
96-
the _p_g___u_p_g_r_a_d_e___i_n_f_o_/ directory when you are satisfied.
95+
by restoring from your full ppgg__dduummppaallll backup. You can
96+
delete the _p_g___u_p_g_r_a_d_e___i_n_f_o_/ directory when you are satis-
97+
fied.
9798

98-
Theupgradeddatabaseswill be in an un-vacuumed state.
99-
You will probably want to run a_V_A_C_U_U_M_A_N_A_L_Y_Z_E bbeeffoorree
100-
bbeeggiinnnniinngg pprroodduuccttiioonn wwoorrkk..
99+
The upgraded databases will be inanun-vacuumed state.
100+
Youwillprobablywantto runa_V_A_C_U_U_M _A_N_A_L_Y_Z_Ebefore
101+
beginning production work.
101102

102103
SSEEEE AALLSSOO
103104
initdb(1), postmaster(1), pg_dump(1), pg_dumpall(1), vacu-
@@ -124,7 +125,6 @@ SSEEEE AALLSSOO
124125

125126

126127

127-
128128

129129

130130
14 Jan 2002 PG_UPGRADE(1) 2

‎contrib/pg_upgrade/pg_upgrade

Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pg_upgrade: update a database without needing a full dump/reload cycle.
44
# CAUTION: Read the manual page before trying to use this!
55

6-
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.1 2002/01/1417:32:07 momjian Exp $
6+
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.2 2002/01/1422:54:44 momjian Exp $
77
#
88
# NOTE: we must be sure to update the version-checking code a few dozen lines
99
# below for each new PostgreSQL release.
@@ -30,6 +30,7 @@ CUR_VERSION="7.2"
3030
trap"rm -f /tmp/$$.*" 0 1 2 3 15
3131

3232
PHASE=""
33+
3334
if ["$#"-eq 1 ]
3435
then
3536
if ["X$1"="X-1" ]
@@ -38,26 +39,41 @@ then
3839
elif ["X$1"="X-2" ]
3940
thenPHASE="2"
4041
shift
42+
elif ["X$1"="X-D" ]
43+
thenDATADIR="$2"
44+
shift
4145
fi
4246
fi
4347

4448
if ["$PHASE"="" ]
4549
thenecho"You must run$0 in either mode 1 or mode 2."1>&2
46-
echo"Usage:$0 [ -1 | -2 ]"1>&2
50+
echo"Usage:$0 [-D datadir] -1 | -2"1>&2
51+
exit 1
52+
fi
53+
54+
if ["$DATADIR"="" ]
55+
thenecho"You must set the DATADIR environment variable or specify it with -D."1>&2
56+
echo"Usage:$0 [-D datadir] -1 | -2"1>&2
4757
exit 1
4858
fi
4959

50-
if [!-e data ]
51-
thenecho"$0 must be run from the directory above your /data directory.
60+
if [!-d"$DATADIR" ]
61+
thenecho"$DATADIR does not exist.
5262
$0 aborted."1>&2
5363
if ["$PHASE"-eq 2 ]
54-
thenecho"You mustrun initdb to create a template1 database."1>&2
64+
thenecho"Perhaps you didn'trun initdb."1>&2
5565
fi
5666
exit 1
5767
fi
5868

69+
if ["$USER"="root"-o!-r"$DATADIR"/PG_VERSION ]
70+
thenecho"You must run this as the PostgreSQL superuser.
71+
$0 aborted."1>&2
72+
exit 1
73+
fi
74+
5975
INFODIR="pg_upgrade_info"
60-
OLDDIR="$INFODIR/data"
76+
SAVEDATA="$INFODIR"/"`basename\"$DATADIR\"`"
6177

6278
make_dbobjoidmap()
6379
{
@@ -99,21 +115,23 @@ move_objfiles()
99115
{
100116
# Test to make sure there is a matching file in each place
101117

102-
if [!-e"$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID" ]
118+
if [!-f"$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID"-a \
119+
!-h"$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID" ]
103120
thenecho"Move of database$DB, OID$SRC_OID, object$OBJ failed.
104121
File not found; exiting"1>&2
105122
exit 1
106123
fi
107124

108-
if [!-e data/base/"$DST_DBOID"/"$DST_OID" ]
125+
if [!-f"$DATADIR"/base/"$DST_DBOID"/"$DST_OID"-a \
126+
!-h"$DATADIR"/base/"$DST_DBOID"/"$DST_OID" ]
109127
thenecho"Move of database$DB, OID$DST_OID, object$OBJ failed.
110128
File not found; exiting"1>&2
111129
exit 1
112130
fi
113131

114132
# Move files
115133

116-
mv -f"$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID"data/base/"$DST_DBOID"/"$DST_OID"
134+
mv -f"$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID""$DATADIR"/base/"$DST_DBOID"/"$DST_OID"
117135
if ["$?"-ne 0 ]
118136
thenecho"Move of database$DB, OID$SRC_OID, object$OBJ
119137
to$DST_OID failed.; exiting"1>&2
@@ -122,10 +140,10 @@ to $DST_OID failed.; exiting" 1>&2
122140

123141
# handle table extents
124142

125-
ls"$OLDDIR"/base/"$SRC_DBOID"/"$SRC_OID".*2>/dev/null|whileread FILE
143+
ls"$SAVEDATA"/base/"$SRC_DBOID"/"$SRC_OID".*2>/dev/null|whileread FILE
126144
do
127145
EXT=`basename"$FILE"| sed's/^.*\.\(.*\)$/\1/'`
128-
mv -f"$FILE"data/base/"$DST_DBOID"/"$DST_OID"."$EXT"
146+
mv -f"$FILE""$DATADIR"/base/"$DST_DBOID"/"$DST_OID"."$EXT"
129147
if ["$?"-ne 0 ]
130148
thenecho"Move of database$DB, OID$SRC_OID, object$OBJ
131149
to$DST_OID failed.; exiting"1>&2
@@ -142,15 +160,15 @@ then
142160
##########################
143161

144162

145-
if [!-ddata/base/1 ]
146-
thenecho"There is no database template1 indata/base."1>&2
163+
if [!-d"$DATADIR"/base/1 ]
164+
thenecho"There is no database template1 in$DATADIR/base."1>&2
147165
exit 1
148166
fi
149167

150168
# get version
151-
SRC_VERSION="`catdata/PG_VERSION`"
169+
SRC_VERSION=`cat"$DATADIR"/PG_VERSION`
152170
if ["$SRC_VERSION"="" ]
153-
thenecho"$0 can not find PostgreSQL version file 'data/PG_VERSION'.
171+
thenecho"$0 can not find PostgreSQL version file '$DATADIR/PG_VERSION'.
154172
$0 aborted."1>&2
155173
exit 1
156174
fi
@@ -258,9 +276,9 @@ $0 aborted." 1>&2
258276
exit 1
259277
fi
260278

261-
mvdata"$INFODIR"
279+
mv"$DATADIR""$INFODIR"
262280
if [$?-ne 0 ]
263-
thenecho"Can not move old /data out of the way.
281+
thenecho"Can not move old /$DATADIR out of the way.
264282
$0 aborted."1>&2
265283
exit 1
266284
fi
@@ -283,38 +301,38 @@ thenecho "There is no '$INFODIR' directory from a phase 1 run of $0." 1>&2
283301
exit 1
284302
fi
285303

286-
if [!-e"$OLDDIR" ]
287-
thenecho"There is no '$OLDDIR' directory from the phase 1 run of$0."1>&2
304+
if [!-d"$SAVEDATA" ]
305+
thenecho"There is no '$SAVEDATA' directory from the phase 1 run of$0."1>&2
288306
exit 1
289307
fi
290308

291-
if [!-f"$OLDDIR/PG_VERSION" ]
292-
thenecho"Cannot read '$OLDDIR/PG_VERSION' --- something is wrong."1>&2
309+
if [!-f"$SAVEDATA/PG_VERSION" ]
310+
thenecho"Cannot read '$SAVEDATA/PG_VERSION' --- something is wrong."1>&2
293311
exit 1
294312
fi
295313

296-
if [!-f"data/PG_VERSION" ]
297-
thenecho"Cannot read 'data/PG_VERSION' --- something is wrong."1>&2
314+
if [!-f"$DATADIR/PG_VERSION" ]
315+
thenecho"Cannot read '$DATADIR/PG_VERSION' --- something is wrong."1>&2
298316
exit 1
299317
fi
300318

301-
if [!-d"data/base/1" ]
302-
thenecho"Cannot find database template1 in 'data/base'."1>&2
319+
if [!-d"$DATADIR/base/1" ]
320+
thenecho"Cannot find database template1 in '$DATADIR/base'."1>&2
303321
echo"Are you running$0 as the postgres superuser?"1>&2
304322
exit 1
305323
fi
306324

307325
# Get the actual versions seen in the data dirs.
308326

309-
SRC_VERSION=`cat"$OLDDIR"/PG_VERSION`
310-
DST_VERSION=`catdata/PG_VERSION`
327+
SRC_VERSION=`cat"$SAVEDATA"/PG_VERSION`
328+
DST_VERSION=`cat"$DATADIR"/PG_VERSION`
311329

312330
# Check for version compatibility.
313331
# This code will need to be updated/reviewed for each new PostgreSQL release.
314332

315333
if ["$DST_VERSION"!="$CUR_VERSION" ]
316334
thenecho"$0 is for PostgreSQL version$CUR_VERSION
317-
butdata/PG_VERSION contains$DST_VERSION."1>&2
335+
but$DATADIR/PG_VERSION contains$DST_VERSION."1>&2
318336
echo"Did you run initdb for version$UPGRADE_VERSION by mistake?"1>&2
319337
exit 1
320338
fi
@@ -349,17 +367,17 @@ fi
349367
# If the XID is > 2 billion, 7.1 database will have non-frozen XID's in
350368
# low numbers, and 7.2 will think they are in the future --- bad.
351369

352-
SRC_XID=`pg_resetxlog -n"$OLDDIR"| grep"NextXID"| awk -F' *''{print $4}'`
370+
SRC_XID=`pg_resetxlog -n"$SAVEDATA"| grep"NextXID"| awk -F' *''{print $4}'`
353371
if ["$SRC_VERSION"="7.1"-a"$SRC_XID"-gt 2000000000 ]
354372
thenecho"XID too high for$0.; exiting"1>&2
355373
exit 1
356374
fi
357-
DST_XID=`pg_resetxlog -ndata| grep"NextXID"| awk -F' *''{print $4}'`
375+
DST_XID=`pg_resetxlog -n"$DATADIR"| grep"NextXID"| awk -F' *''{print $4}'`
358376

359377
# compare locales to make sure they match
360378

361-
pg_resetxlog -n"$OLDDIR"| grep"^LC_"> /tmp/$$.0
362-
pg_resetxlog -ndata| grep"^LC_"> /tmp/$$.1
379+
pg_resetxlog -n"$SAVEDATA"| grep"^LC_"> /tmp/$$.0
380+
pg_resetxlog -n"$DATADIR"| grep"^LC_"> /tmp/$$.1
363381
if! diff /tmp/$$.0 /tmp/$$.1>/dev/null
364382
thenecho"Locales do not match between the two versions.; exiting"1>&2
365383
exit 1
@@ -470,26 +488,26 @@ thenMAX_XID="$SRC_XID"
470488
elseMAX_XID="$DST_XID"
471489
fi
472490

473-
pg_resetxlog -x"$MAX_XID"data
491+
pg_resetxlog -x"$MAX_XID""$DATADIR"
474492
if ["$?"-ne 0 ]
475493
thenecho"Unable to set new XID.; exiting"1>&2
476494
exit 1
477495
fi
478496

479497
# Move over old WAL
480498

481-
rm -rdata/pg_xlog
482-
mv -f"$OLDDIR"/pg_xlogdata
499+
rm -r"$DATADIR"/pg_xlog
500+
mv -f"$SAVEDATA"/pg_xlog"$DATADIR"
483501

484502
# Set last log file id and segment from old database
485503

486-
LOG_ID=`pg_resetxlog -n"$OLDDIR"| grep"Current log file id:"|
504+
LOG_ID=`pg_resetxlog -n"$SAVEDATA"| grep"Current log file id:"|
487505
awk -F' *''{print $5}'`
488506
if ["$LOG_ID"="" ]
489507
thenecho"Unable to get old log file id.; exiting"1>&2
490508
exit 1
491509
fi
492-
SEG_ID=`pg_resetxlog -n"$OLDDIR"| grep"Next log file segment:"|
510+
SEG_ID=`pg_resetxlog -n"$SAVEDATA"| grep"Next log file segment:"|
493511
awk -F' *''{print $5}'`
494512
if ["$SEG_ID"="" ]
495513
thenecho"Unable to get old log segment id.; exiting"1>&2
@@ -498,7 +516,7 @@ fi
498516

499517
# Set checkpoint location of new database
500518

501-
pg_resetxlog -l"$LOG_ID""$SEG_ID"data
519+
pg_resetxlog -l"$LOG_ID""$SEG_ID""$DATADIR"
502520
if ["$?"-ne 0 ]
503521
thenecho"Unable to set new log file/segment id.; exiting"1>&2
504522
exit 1

‎contrib/pg_upgrade/pg_upgrade.man

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
.TH PG_UPGRADE 1 "PG_UPGRADE(1)" "14 Jan 2002" "PostgreSQL Client Applications" ""
22
.SH NAME
3-
pg_upgrade\-upgrade tool
3+
pg_upgrade\-upgrading from a previous release without reloading
44
.SH SYNOPSIS
5-
Allows upgrading from a previous release without reloading data
5+
pg_upgrade [-D\fIdata_dir\fP] -1 | -2
66
.SH DESCRIPTION
7-
pg_upgrade is a utility for upgrading from a previous PostgreSQL release
8-
without reloading all the data. Not all PostgreSQL releases canbe
9-
handledthisway. Check the release notes for details about your
7+
\fBpg_upgrade\fP is a utility for upgrading from a previous PostgreSQL release
8+
without reloading all the data. Not all PostgreSQL releases canuse
9+
thisutility. Check the release notes for details about your
1010
version.
1111
.LP
12-
pg_upgrade must be run in two stages. In phase one you must run
13-
pg_upgrade with your old database installation in place. In phase two,
14-
pg_upgrade must be run on a freshlyinitdb'ed current install.
15-
In both phases, the samepg_upgrade script matching the newly installed
12+
\fBpg_upgrade\fP must be run in two stages. In phase one you must run
13+
\fBpg_upgrade\fP with your old database installation in place. In phase two,
14+
\fBpg_upgrade\fP must be run on a freshly\fBinitdb\fP'ed current install.
15+
In both phases, the same\fBpg_upgrade\fP script matching the newly installed
1616
version must be used.
1717
.SH Upgrading PostgreSQL with pg_upgrade
1818
.LP
1919
1) Back up your existing data directory, preferably by making a complete
20-
dump withpg_dumpall.
20+
dump with\fBpg_dumpall.\fP
2121
.LP
2222
2) Copy the program\fIpgsql/contrib/pg_upgrade/pg_upgrade\fP from the current
2323
PostgreSQL distribution somewhere into your path.
@@ -27,6 +27,7 @@ PostgreSQL distribution somewhere into your path.
2727
.B$pg_upgrade-1
2828
.sp
2929
to collect information about the old database needed for the upgrade.
30+
You may use\fI-D\fP to specify the data directory, or use PGDATA.
3031
.LP
3132
4) Do:
3233
.LP
@@ -41,7 +42,7 @@ to install the new binaries.
4142
.B$makeinstall
4243
.sp
4344
to install the\fIpg_resetxlog\fP utility which is needed by
44-
pg_upgrade.
45+
\fBpg_upgrade\fP.
4546
.LP
4647
6) Run initdb to create a new template1 database containing the system
4748
tables for the new release. Make sure you use settings similar to those
@@ -51,7 +52,7 @@ used in your previous version.
5152
to the server until the upgrade is complete. You may wish to start the
5253
postmaster without -i or alter pg_hba.conf temporarily.)
5354
.LP
54-
8) Change your working directory to the pgsql main directory, and type:
55+
8) Change your working directory to the pgsql main directory again, and type:
5556
.LP
5657
.B$pg_upgrade-2
5758
.sp
@@ -66,10 +67,10 @@ subdirectories.
6667
.LP
6768
10) Carefully examine the contents of the upgraded databases. If you
6869
detect problems, you'll need to recover by restoring from your full
69-
pg_dump backup. You can delete the\fIpg_upgrade_info/\fP directory when you
70+
\fBpg_dumpall\fP backup. You can delete the\fIpg_upgrade_info/\fP directory when you
7071
are satisfied.
7172
.LP
7273
The upgraded databases will be in an un-vacuumed state. You will
73-
probably want to run a\fIVACUUMANALYZE\fBbeforebeginningproductionwork.
74+
probably want to run a\fIVACUUMANALYZE\fP before beginning production work.
7475
.SH SEE ALSO
7576
initdb(1), postmaster(1), pg_dump(1), pg_dumpall(1), vacuumdb(1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp