xref: /netbsd-src/external/ibm-public/postfix/dist/proto/DB_README.html (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3
4<html>
5
6<head>
7
8<title>Postfix Berkeley DB Howto</title>
9
10<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
11
12</head>
13
14<body>
15
16<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix Berkeley DB Howto</h1>
17
18<hr>
19
20<h2>Introduction</h2>
21
22<p> Postfix uses databases of various kinds to store and look up
23information. Postfix databases are specified as "type:name".
24Berkeley DB implements the Postfix database type "hash" and
25"btree".  The name of a Postfix Berkeley DB database is the name
26of the database file without the ".db" suffix. Berkeley DB databases
27are maintained with the postmap(1) command.  </p>
28
29<p> Note: Berkeley DB version 4 is not supported by Postfix versions
30before 2.0.  </p>
31
32<p> This document describes: </p>
33
34<ol>
35
36<li> <p> How to build Postfix <a href="#disable_db">without Berkeley
37DB support</a> even if the system comes with Berkeley DB. </p>
38
39<li> <p> How to build Postfix on <a href="#no_db">systems that
40normally have no Berkeley DB library</a>. </p>
41
42<li> <p> How to build Postfix on <a href="#bsd">BSD</a> or <a
43href="#linux">Linux</a> systems with multiple Berkeley DB
44versions.  </p>
45
46<li> <p> How to <a href="#tweak">tweak</a> performance. </p>
47
48<li> <p> Missing <a href="#pthread">pthread</a> library trouble. </p>
49
50</ol>
51
52<h2><a name="disable_db">Building Postfix without Berkeley
53DB support even if the system comes with Berkeley DB</a></h2>
54
55<p> Note: The following instructions apply to Postfix 2.9 and later. </p>
56
57<p> Postfix will normally enable Berkeley DB support if the system
58is known to have it. To build Postfix without Berkeley DB support,
59build the makefiles as follows: </p>
60
61<blockquote>
62<pre>
63% make makefiles CCARGS="-DNO_DB"
64% make
65</pre>
66</blockquote>
67
68<p> This will disable support for "hash" and "btree" files. </p>
69
70<h2><a name="no_db">Building Postfix on systems that normally have
71no Berkeley DB library</a></h2>
72
73<p> Some UNIXes ship without Berkeley DB support; for historical
74reasons these use DBM files instead. A problem with DBM files is
75that they can store only limited amounts of data. To build Postfix
76with
77Berkeley DB support you need to download and install the source
78code from http://www.oracle.com/database/berkeley-db/. </p>
79
80<p> Warning: some Linux system libraries use Berkeley DB, as do
81some third-party libraries such as SASL. If you compile Postfix
82with a different Berkeley DB implementation, then every Postfix
83program will dump core because either the system library, the SASL
84library, or Postfix itself ends up using the wrong version. </p>
85
86<p>The more recent Berkeley DB versions have a compile-time switch,
87"--with-uniquename", which renames the symbols so that multiple
88versions of Berkeley DB can co-exist in the same application.
89Although wasteful, this may be the only way to keep things from
90falling apart. </p>
91
92<p> To build Postfix after you installed the Berkeley DB from
93source code, use something like: </p>
94
95<blockquote>
96<pre>
97% make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
98    AUXLIBS="-L/usr/local/BerkeleyDB/lib -ldb"
99% make
100</pre>
101</blockquote>
102
103<p> Solaris needs this: </p>
104
105<blockquote>
106<pre>
107% make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
108    AUXLIBS="-R/usr/local/BerkeleyDB/lib -L/usr/local/BerkeleyDB/lib -ldb"
109% make
110</pre>
111</blockquote>
112
113<p> The exact pathnames depend on the Berkeley DB version, and on
114how it was installed. </p>
115
116<p> Warning: the file format produced by Berkeley DB version 1 is
117not compatible with that of versions 2 and 3 (versions 2 and 3 have
118the same format). If you switch between DB versions, then you may
119have to rebuild all your Postfix DB files. </p>
120
121<p> Warning: if you use Berkeley DB version 2 or later, do not
122enable DB 1.85 compatibility mode. Doing so would break fcntl file
123locking. </p>
124
125<p> Warning: if you use Perl to manipulate Postfix's Berkeley DB
126files, then you need to use the same Berkeley DB version in Perl
127as in Postfix.  </p>
128
129<h2><a name="bsd">Building Postfix on BSD systems with multiple
130Berkeley DB versions</a></h2>
131
132<p> Some BSD systems ship with multiple Berkeley DB implementations.
133Normally, Postfix builds with the default DB version that ships
134with the system. </p>
135
136<p> To build Postfix on BSD systems with a non-default DB version,
137use a variant of the following commands: </p>
138
139<blockquote>
140<pre>
141% make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3
142% make
143</pre>
144</blockquote>
145
146<p> Warning: the file format produced by Berkeley DB version 1 is
147not compatible with that of versions 2 and 3 (versions 2 and 3 have
148the same format). If you switch between DB versions, then you may
149have to rebuild all your Postfix DB files. </p>
150
151<p> Warning: if you use Berkeley DB version 2 or later, do not
152enable DB 1.85 compatibility mode. Doing so would break fcntl file
153locking. </p>
154
155<p> Warning: if you use Perl to manipulate Postfix's Berkeley DB
156files, then you need to use the same Berkeley DB version in Perl
157as in Postfix.  </p>
158
159<h2><a name="linux">Building Postfix on Linux systems with multiple
160Berkeley DB versions</a></h2>
161
162<p> Some Linux systems ship with multiple Berkeley DB implementations.
163Normally, Postfix builds with the default DB version that ships
164with the system. </p>
165
166<p> Warning: some Linux system libraries use Berkeley DB. If you
167compile Postfix with a non-default Berkeley DB implementation, then
168every Postfix program will dump core because either the system
169library or Postfix itself ends up using the wrong version. </p>
170
171<p> On Linux, you need to edit the makedefs script in order to
172specify a non-default DB library.  The reason is that the location
173of the default db.h include file changes randomly between vendors
174and between versions, so that Postfix has to choose the file for
175you. </p>
176
177<p> Warning: the file format produced by Berkeley DB version 1 is
178not compatible with that of versions 2 and 3 (versions 2 and 3 have
179the same format). If you switch between DB versions, then you may
180have to rebuild all your Postfix DB files. </p>
181
182<p> Warning: if you use Berkeley DB version 2 or later, do not
183enable DB 1.85 compatibility mode. Doing so would break fcntl file
184locking. </p>
185
186<p> Warning: if you use Perl to manipulate Postfix's Berkeley DB
187files, then you need to use the same Berkeley DB version in Perl
188as in Postfix.  </p>
189
190<h2><a name="tweak">Tweaking performance</a></h2>
191
192<p> Postfix provides two configuration parameters that control how
193much buffering memory Berkeley DB will use. </p>
194
195<ul>
196
197<li> <p> berkeley_db_create_buffer_size (default: 16 MBytes per
198table).  This setting is used by the commands that maintain Berkeley
199DB files: postalias(1) and postmap(1).  For "hash" files, create
200performance degrades rapidly unless the memory pool is O(file size).
201For "btree" files, create performance is good with sorted input even
202for small memory pools, but with random input degrades rapidly
203unless the memory pool is O(file size). </p>
204
205<li> <p> berkeley_db_read_buffer_size (default: 128 kBytes per
206table).  This setting is used by all other Postfix programs. The
207buffer size is adequate for reading. If the cache is smaller than
208the table, random read performance is hardly cache size dependent,
209except with btree tables, where the cache size must be large enough
210to contain the entire path from the root node. Empirical evidence
211shows that 64 kBytes may be sufficient. We double the size to play
212safe, and to anticipate changes in implementation and bloat. </p>
213
214</ul>
215
216<h2><a name="pthread">Missing pthread library trouble</a></h2>
217
218<p> When building Postfix fails with: </p>
219
220<blockquote>
221<pre>
222undefined reference to `pthread_condattr_setpshared'
223undefined reference to `pthread_mutexattr_destroy'
224undefined reference to `pthread_mutexattr_init'
225undefined reference to `pthread_mutex_trylock'
226</pre>
227</blockquote>
228
229<p> Add the "-lpthread" library to the "make makefiles" command. </p>
230
231<blockquote>
232<pre>
233% make makefiles .... AUXLIBS="... -lpthread"
234</pre>
235</blockquote>
236
237<p> More information is available at
238http://www.oracle.com/database/berkeley-db/. </p>
239
240</body>
241
242</html>
243