1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
<Chapter Id="install">
<Title>Installation</Title>
<Abstract>
<Para>
Installation instructions for
<ProductName>PostgreSQL</ProductName> 7.0.
</Para>
</Abstract>
<Para>
Commands were tested on RedHat Linux version 5.2 using the bash shell.
Except where noted, they will probably work on most systems. Commands
like <command>ps</command> and <command>tar</command> may vary wildly
between platforms on what options you should use.
<Emphasis>Use common sense</Emphasis> before typing in these commands.
</Para>
<Para>
If you haven't gotten the <ProductName>PostgreSQL</ProductName> distribution,
get it from <ULink url="ftp://ftp.postgresql.org">ftp.postgresql.org</ULink>,
then unpack it:
<ProgramListing>
$ gunzip postgresql-7.0.tar.gz
$ tar -xf postgresql-7.0.tar
$ mv postgresql-7.0 /usr/src
</ProgramListing>
Again, these commands might differ on your system.
</Para>
<Sect1>
<Title>Before you start</Title>
<Para>
Building <Productname>PostgreSQL</Productname> requires <acronym>GNU</acronym>
<Application>make</Application>. It will <Emphasis>not</Emphasis>
work with other <Application>make</Application> programs. On GNU/Linux systems
GNU make is the default tool, on other systems you may find that
GNU <Application>make</Application> is installed under the name <Quote>gmake</Quote>.
We will use that name from now on to indicate <acronym>GNU</acronym>
<Application>make</Application>, no matter what name it has on your system.
To test for <acronym>GNU</acronym> <Application>make</Application> enter
<programlisting>
$ <userinput>gmake --version</userinput>
</programlisting>
If you need to get <acronym>GNU</acronym> <Application>make</Application>, you can
find it at <ULink url="ftp://ftp.gnu.org">ftp://ftp.gnu.org</ULink>.
</Para>
<Para>
Up to date information on supported platforms is at
<ulink url="http://www.postgresql.org/docs/admin/ports.htm">
http://www.postgresql.org/docs/admin/ports.htm</ulink>.
In general, most Unix-compatible platforms with modern libraries should be able to run
<ProductName>PostgreSQL</ProductName>. In the <filename>doc</filename> subdirectory
of the distribution are several platform-specific FAQ and README documents you
might wish to consult if you are having trouble.
</para>
<para>
Although the minimum required memory for running <ProductName>PostgreSQL</ProductName>
can be as little as 8MB, there are noticable speed improvements when expanding memory
up to 96MB or beyond. The rule is you can never have too much memory.
</para>
<Para>
Check that you have sufficient disk space. You will need about
30 Mbytes for the source tree during compilation and about 5 Mbytes for
the installation directory. An empty database takes about 1 Mbyte, otherwise
they take about five times the amount of space that a flat text file with the
same data would take. If you run the regression tests you will temporarily need
an extra 20MB.
</Para>
<Para>
To check for disk space, use
<programlisting>
$ df -k
</programlisting>
</para>
<para>
Considering today's prices for hard disks, getting a large and fast hard disk should
probably be in your plans before putting a database into production use.
</para>
</Sect1>
<Sect1>
<Title>Installation Procedure</Title>
<Procedure>
<Title><ProductName>PostgreSQL</ProductName> Installation</Title>
<Para>
For a fresh install or upgrading from previous releases of
<ProductName>PostgreSQL</ProductName>:
</Para>
<Step Performance="optional">
<Para>
Create the <ProductName>PostgreSQL</ProductName> superuser account.
This is the user the server will run as. For production use you
should create a separate, unprivileged account (<literal>postgres</literal> is
commonly used). If you do not have root access or just want to play around,
your own user account is enough.
</para>
<para>
Running <ProductName>PostgreSQL</ProductName> as <literal>root</literal>, <literal>bin</literal>,
or any other account with special access rights is a security risk and therefore
won't be allowed.
</para>
<Para>
You need not do the building and installation itself under this account
(although you can). You will be told when you need to login as the
database superuser.
</Para>
</Step>
<Step Performance="required">
<Para>
If you are not upgrading an existing system then skip to
<xref linkend="continue">.
</Para>
<Para>
You now need to back up your existing database.
To dump your fairly recent post-6.0 database installation, type
<programlisting>
$ pg_dumpall > db.out
</programlisting>
If you wish to preserve object id's (oids), then use the -o
option when running <application>pg_dumpall</application>.
However, unless you have a
special reason for doing this (such as using OIDs as keys
in tables), don't do it.
</Para>
<Para>
Make sure to use the <application>pg_dumpall</application>
command from the version you are currently running.
However, do not use the <application>pg_dumpall</application>
script from 6.0 or everything will be owned by the
<ProductName>PostgreSQL</ProductName> super user. In that case
you should grab <application>pg_dumpall</application> from a later
6.x.x release. 7.0's <application>pg_dumpall</application>
will not work on older databases.
If you are upgrading from a version prior to
<ProductName>Postgres95</ProductName> v1.09 then you must back up your database,
install <ProductName>Postgres95</ProductName> v1.09, restore your database,
then back it up again.
</Para>
<caution>
<Para>
You must make sure that your database is not updated in the middle of
your backup. If necessary, bring down postmaster, edit the permissions
in file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>
to allow only you on, then
bring <application>postmaster</application> back up.
</Para>
</caution>
</Step>
<Step Performance="required">
<Para>
If you are upgrading an existing system then kill the database server now. Type
<ProgramListing>
$ ps ax | grep postmaster
</ProgramListing>
This should list the process numbers for a number of processes, similar
to this:
<ProgramListing>
263 ? SW 0:00 (postmaster)
777 p1 S 0:00 grep postmaster
</ProgramListing>
Type the following line, with <replaceable>pid</replaceable>
replaced by the process id for process <literal>postmaster</literal>
(263 in the above case). (Do not use the id for the process "grep postmaster".)
<programlisting>
$ kill <replaceable>pid</replaceable>
</programlisting>
</Para>
<tip>
<para>
On systems which have <productname>PostgreSQL</productname> started at boot time, there
is probably a startup file which will accomplish the same thing. For example, on a
Redhat Linux system one might find that
<programlisting>
$ /etc/rc.d/init.d/postgres.init stop
</programlisting>
works.
</para>
</tip>
<Para>
Also move the old directories out of the way. Type the following:
<programlisting>
$ mv /usr/local/pgsql /usr/local/pgsql.old
</programlisting>
or replace your particular paths.
</Para>
</Step>
<Step Performance="required" id="continue">
<Para>
Configure the source code for your system. It is this step at which
you can specify your actual installation path for the build process
and make choices about what gets installed. Change into the <filename>src</filename>
subdirectory and type:
<ProgramListing>
$ ./configure [ <replaceable>options</replaceable> ]
</ProgramListing>
For a complete list of options, type:
<ProgramListing>
./configure --help
</ProgramListing>
Some of the more commonly used ones are:
<VariableList>
<varlistentry>
<term>--prefix=BASEDIR</term>
<listitem>
<para>
Selects a different base directory for the installation of
<ProductName>PostgreSQL</ProductName>. The default is <filename>/usr/local/pgsql</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--enable-locale</term>
<listitem>
<para>
If you want to use locales.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--enable-multibyte</term>
<listitem>
<para>
Allows the use of multibyte character encodings. This is primarily for
languages like Japanese, Korean, or Chinese.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--with-perl</term>
<listitem>
<para>
Builds the Perl interface. Please note that the Perl interface will be
installed into the usual place for Perl modules (typically under
<filename>/usr/lib/perl</filename>), so you must have root access to use
this option successfully.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--with-odbc</term>
<listitem>
<para>
Builds the ODBC driver package.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--with-tcl</term>
<listitem>
<para>
Builds interface libraries and programs requiring
Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh.
</para>
</listitem>
</varlistentry>
</VariableList>
</Para>
</step>
<Step Performance="required">
<Para>
Compile the program. Type
<ProgramListing>
$ gmake
</ProgramListing>
The compilation process can take anywhere from 10 minutes to an hour.
Your milage will most certainly vary.
</Para>
<Para>
The last line displayed will hopefully be
<programlisting>
All of PostgreSQL is successfully made. Ready to install.
</programlisting>
Remember, <Quote>gmake</Quote> may be called <Quote>make</Quote> on
your system.
</Para>
</Step>
<Step Performance="required">
<Para>
Install the program. Type
<ProgramListing>
$ gmake install
</ProgramListing>
</Para>
</Step>
<Step Performance="required">
<Para>
Tell your system how to find the new shared libraries. How to do this varies between
platforms. What tends to work everywhere is to set the environment variable
<envar>LD_LIBRARY_PATH</envar>:
<programlisting>
$ LD_LIBRARY_PATH=/usr/local/pgsql/lib
$ export LD_LIBRARY_PATH
</programlisting>
You might want to put this into a shell startup file such as
<filename>~/.bash_profile</filename>.
</Para>
<Para>
On some systems the following is the preferred method, but you must have root
access. Edit file <filename>/etc/ld.so.conf</filename> to add a line
<programlisting>
<FileName>/usr/local/pgsql/lib</FileName>
</programlisting>
Then run command <Command>/sbin/ldconfig</Command>.
</Para>
<Para>
If in doubt, refer to the manual pages of your system. If you later on get
a message like
<programlisting>
./psql: error in loading shared libraries
libpq.so.2.1: cannot open shared object file: No such file or directory
</programlisting>
then the above was necessary. Simply do this step then.
</Para>
</Step>
<Step Performance="required">
<Para>
Create the database installation. To do this you must log in to your
<ProductName>PostgreSQL</ProductName> superuser account. It will not
work as root.
<ProgramListing>
$ mkdir /usr/local/pgsql/data
$ chown postgres /usr/local/pgsql/data
$ su - postgres
$ /usr/local/pgsql/initdb -D /usr/local/pgsql/data
</ProgramListing>
</Para>
<Para>
The <option>-D</option> option specifies the location where the data will be
stored. You can use any path you want, it does not have to be under
the installation directory. Just make sure that the superuser account
can write to it (or create it) before starting <command>initdb</command>.
</Para>
</Step>
<Step Performance="required">
<Para>
The previous step should have told you how to start up the database server.
Do so now.
<programlisting>
$ /usr/local/pgsql/initdb/postmaster -D /usr/local/pgsql/data
</programlisting>
This will start the server in the foreground. To make it detach to
the background, use the <option>-S</option>.
</Para>
</Step>
<Step Performance="optional">
<para>
If you are upgrading from an existing installation, dump your data back in:
<programlisting>
$ /usr/local/pgsql/bin/psql < db.out
</programlisting>
You also might want to copy over the old <filename>pg_hba.conf</filename>
file and any other files you might have had set up for authentication, such
as password files.
</Para>
</Step>
</Procedure>
<para>
This concludes the installation proper. To make your life more productive and enjoyable
you should look at the following optional steps and suggestions.
</para>
<itemizedlist>
<listitem>
<Para>
Life will be more convenient if you set up some enviroment variables. First of all
you probably want to include <filename>/usr/local/pgsql/bin</filename> (or equivalent)
into your <envar>PATH</envar>. To do this, add the following to your shell startup
file, such as <filename>~/.bash_profile</filename> (or <filename>/etc/profile</filename>,
if you want it to affect every user):
<programlisting>
PATH=$PATH:/usr/local/pgsql/bin
</programlisting>
</Para>
<Para>
Furthermore, if you set <envar>PGDATA</envar> in the environment of the PostgreSQL
superuser, you can omit the <option>-D</option> for <filename>postmaster</filename>
and <filename>initdb</filename>.
</Para>
</listitem>
<listitem>
<Para>
You probably want to install the <application>man</application> and
<acronym>HTML</acronym> documentation. Type
<ProgramListing>
$ cd /usr/src/pgsql/postgresql-7.0/doc
$ gmake install
</ProgramListing>
This will install files under <filename>/usr/local/pgsql/doc</filename>.
</para>
<para>
The documentation is also available in Postscript format. If you have
a Postscript printer, or have your machine already set up to accept
Postscript files using a print filter, then to print the User's Guide
simply type
<programlisting>
$ cd /usr/local/pgsql/doc
$ gunzip -c user.ps.tz | lpr
</programlisting>
Here is how you might do it if you have Ghostscript on your system and are
writing to a laserjet printer.
<programlisting>
$ alias gshp='gs -sDEVICE=laserjet -r300 -dNOPAUSE'
$ export GS_LIB=/usr/share/ghostscript:/usr/share/ghostscript/fonts
$ gunzip user.ps.gz
$ gshp -sOUTPUTFILE=user.hp user.ps
$ gzip user.ps
$ lpr -l -s -r manpage.hp
</programlisting>
If in doubt, confer your manuals or your local expert.
</para>
<para>
The Adminstrator's Guide should probably be your first reading if you
are completely new to <productname>PostgreSQL</productname>, as it contains
information about how to set up database users and authentication.
</para>
</listitem>
<listitem>
<Para>
Usually, you will want to modify your computer so that it will automatically
start the database server whenever it boots.
This is not required; the <ProductName>PostgreSQL</ProductName> server can
be run successfully from non-privileged accounts without root intervention.
</para>
<para>
Different systems have different conventions for starting up daemons at boot time,
so you are advised to familiarize yourself with them.
Most systems have a file <filename>/etc/rc.local</filename> or
<filename>/etc/rc.d/rc.local</filename> which is almost certainly no bad place
to put such a command.
Whatever you do, postmaster must be run by the <ProductName>PostgreSQL</ProductName>
superuser (<literal>postgres</literal>) <emphasis>and not by root</emphasis> or
any other user. Therefore you probably always want to form your command lines
along the lines of <literal>su -c '...' postgres</literal>.
</para>
<para>
It might be advisable to keep a log of the server output. To start the server that way
try:
<ProgramListing>
nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres &
</ProgramListing>
</para>
<para>
Here are a few more operating system specific suggestions.
<itemizedlist>
<listitem>
<para>
Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
2.5.1 to contain the following single line:
<programlisting>
su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
</programlisting>
</para>
</listitem>
<listitem>
<para>
In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
contain the following lines and make it chmod 755 and chown
root:bin.
<programlisting>
#!/bin/sh
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data
-S -o -F > /usr/local/pgsql/errlog' &
echo -n ' pgsql'
}
</programlisting>
You may put the line breaks as shown above. The shell is smart
enough to keep parsing beyond end-of-line if there is an
expression unfinished. The exec saves one layer of shell under
the postmaster process so the parent is init.
</para>
</listitem>
<listitem>
<para>
In RedHat Linux add a file <filename>/etc/rc.d/init.d/postgres.init</filename>
which is based on the example in <filename>contrib/linux/</filename>.
Then make a softlink to this file from
<filename>/etc/rc.d/rc5.d/S98postgres.init</filename>.
</para>
</listitem>
</itemizedlist>
</Para>
</listitem>
<listitem>
<Para>
Run the regression tests. The regression tests are a test suite to verify that
PostgreSQL runs on your machine in the way the developers expected it to.
You should definitely do this before putting a server into production use.
The file <filename>/usr/src/pgsql/postgresql-7.0/src/test/regress/README</filename>
has detailed
instructions for running and interpreting the regression tests.
</Para>
</listitem>
</itemizedlist>
</Sect1>
</Chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
sgml-local-ecat-files:nil
End:
-->
|