xref: /netbsd-src/external/ibm-public/postfix/dist/html/MULTI_INSTANCE_README.html (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
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>Managing multiple Postfix instances on a single host</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="">Managing
17multiple Postfix instances on a single host</h1>
18
19<hr>
20
21<h2>Overview </h2>
22
23<p> This document is a guide to managing multiple Postfix instances
24on a single host using the <a href="postmulti.1.html">postmulti(1)</a> instance manager. Multi-instance
25support is available with Postfix version 2.6 and later.  See the
26<a href="postfix-wrapper.5.html">postfix-wrapper(5)</a> manual page for background on the instance
27management framework, and on how to deploy a custom instance manager.
28</p>
29
30<p> Topics covered in this document: </p>
31
32<ul>
33
34<li><a href="#why"> Why multiple Postfix instances </a>
35
36<li><a href="#split"> Null-client instances versus service instances </a>
37
38<li><a href="#quick"> Multi-instance walk-through  </a>
39
40<li><a href="#parts"> Components of a Postfix system </a>
41
42<li><a href="#default"> The default Postfix instance </a>
43
44<li><a href="#group"> Instance groups </a>
45
46<li><a href="#params"> Multi-instance configuration parameters </a>
47
48<li><a href="#how"> Using the postmulti(1) command </a>
49
50<li><a href="#credits"> Credits </a>
51
52</ul>
53
54<h2><a name="why"> Why multiple Postfix instances </a></h2>
55
56<p> Postfix is a general-purpose mail system that can be configured
57to serve a variety of needs. Examples of Postfix applications are: </p>
58
59<ul>
60
61<li><p> Local mail submission for shell users and system processes. </p>
62
63<li><p> Incoming (MX host) email from the Internet. </p>
64
65<li><p> Outbound mail relay for a corporate network. </p>
66
67<li><p> Authenticated submission for roaming users. </p>
68
69<li><p> Before/after content-filter mail. </p>
70
71</ul>
72
73<p> A single Postfix configuration can provide many or all of these
74services, but a complex interplay of settings may be required, for
75example with <a href="master.5.html">master.cf</a> options overriding <a href="postconf.5.html">main.cf</a> settings. In this
76document we take the view that multiple Postfix instances may be a
77simpler way to configure a multi-function Postfix system.  With
78multiple Postfix instances, each instance has its own directories
79for configuration, queue and data files, but it shares all Postfix
80program and documentation files with other instances. </p>
81
82<p> Since there is no single right way to configure your system,
83we recommend that you choose what makes you most comfortable. If
84different Postfix services don't involve incompatible <a href="postconf.5.html">main.cf</a> or
85<a href="master.5.html">master.cf</a> settings, and if they can be combined together without
86complex tricks, then a single monolithic configuration may be the
87simplest approach. </p>
88
89<p> The purpose of multi-instance support in Postfix is not to force
90you to create multiple Postfix instances, but rather to give you a
91choice. Multiple instances give you the freedom to tune each Postfix
92instance to a single task that it does well and to combine instances
93into complete systems. </p>
94
95<p> With the introduction of the <a href="postmulti.1.html">postmulti(1)</a> utility and the reduction
96of the per-instance configuration footprint of a secondary Postfix
97instance to just a <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a> file (other files are now in
98shared locations), we hope that multiple instances will be easier to
99use than ever before. </p>
100
101<h2><a name="split"> Null-client instances versus service instances </a></h2>
102
103<p> In the multi-instance approach to configuring Postfix, the first
104simplification is with the default local-submission Postfix instance.
105</p>
106
107<p> Most UNIX systems require support for email submission with the
108<a href="sendmail.1.html">sendmail(1)</a> command so that system processes such as cron jobs can
109send status reports, and so that system users can send email with
110command-line utilities.  Such email can be handled with a <a
111href="STANDARD_CONFIGURATION_README.html#null_client">null-client</a>
112Postfix configuration that forwards all mail to a central mail hub.
113The null client will typically either not run an SMTP listener at
114all (<a href="postconf.5.html#master_service_disable">master_service_disable</a> = inet), or it will listen only on the
115loopback interface (<a href="postconf.5.html#inet_interfaces">inet_interfaces</a> = loopback-only). </p>
116
117<p> When implementing specialized servers for inbound Internet
118email, outbound MTAs, internal mail hubs, and so on, we recommend
119using a null client for local submission and creating single-function
120secondary Postfix instances to serve the specialized needs. </p>
121
122<blockquote>
123
124<p> Note: usually, you need to use different "<a href="postconf.5.html#myhostname">myhostname</a>" settings
125when you run multiple instances on the same host. Otherwise, there
126will be false "mail loops back to myself" alarms when one instance
127tries to send mail into another instance.  Typically, the null-client
128instance will use the system's hostname, and other instances will
129use their own dedicated "<a href="postconf.5.html#myhostname">myhostname</a>" settings. Different names are
130not needed when instances send mail to each other with a protocol
131other than SMTP, or with SMTP over a TCP port other than 25 as is
132usual with SMTP-based content filters.  </p>
133
134</blockquote>
135
136<h2><a name="quick"> Multi-instance walk-through </a></h2>
137
138<p> Before discussing the fine details of multi-instance operation
139we first show the steps for creating a border mail server. This
140server has with a null-client Postfix instance for local submission,
141an input Postfix instance to receive mail from the Internet, plus
142an <a href="FILTER_README.html#advanced_filter">advanced</a> SMTP
143content-filter and an output Postfix instance to deliver filtered
144email to its internal destination. </p>
145
146<h3>Setting up the null-client Postfix instance </h3>
147
148<p> On a border mail hub, while mail from the Internet requires a
149great deal of scrutiny, locally submitted messages are typically
150limited to mail from cron jobs and other system services. In this
151regard the border MTA is not different from other Unix hosts in
152your environment. For this reason, it will submit locally-generated
153email to the internal mail hub. We start the construction of the
154border mail server with the <a href="#default_instance">default</a>
155instance, which will be a local-submission <a
156href="STANDARD_CONFIGURATION_README.html#null_client">null client</a>:
157</p>
158
159<blockquote>
160<pre>
161/etc/postfix/<a href="postconf.5.html">main.cf</a>:
162    # We are mta1.example.com
163    #
164    <a href="postconf.5.html#myhostname">myhostname</a> = mta1.example.com
165    <a href="postconf.5.html#mydomain">mydomain</a> = example.com
166
167    # Flat user-account namespace in example.com:
168    #
169    #   user@example.com not user@host.example.com
170    #
171    <a href="postconf.5.html#myorigin">myorigin</a> = $<a href="postconf.5.html#mydomain">mydomain</a>
172
173    # Postfix 2.6+, disable inet services, specifically disable <a href="smtpd.8.html">smtpd(8)</a>
174    #
175    <a href="postconf.5.html#master_service_disable">master_service_disable</a> = inet
176
177    # No local delivery:
178    #
179    <a href="postconf.5.html#mydestination">mydestination</a> =
180    <a href="postconf.5.html#local_transport">local_transport</a> = <a href="error.8.html">error</a>:5.1.1 Mailbox unavailable
181    <a href="postconf.5.html#alias_database">alias_database</a> =
182    <a href="postconf.5.html#alias_maps">alias_maps</a> =
183    <a href="postconf.5.html#local_recipient_maps">local_recipient_maps</a> =
184
185    # Send everything to the internal mailhub
186    #
187    <a href="postconf.5.html#relayhost">relayhost</a> = [mailhub.example.com]
188
189    # Indexed table macro:
190    # (use "hash", ... when <a href="CDB_README.html">cdb</a> is not available)
191    #
192    <a href="postconf.5.html#default_database_type">default_database_type</a> = cdb
193    indexed = ${<a href="postconf.5.html#default_database_type">default_database_type</a>}:${<a href="postconf.5.html#config_directory">config_directory</a>}/
194
195    # Expose origin host of mail from "root", ...
196    #
197    <a href="postconf.5.html#smtp_generic_maps">smtp_generic_maps</a> = ${indexed}generic
198
199    # Send messages addressed to "root", ... to the MTA support team
200    #
201    <a href="postconf.5.html#virtual_alias_maps">virtual_alias_maps</a> = ${indexed}virtual
202
203/etc/postfix/generic:
204    # The smarthost supports "+" addressing (<a href="postconf.5.html#recipient_delimiter">recipient_delimiter</a> = +).
205    # Mail from "root" exposes the origin host, without replies
206    # and bounces going back to the same host.
207    #
208    # On clustered MTAs this file is typically machine-built from
209    # a template file. The build process expands the template into
210    # "mtaadmin+root=mta1"
211    #
212    root        mtaadmin+root=mta1
213
214/etc/postfix/virtual:
215    # Caretaker aliases:
216    #
217    root        mtaadmin
218    postmaster  root
219</pre>
220</blockquote>
221
222<p> You would typically also add a Makefile, to automatically run
223<a href="postmap.1.html">postmap(1)</a> commands when source files change. This Makefile also
224creates a "generic" database when none exists. </p>
225
226<blockquote>
227<pre>
228/etc/postfix/Makefile:
229    MTAADMIN=mtaadmin
230
231    all: virtual.cdb generic.cdb
232
233    generic: Makefile
234            @echo Creating $@
235            @rm -f $@.tmp
236            @printf '%s\t%s+root=%s\n' root ${MTAADMIN} `uname -n` &gt; $@.tmp
237            @mv $@.tmp generic
238
239    %.<a href="CDB_README.html">cdb</a>: %
240            postmap <a href="CDB_README.html">cdb</a>:$&lt;
241</pre>
242</blockquote>
243
244<p> Construct the "virtual" and "generic" databases (the latter is
245created by running "make"), then start and test the null-client:
246</p>
247
248<blockquote>
249<pre>
250# cd /etc/postfix; make
251# postfix start
252# sendmail -i -f root -t &lt;&lt;EOF
253From: root
254To: root
255Subject: test
256
257testing
258EOF
259</pre>
260</blockquote>
261
262<p> The test message should be delivered the members of the "mtaadmin"
263address group (or whatever address group you choose) with the
264following headers: </p>
265
266<blockquote>
267<pre>
268From: mtaadmin+root=mta1@example.com
269To: mtadmin+root=mta1@example.com
270Subject: test
271</pre>
272</blockquote>
273
274<h3>Setting up the "output" Postfix instance </h3>
275
276<p> With the null-client instance out of the way, we can create the
277MTA "output" instance that will deliver filtered mail to the inside
278network. We add the "output" instance first, because the output
279instance needs to be up and running before the input instance can
280be fully tested, and when the system boots, the "output" instance
281must start before the input instance. We will put the output and
282input instances into a single instance group named "mta".  </p>
283
284<p> Just once, when adding the first secondary instance, enable
285multi-instance support in the default (null-client) instance: </p>
286
287<blockquote>
288<pre>
289# postmulti -e init
290</pre>
291</blockquote>
292
293<p> Then create the output instance: <p>
294
295<blockquote>
296<pre>
297# postmulti -I postfix-out -G mta -e create
298</pre>
299</blockquote>
300
301<p> The instance configuration directory defaults to /etc/postfix-out,
302more precisely, the "postfix-out" subdirectory of the parent directory
303of the default-instance configuration directory. The new instance will
304be created in a "disabled" state: </p>
305
306<blockquote>
307<pre>
308/etc/postfix-out/<a href="postconf.5.html">main.cf</a>
309    #
310    # ... "stock" <a href="postconf.5.html">main.cf</a> settings ...
311    #
312    <a href="postconf.5.html#multi_instance_name">multi_instance_name</a> = postfix-out
313    <a href="postconf.5.html#queue_directory">queue_directory</a> = /var/spool/postfix-out
314    <a href="postconf.5.html#data_directory">data_directory</a> = /var/lib/postfix-out
315    #
316    <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = no
317    <a href="postconf.5.html#master_service_disable">master_service_disable</a> = inet
318    <a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> =
319</pre>
320</blockquote>
321
322<p> This instance has a "stock" <a href="master.5.html">master.cf</a> file, and its queue and
323data directories, also named "postfix-out", will be located in the
324same parent directories as the corresponding directories of the
325default instance (e.g., /var/spool/postfix-out and /var/lib/postfix-out).
326</p>
327
328<p> While this instance is immediately safe to start, it is not yet
329usefully configured. It needs to be customized to fit the role of a
330post-filter re-injection SMTP service. Typical additions include: </p>
331
332<blockquote>
333<pre>
334/etc/postfix-out/<a href="master.5.html">master.cf</a>:
335    # Replace default "smtp inet" entry with one listening on port 10026.
336    127.0.0.1:10026     inet  n       -       n       -       -       smtpd
337
338/etc/postfix-out/<a href="postconf.5.html">main.cf</a>
339    # ...
340
341    # Comment out if you don't use IPv6 internally
342    # <a href="postconf.5.html#inet_protocols">inet_protocols</a> = ipv4
343    <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> = loopback-only
344    <a href="postconf.5.html#mynetworks_style">mynetworks_style</a> = host
345    <a href="postconf.5.html#smtpd_authorized_xforward_hosts">smtpd_authorized_xforward_hosts</a> = $<a href="postconf.5.html#mynetworks">mynetworks</a>
346
347    # Don't <a href="anvil.8.html">anvil(8)</a> control the re-injection port.
348    #
349    <a href="postconf.5.html#smtpd_client_connection_count_limit">smtpd_client_connection_count_limit</a> = 0
350    <a href="postconf.5.html#smtpd_client_event_limit_exceptions">smtpd_client_event_limit_exceptions</a> = $<a href="postconf.5.html#mynetworks">mynetworks</a>
351
352    # Best practice when <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> is set, as this is not a
353    # "secondary IP personality" configuration.
354    #
355    <a href="postconf.5.html#smtp_bind_address">smtp_bind_address</a> = 0.0.0.0
356
357    # All header rewriting happens upstream
358    #
359    <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> =
360
361    # No local delivery on border gateway
362    #
363    <a href="postconf.5.html#mydestination">mydestination</a> =
364    <a href="postconf.5.html#alias_maps">alias_maps</a> =
365    <a href="postconf.5.html#alias_database">alias_database</a> =
366    <a href="postconf.5.html#local_recipient_maps">local_recipient_maps</a> =
367    <a href="postconf.5.html#local_transport">local_transport</a> = <a href="error.8.html">error</a>:5.1.1 Mailbox unavailable
368
369    # May need a <a href="postconf.5.html#recipient_delimiter">recipient_delimiter</a> for per-user transport lookups:
370    #
371    <a href="postconf.5.html#recipient_delimiter">recipient_delimiter</a> = +
372
373    # Only one (unrestricted client)
374    # With multiple instances, rarely need "-o param=value" overrides
375    # in <a href="master.5.html">master.cf</a>, each instance gets its own <a href="postconf.5.html">main.cf</a> file.
376    #
377    # Postfix 2.10 and later: specify empty <a href="postconf.5.html#smtpd_relay_restrictions">smtpd_relay_restrictions</a>.
378    <a href="postconf.5.html#smtpd_relay_restrictions">smtpd_relay_restrictions</a> =
379    <a href="postconf.5.html#smtpd_recipient_restrictions">smtpd_recipient_restrictions</a> = <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>, reject
380
381    # Tolerate occasional high latency in the  content filter.
382    #
383    <a href="postconf.5.html#smtpd_timeout">smtpd_timeout</a> = 1200s
384
385    # Best when empty, with all parent domain matches explicit.
386    #
387    <a href="postconf.5.html#parent_domain_matches_subdomains">parent_domain_matches_subdomains</a> =
388
389    # Use the "relay" transport for inbound mail, and the default
390    # "smtp" transport for outbound mail (bounces, ...). The latter
391    # won't starve the former of delivery agent slots.
392    #
393    <a href="postconf.5.html#relay_domains">relay_domains</a> = example.com, .example.com
394
395    # With xforward, match the input instance setting, if you
396    # want "yes", set both to "yes".
397    #
398    <a href="postconf.5.html#smtpd_client_port_logging">smtpd_client_port_logging</a> = no
399
400    # Transport settings ...
401    # Message size limit
402    # Concurrency tuning for "relay" and "smtp" transport
403    # ...
404</pre>
405</blockquote>
406
407<p> With the "output" configuration in place, enable and start the
408instance: </p>
409
410<blockquote>
411<pre>
4121 # postmulti -i postfix-out -x postconf -e \
4132     "<a href="postconf.5.html#master_service_disable">master_service_disable</a> =" "<a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> = root"
4143 # postmulti -i postfix-out -e enable
4154 # postmulti -i postfix-out -p start
416</pre>
417</blockquote>
418
419<p> This uses the <a href="postmulti.1.html">postmulti(1)</a> command to invoke <a href="postconf.1.html">postconf(1)</a> in the
420context (MAIL_CONFIG=/etc/postfix-out) of the output instance.  </p>
421
422<ul>
423
424<li> <p> Lines 1-2: With "<a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> = root", the
425superuser can test the postfix-out instance with "postmulti -i
426postfix-out -x sendmail -bv recipient...", but otherwise local
427submission remains disabled.  </p>
428
429<li> <p> Lines 1-2: With "<a href="postconf.5.html#master_service_disable">master_service_disable</a> =", the "inet"
430listeners are re-enabled. </p>
431
432<li> <p> Line 3: The output instance is enabled for multi-instance
433start/stop. </p>
434
435<li> <p> Line 4: The output instance is started. </p>
436
437</ul>
438
439<p> Test the output instance by submitting probe messages via "sendmail
440-bv" and "telnet". For production systems, in-depth configuration tests
441should be done on a lab system. The simple tests just suggested will only
442confirm successful deployment of a configuration that should already be
443known good. </p>
444
445<h3> Setting up the content-filter proxy </h3>
446
447<p> With the output instance ready, deploy your content-filter
448proxy.  Most proxies will need their own /etc/rc* start/stop script.
449Some proxies, however, are started on demand by the Postfix <a href="spawn.8.html">spawn(8)</a>
450service, in which case you need to add the relevant <a href="spawn.8.html">spawn(8)</a> entry
451to the output instance <a href="master.5.html">master.cf</a> file.  </p>
452
453<p> Configure the proxy to listen on 127.0.0.1:10025 and to re-inject
454filtered email to 127.0.0.1:10026.  Start the proxy service if
455necessary, then test the proxy via "telnet" or automated SMTP
456injectors. The proxy should support the following ESMTP features:
457DSN, 8BITMIME, and XFORWARD. In addition, the proxy should support
458multiple mail deliveries within an SMTP session. </p>
459
460<h3> Setting up the input Postfix instance </h3>
461
462<p> The input Postfix instance receives mail from the network and
463sends it through the content filter. Now we create the input instance,
464also part of the "mta" instance group: </p>
465
466<blockquote>
467<pre>
468# postmulti -I postfix-in -G mta -e create
469</pre>
470</blockquote>
471
472<p> The new instance configuration directory defaults to /etc/postfix-in,
473more precisely, the "postfix-in" subdirectory of the parent directory
474of the default-instance configuration directory. The new instance will
475be created in a "disabled" state: </p>
476
477<blockquote>
478<pre>
479/etc/postfix-in/<a href="postconf.5.html">main.cf</a>
480    #
481    # ... "stock" <a href="postconf.5.html">main.cf</a> settings ...
482    #
483    <a href="postconf.5.html#multi_instance_name">multi_instance_name</a> = postfix-in
484    <a href="postconf.5.html#queue_directory">queue_directory</a> = /var/spool/postfix-in
485    <a href="postconf.5.html#data_directory">data_directory</a> = /var/lib/postfix-in
486    #
487    <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = no
488    <a href="postconf.5.html#master_service_disable">master_service_disable</a> = inet
489    <a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> =
490</pre>
491</blockquote>
492
493<p> As before, make appropriate changes to <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a> to
494make the instance production ready. Consider setting "<a href="postconf.5.html#soft_bounce">soft_bounce</a> = yes"
495during the first few hours of deployment, so you can iron-out any unexpected
496"kinks". </p>
497
498<p> Manual testing can start with:
499
500<blockquote>
501<pre>
502/etc/postfix-in/<a href="postconf.5.html">main.cf</a>
503    # Accept only local traffic, but allow impersonation:
504    <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> = 127.0.0.1
505    <a href="postconf.5.html#smtpd_authorized_xclient_hosts">smtpd_authorized_xclient_hosts</a> = 127.0.0.1
506</pre>
507</blockquote>
508
509<p> This allows you to use the Postfix-specific <a
510href="XCLIENT_README.html">XCLIENT</a> SMTP command to safely
511simulate connections from remote systems before any remote systems
512are able to connect. If the test results look good, revert the above
513settings to the required production values. Typical settings in the
514pre-filter input instance include: </p>
515
516<blockquote>
517<pre>
518/etc/postfix-in/<a href="postconf.5.html">main.cf</a>
519    #
520    # ...
521    #
522
523    # No local delivery on border gateway
524    #
525    <a href="postconf.5.html#mydestination">mydestination</a> =
526    <a href="postconf.5.html#alias_maps">alias_maps</a> =
527    <a href="postconf.5.html#alias_database">alias_database</a> =
528    <a href="postconf.5.html#local_recipient_maps">local_recipient_maps</a> =
529    <a href="postconf.5.html#local_transport">local_transport</a> = <a href="error.8.html">error</a>:5.1.1 Mailbox unavailable
530
531    # Don't rewrite remote headers
532    #
533    <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> =
534
535    # All recipients of not yet filtered email go to the same filter together.
536    #
537    # With multiple instances, the content-filter is specified
538    # via transport settings not the "<a href="postconf.5.html#content_filter">content_filter</a>" transport
539    # switch override! Here the filter listens on local port 10025.
540    #
541    # If you need to route some users or recipient domains directly to the
542    # output instance bypassing the filter, just define a transport table
543    # with suitable entries.
544    #
545    <a href="postconf.5.html#default_transport">default_transport</a> = <a href="smtp.8.html">smtp</a>:[127.0.0.1]:10025
546    <a href="postconf.5.html#relay_transport">relay_transport</a> = $<a href="postconf.5.html#default_transport">default_transport</a>
547    <a href="postconf.5.html#virtual_transport">virtual_transport</a> = $<a href="postconf.5.html#default_transport">default_transport</a>
548    <a href="postconf.5.html#transport_maps">transport_maps</a> =
549
550    # Pass original client log information through the filter.
551    #
552    <a href="postconf.5.html#smtp_send_xforward_command">smtp_send_xforward_command</a> = yes
553
554    # Avoid splitting the envelope and scanning messages multiple times.
555    # Match the re-injection server's recipient limit.
556    #
557    <a href="postconf.5.html#smtp_destination_recipient_limit">smtp_destination_recipient_limit</a> = 1000
558
559    # Tolerate occasional high latency in the content filter.
560    #
561    <a href="postconf.5.html#smtp_data_done_timeout">smtp_data_done_timeout</a> = 1200s
562
563    # With xforward, match the output instance setting, if you
564    # want "yes", set both to "yes".
565    #
566    <a href="postconf.5.html#smtpd_client_port_logging">smtpd_client_port_logging</a> = no
567
568    # ... Lots of settings for inbound MX host ...
569</pre>
570</blockquote>
571
572<p> With the "input" instance configured, enable and start it: </p>
573
574<blockquote>
575<pre>
576# postmulti -i postfix-in -x postconf -e \
577    "<a href="postconf.5.html#master_service_disable">master_service_disable</a> =" "<a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> = root"
578# postmulti -i postfix-in -e enable
579# postmulti -i postfix-in -p start
580</pre>
581</blockquote>
582
583<p> That's it. You now have a 3-instance configuration. A null-client
584sending all locally submitted mail to the internal mail hub and a pair of
585"mta" instances that receive mail from the Internet, pass it through a
586content-filter, and then deliver it to the internal destination. </p>
587
588<p> Running "postfix start" or "postfix stop" will now start/stop all
589three Postfix instances. You can use "postfix -c /config/path start"
590to start just one instance, or use the instance name (or instance
591group name) via <a href="postmulti.1.html">postmulti(1)</a>: </p>
592
593<blockquote>
594<pre>
595# postmulti -i - -p stop
596# postmulti -g mta -p status
597# postmulti -i postfix-out -p flush
598# postmulti -i postfix-in -p reload
599# ...
600</pre>
601</blockquote>
602
603<p> This example ends the multi-instance "walk through". The remainder
604of this document provides background information on Postfix
605multi-instance support features and options. </p>
606
607<h2><a name="parts"> Components of a Postfix system </a></h2>
608
609<p> A Postfix system consists of the following components: </p>
610
611<p> Shared among all instances: </p>
612
613<ul>
614
615<li><p> Command-line utilities for administrators and users installed in
616$<a href="postconf.5.html#command_directory">command_directory</a>, $<a href="postconf.5.html#sendmail_path">sendmail_path</a>, $<a href="postconf.5.html#mailq_path">mailq_path</a> and $<a href="postconf.5.html#newaliases_path">newaliases_path</a>. </p>
617
618<li><p> Daemon executables, and run-time support files installed in
619$<a href="postconf.5.html#daemon_directory">daemon_directory</a>. </p>
620
621<li><p> Bundled documentation, installed in $<a href="postconf.5.html#html_directory">html_directory</a>,
622$<a href="postconf.5.html#manpage_directory">manpage_directory</a> and $<a href="postconf.5.html#readme_directory">readme_directory</a>. </p>
623
624<li><p> Entries in /etc/passwd and /etc/group for the $<a href="postconf.5.html#mail_owner">mail_owner</a> user and
625$<a href="postconf.5.html#setgid_group">setgid_group</a> group. The $<a href="postconf.5.html#mail_owner">mail_owner</a> user provides the mail system
626with a protected (non-root) execution context. The $<a href="postconf.5.html#setgid_group">setgid_group</a> group
627is used exclusively to support the setgid <a href="postdrop.1.html">postdrop(1)</a> and <a href="postqueue.1.html">postqueue(1)</a>
628utilities (it <b>must not</b> be the primary group or secondary group
629of any users, including the $<a href="postconf.5.html#mail_owner">mail_owner</a> user). </p>
630
631</ul>
632
633<p> Private to each instance: </p>
634
635<ul>
636
637<li><p> The <a href="postconf.5.html">main.cf</a>, <a href="master.5.html">master.cf</a> (and other optional) configuration
638files in $<a href="postconf.5.html#config_directory">config_directory</a>. </p>
639
640<li> <p> The <a href="QSHAPE_README.html#maildrop_queue">maildrop</a>, incoming, active, deferred and <a href="QSHAPE_README.html#hold_queue">hold queues</a>
641in $<a href="postconf.5.html#queue_directory">queue_directory</a> (which contains additional directories needed
642by Postfix, and which optionally doubles as a chroot jail for Postfix
643daemon processes). </p>
644
645<li> <p> Various caches (TLS session, address verification, ...)
646in $<a href="postconf.5.html#data_directory">data_directory</a>. </p>
647
648</ul>
649
650<p> The Postfix configuration parameters mentioned above are
651collectively referred to as "installation parameters". Their default
652values are set when the Postfix software is built from source, and
653all but one may be optionally set to a non-default value via the
654<a href="postconf.5.html">main.cf</a> file.  The one parameter that (catch-22) cannot be set in
655<a href="postconf.5.html">main.cf</a> is $<a href="postconf.5.html#config_directory">config_directory</a>, as this defines the location of the
656<a href="postconf.5.html">main.cf</a> file itself. </p>
657
658<p> Though <a href="postconf.5.html#config_directory">config_directory</a> cannot be set in <a href="postconf.5.html">main.cf</a>, <a href="postfix.1.html">postfix(1)</a> and
659most of the other command-line Postfix utilities allow you to specify a
660non-default configuration directory via a command line option (typically
661<b>-c</b>) or via the MAIL_CONFIG environment variable. In this way,
662it is possible to have multiple configuration directories on the same
663machine, and to have multiple running <a href="master.8.html">master(8)</a> daemons each with its
664own configuration files, queue directory and data directory. </p>
665
666<p> These multiple running copies of <a href="master.8.html">master(8)</a> share the base Postfix
667software. They do not (and cannot) share their configuration
668directories, queue directories or data directories. </p>
669
670<p> Each combination of configuration directory, together with the queue
671directory and data directory (specified in the corresponding <a href="postconf.5.html">main.cf</a> file)
672make up a Postfix <b>instance</b>. </p>
673
674<h2><a name="default"> The default Postfix instance </a></h2>
675
676<p> One Postfix instance is special: this is the instance whose
677configuration directory is the default one compiled into the Postfix
678utilities. The location of the default configuration directory is
679typically /etc/postfix, and can be queried via the "postconf -d
680<a href="postconf.5.html#config_directory">config_directory</a>" command.  We call the instance with this configuration
681directory the "default instance". </p>
682
683<p> The default instance is responsible for local mail submission. The
684setgid <a href="postdrop.1.html">postdrop(1)</a> utility is used by the <a href="sendmail.1.html">sendmail(1)</a> local submission
685program to spool messages into the <b>maildrop</b> sub-directory of the
686queue directory of the default instance. </p>
687
688<p> Even in the rare case when "sendmail -C" is used to submit local mail
689into a non-default Postfix instance, for security reasons, <a href="postdrop.1.html">postdrop(1)</a>
690will consult the default <a href="postconf.5.html">main.cf</a> file to check the validity of the
691requested non-default configuration directory. </p>
692
693<p> So, while in most other respects, all instances are equal, the
694default instance is "more equal than others". You may choose to create
695additional instances, but you must have at least the default instance,
696with its configuration directory in the default compiled-in location. </p>
697
698<h2><a name="group"> Instance groups </a></h2>
699
700<p> The <a href="postmulti.1.html">postmulti(1)</a> multi-instance manager supports the notion of an
701instance "group". Typically, the member instances of an instance group
702constitute a logical service, and are expected to all be running or all
703be stopped. </p>
704
705<p> In many cases a single Postfix instance will be a complete logical
706"service". You should define such instances as stand-alone instances
707that are not members of any instance "group". The null-client
708instance is an example of a non-group instance. </p>
709
710<p> When a logical service consists of multiple Postfix instances,
711often a pair of pre-filter and post-filter instances with a content
712filter proxy between them, the related instances should be members
713of a single instance group (however, the content filter usually has
714its own start/stop procedure that is separate from any Postfix
715instance).  </p>
716
717<p> The default instance <a href="postconf.5.html">main.cf</a> file's $<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a>
718configuration parameter lists the configuration directories of all
719secondary (non-default) instances. Together with the default instance,
720these secondary instances are managed by the multi-instance manager.
721Instances are started in the order listed, and stopped in the
722opposite order. For instances that are members of a service "group",
723you should arrange to start the service back-to-front, with the
724output stages started and ready to receive mail before the input
725stages are started. </p>
726
727<h2><a name="params"> Multi-instance configuration parameters </a></h2>
728
729<dl>
730
731<dt> <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> </dt>
732
733<dd> <p> This default-instance configuration parameter must be set
734to a suitable multi-instance manager's "wrapper" program that
735controls the starting, stopping, etc. of a multi-instance Postfix
736system. To use the <a href="postmulti.1.html">postmulti(1)</a> manager described in this document,
737this parameter should be set with the "<a href="#init">postmulti
738-e init</a>" command.  </p> </dd>
739
740<dt> <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> </dt>
741
742<dd> <p> This default-instance configuration parameter specifies
743an optional list of the secondary instances controlled via the
744multi-instance manager. Instances are listed in their "start" order,
745with the default instance always started first (if enabled). If
746$<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> is left empty, the <a href="postfix.1.html">postfix(1)</a> command
747runs with multi-instance support turned off, and none of the
748multi_instance_ configuration parameters will have any effect. </p>
749
750<p> Do not assign a non-empty list of secondary instance configuration
751directories to <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> until you have configured a
752suitable <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> setting! This is best accomplished via
753the "<a href="#init">postmulti -e init</a>" command.
754</p> </dd>
755
756<dt> <a href="postconf.5.html#multi_instance_name">multi_instance_name</a> </dt>
757
758<dd> <p> Each Postfix instance may be assigned a distinct name (with
759"postfix -e create/import/assign -I <i>name</i>..."). This name can
760be used with the <a href="postmulti.1.html">postmulti(1)</a> command-line utility to perform tasks
761on the instance by name (rather than the full pathname of its
762configuration directory). Choose a name that concisely captures the
763role of the instance (it must start with "postfix-").  It is an
764error for two instances to have the same $<a href="postconf.5.html#multi_instance_name">multi_instance_name</a>.  You
765can leave an instance "nameless" by leaving this parameter at the
766default empty setting. </p>
767
768<p> To avoid confusion in your logs, if you don't assign each
769secondary instance a non-empty (distinct) $<a href="postconf.5.html#multi_instance_name">multi_instance_name</a>, you
770should make sure that the $<a href="postconf.5.html#syslog_name">syslog_name</a> setting is different for
771each instance. The $<a href="postconf.5.html#syslog_name">syslog_name</a> parameter defaults to $<a href="postconf.5.html#multi_instance_name">multi_instance_name</a>
772when the latter is non-empty. If at all possible, the <a href="postconf.5.html#syslog_name">syslog_name</a>
773should start with "postfix-", this helps log parsers to identify
774log entries from secondary Postfix instances.  </p> </dd>
775
776<dt> <a href="postconf.5.html#multi_instance_group">multi_instance_group</a> </dt>
777
778<dd> <p> Each Postfix instance may be assigned an "instance group"
779name (with "postfix -e create/import/assign -G <i>name</i>...").
780The default (empty) value of <a href="postconf.5.html#multi_instance_group">multi_instance_group</a> parameter indicates
781a stand-alone instance that is not part of any group. The group
782name can be used with the <a href="postmulti.1.html">postmulti(1)</a> command-line utility to
783perform a task on the members of a group by name. Choose a single-word
784group name that concisely captures the role of the group.  </p>
785</dd>
786
787<dt> <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> </dt>
788
789<dd> <p> This parameter controls whether a Postfix instance will
790be started by a Postfix multi-instance manager.  The default value
791is "no". The instance can be started explicitly with "postfix -c
792/path/to/config/directory"; this is useful for testing.  </p>
793
794<p> When an instance is disabled, the <a href="postfix.1.html">postfix(1)</a> "start" command
795is replaced by "check". </p>
796
797<p> Some <a href="postfix.1.html">postfix(1)</a> commands (such as "stop", "flush", ...) require
798a running Postfix instance, and skip instances that are disabled.
799</p>
800
801<p> Other <a href="postfix.1.html">postfix(1)</a> commands (such as "status", "set-permissions",
802"upgrade-configuration", ...) do not require a running Postfix
803system, and apply to all instances whether enabled or not.  </p>
804</dd>
805
806</dl>
807
808<p> The <a href="postmulti.1.html">postmulti(1)</a> utility can be used to create (or destroy) instances.
809It can also be used to "import" or "deport" existing instances into or
810from the list of managed instances. When using <a href="postmulti.1.html">postmulti(1)</a> to manage
811instances, the above configuration parameters are managed for you
812automatically. See below. </p>
813
814<h2><a name="how"> Using the postmulti(1) command </a></h2>
815
816<ul>
817
818<li><a href="#init"> Initializing the multi-instance manager </a>
819
820<li><a href="#list"> Listing managed instances </a>
821
822<li><a href="#start"> Starting or stopping a multi-instance system </a>
823
824<li><a href="#adhoc"> Ad-hoc multi-instance operations </a>
825
826<li><a href="#create"> Creating a new Postfix instance </a>
827
828<li><a href="#destroy"> Destroying a Postfix instance </a>
829
830<li><a href="#import"> Importing an existing Postfix instance </a>
831
832<li><a href="#deport"> Deporting a managed Postfix instance </a>
833
834<li><a href="#assign"> Assigning a new name or group name </a>
835
836<li><a href="#enable"> Enabling/disabling managed instances </a>
837
838</ul>
839
840<h3><a name="init"> Initializing the multi-instance manager </a></h3>
841
842<p> Before <a href="postmulti.1.html">postmulti(1)</a> is used for the first time, you must install
843it as the <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> for your Postfix system and enable
844multi-instance operation of the default Postfix instance. You can then
845proceed to add <a href="#create">new</a> or <a href="#import">existing</a>
846instances to the multi-instance configuration. This initial installation
847is accomplished as follows: </p>
848
849<blockquote>
850<pre>
851    # postmulti -e init
852</pre>
853</blockquote>
854
855<p> This updates the default instance <a href="postconf.5.html">main.cf</a> file as follows: </p>
856
857<blockquote>
858<pre>
859    # Use <a href="postmulti.1.html">postmulti(1)</a> as a <a href="postfix-wrapper.5.html">postfix-wrapper(5)</a>
860    #
861    <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> = ${<a href="postconf.5.html#command_directory">command_directory</a>}/postmulti -p --
862
863    # Configure the default instance to start when in multi-instance mode
864    #
865    <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes
866</pre>
867</blockquote>
868
869<p> If you prefer, you can make these changes by editing the default
870<a href="postconf.5.html">main.cf</a> directly, or by using "postconf -e". </p>
871
872<h3><a name="list"> Listing managed instances </a></h3>
873
874<p> The list of managed instances consists of the default instance and
875the additional instances whose configuration directories are listed
876(in start order) under the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter of the
877default <a href="postconf.5.html">main.cf</a> configuration file.  </p>
878
879<p> You can list selected instances, groups of instances or all
880instances by specifying only the instance matching options with the
881"-l" option.  The "-a" option is assumed if no other instance
882selection options are specified (this behavior changes with the
883"-e" option).  As a special case, even if it has an explicit name,
884the default instance can always be selected via "-i -". </p>
885
886<blockquote>
887<pre>
888# postmulti -l -a
889# postmulti -l -g a_group
890# postmulti -l -i an_instance
891</pre>
892</blockquote>
893
894<p> The output is one line per instance (in "postfix start" order):
895</p>
896
897<blockquote>
898
899<table border="1">
900
901<tr> <th align="left">name</th> <th align="left">group</th> <th
902align="left">enabled</th> <th align="left"><a href="postconf.5.html#config_directory">config_directory</a></th>
903</tr>
904
905<tr> <td>-</td> <td>-</td> <td>yes</td> <td>/etc/postfix
906
907<tr> <td>mta-out</td> <td>mta</td> <td>yes</td> <td>/etc/postfix/mta-out
908
909<tr> <td>mta-in</td> <td>mta</td> <td>yes</td> <td>/etc/postfix-mta-in
910
911<tr> <td>msa-out</td> <td>msa</td> <td>yes</td> <td>/etc/postfix-msa-out
912
913<tr> <td>msa-in</td> <td>msa</td> <td>yes</td> <td>/etc/postfix-msa-in
914
915<tr> <td>test</td> <td>-</td> <td>no</td> <td>/etc/postfix-test
916
917</table>
918
919</blockquote>
920
921<p> The first line showing the column headings is not part of the
922output. When either the instance name or the instance group is not
923set, it is shown as a "-". </p>
924
925<p> When selecting an existing instance via the "-i" option, you
926can always use the full pathname of its configuration directory
927instead of the instance (short) name. This is the only way to select
928a non-default nameless instance. The default instance can be selected
929via "-i -", whether it has a name or not. </p>
930
931<p> To list instances in reverse start order, include the "-R"
932option together with the instance selection options. </p>
933
934<h3><a name="start"> Starting or stopping a multi-instance system
935</a></h3>
936
937<p> To start, stop, reload, etc. the complete (already configured as
938above) multi-instance system just use <a href="postfix.1.html">postfix(1)</a> as you would with a
939single-instance system. The Postfix multi-instance wrapper framework
940insulates Postfix init.d start and package upgrade scripts from the
941details of multi-instance management! </p>
942
943<p> The <b>-p</b> option of <a href="postmulti.1.html">postmulti(1)</a> turns on <a href="postfix.1.html">postfix(1)</a> compatibility
944mode. With this option the remaining arguments are exactly those supported
945by <a href="postfix.1.html">postfix(1)</a>, but commands are applied to all instances or all enabled
946instances as appropriate. As described above, this switch is required
947when using <a href="postmulti.1.html">postmulti(1)</a> as the <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a>. </p>
948
949<p> If you want to specify a subset of instances by name, or group name,
950or run arbitrary commands (not just "postfix stop/start/etc. in the
951context (MAIL_CONFIG environment variable setting) of a particular
952instance or group of instances, then you can use the instance-aware
953<a href="postmulti.1.html">postmulti(1)</a> utility directly. </p>
954
955<h3><a name="adhoc"> Ad-hoc multi-instance operations </a></h3>
956
957<p> The <a href="postmulti.1.html">postmulti(1)</a> command can be used by the administrator to run arbitrary
958commands in the context of one or more Postfix instances. The most common
959use-case is stopping or starting a group of Postfix instances: </p>
960
961<blockquote>
962<pre>
963# postmulti -g mygroup -p start
964# postmulti -g mygroup -p flush
965# postmulti -g mygroup -p reload
966# postmulti -g mygroup -p status
967# postmulti -g mygroup -p stop
968# postmulti -g mygroup -p upgrade-configuration
969</pre>
970</blockquote>
971
972<p> The <b>-p</b> option is essentially a short-hand for a leading
973<b>postfix</b> command argument, but with appropriate additional options
974turned on depending on the first argument. In the case of "start",
975disabled instances are "checked" (postfix check) rather than simply
976skipped. </p>
977
978<p> The resulting command is executed for each candidate instance with
979the <b>MAIL_CONFIG</b> environment variable set to the configuration
980directory of the corresponding Postfix instance. </p>
981
982<p> The <a href="postmulti.1.html">postmulti(1)</a> utility is able to launch commands other than
983<a href="postfix.1.html">postfix(1)</a>, Use the <b>-x</b> option to ask postmulti to execute an
984ad-hoc command for all instances, a group of instances, or just one
985instance. With ad-hoc commands the <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> parameter
986is ignored: the command is unconditionally executed for the instances
987selected via -a, -g or -i. In addition to MAIL_CONFIG, the following
988instance parameters are exported into the command environment: </p>
989
990<blockquote>
991<pre>
992<a href="postconf.5.html#command_directory">command_directory</a>=$<a href="postconf.5.html#command_directory">command_directory</a>
993<a href="postconf.5.html#daemon_directory">daemon_directory</a>=$<a href="postconf.5.html#daemon_directory">daemon_directory</a>
994<a href="postconf.5.html#config_directory">config_directory</a>=$<a href="postconf.5.html#config_directory">config_directory</a>
995<a href="postconf.5.html#queue_directory">queue_directory</a>=$<a href="postconf.5.html#queue_directory">queue_directory</a>
996<a href="postconf.5.html#data_directory">data_directory</a>=$<a href="postconf.5.html#data_directory">data_directory</a>
997<a href="postconf.5.html#multi_instance_name">multi_instance_name</a>=$<a href="postconf.5.html#multi_instance_name">multi_instance_name</a>
998<a href="postconf.5.html#multi_instance_group">multi_instance_group</a>=$<a href="postconf.5.html#multi_instance_group">multi_instance_group</a>
999<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a>=$<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a>
1000</pre>
1001</blockquote>
1002
1003<p> The <a href="postconf.5.html#config_directory">config_directory</a> setting is of course the same as MAIL_CONFIG,
1004and is arguably redundant, but leaving it in is less surprising. If
1005you want to skip disabled instances, just check <a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a>
1006environment variable and exit if it is set to "no". </p>
1007
1008<p> The ability to run ad-hoc commands opens up a wealth of additional
1009possibilities: </p>
1010
1011<ul>
1012
1013<li><p> Specify an instance by name rather than configuration directory
1014when using <a href="sendmail.1.html">sendmail(1)</a> to send a verification probe: </p>
1015
1016<blockquote>
1017<pre>
1018$ postmulti -i postfix-myinst -x sendmail -bv test@example.net
1019</pre>
1020</blockquote>
1021
1022<li><p> Display non-default <a href="postconf.5.html">main.cf</a> settings of all Postfix instances.
1023This uses an inline shell script to package together multiple shell
1024commands to execute for each instance: </p>
1025
1026<blockquote>
1027<pre>
1028$ postmulti -x sh -c 'echo "-- $MAIL_CONFIG"; postconf -n'
1029</pre>
1030</blockquote>
1031
1032<li><p> Put all mail in enabled member instances of a group on hold: </p>
1033
1034<blockquote>
1035<pre>
1036# postmulti -g group_name -x \
1037    sh -c 'test $<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes &amp;&amp; postsuper -h ALL'
1038</pre>
1039</blockquote>
1040
1041<li><p> Show top 10 domains in the <a href="QSHAPE_README.html#deferred_queue">deferred queue</a> of all instances:
1042</p>
1043
1044<blockquote>
1045<pre>
1046# postmulti -x sh -c 'echo "-- $MAIL_CONFIG"; qshape deferred | head -12'
1047</pre>
1048</blockquote>
1049
1050</ul>
1051
1052<h3><a name="create"> Creating a new Postfix instance </a></h3>
1053
1054<p> The <a href="postmulti.1.html">postmulti(1)</a> command can be used to create additional Postfix
1055instances. New instances are created with local submission and all "inet"
1056services disabled via the following non-default parameter settings in
1057the <a href="postconf.5.html">main.cf</a> file: </p>
1058
1059<blockquote>
1060<pre>
1061<a href="postconf.5.html#authorized_submit_users">authorized_submit_users</a> =
1062<a href="postconf.5.html#master_service_disable">master_service_disable</a> = inet
1063</pre>
1064</blockquote>
1065
1066<p> The above settings ensure that new instances are safe to start
1067immediately: they will not conflict with inet listeners in existing
1068Postfix instances.  They will also not accept any mail until they are
1069fully configured, at which point you can do away with one or both of
1070the above safety measures. </p>
1071
1072<p> The <a href="postmulti.1.html">postmulti(1)</a> command encourages a preferred way of organizing
1073the configuration directories, queue directories and data directories
1074of non-default instances. If the default instance settings are: </p>
1075
1076<blockquote>
1077<pre>
1078<a href="postconf.5.html#config_directory">config_directory</a> = /conf-path/postfix
1079<a href="postconf.5.html#queue_directory">queue_directory</a> = /queue-path/postfix
1080<a href="postconf.5.html#data_directory">data_directory</a> = /data-path/postfix
1081</pre>
1082</blockquote>
1083
1084<p> A newly-created instance named <i>postfix-myinst</i> will by default
1085have: </p>
1086
1087<blockquote>
1088<pre>
1089<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = no
1090<a href="postconf.5.html#multi_instance_name">multi_instance_name</a> = postfix-myinst
1091<a href="postconf.5.html#config_directory">config_directory</a> = /conf-path/postfix-myinst
1092<a href="postconf.5.html#queue_directory">queue_directory</a> = /queue-path/postfix-myinst
1093<a href="postconf.5.html#data_directory">data_directory</a> = /data-path/postfix-myinst
1094</pre>
1095</blockquote>
1096
1097<p> You can override any of these defaults when creating the instance,
1098but unless you want to spread instance queue directories over multiple
1099file-systems, use the default naming strategy. It keeps the multiple
1100instances organized in a uniform, predictable fashion. </p>
1101
1102<p> When specifying the instance name later, you can refer to it
1103either as "postfix-myinst", or via the full path of the configuration
1104directory. </p>
1105
1106<p> To create a new instance just use the <b>-e create</b> option: </p>
1107
1108<blockquote>
1109<pre>
1110# postmulti -I postfix-myinst -e create
1111</pre>
1112</blockquote>
1113
1114<p> If the new instance is to belong to a group of related instances that
1115implement a single logical service, assign it to a group: </p>
1116
1117<blockquote>
1118<pre>
1119# postmulti -I postfix-myinst -G mygroup -e create
1120</pre>
1121</blockquote>
1122
1123<p> If you want to override the conventional values of the instance
1124installation parameters, specify their values on the command-line: </p>
1125
1126<blockquote>
1127<pre>
1128# postmulti [-I postfix-myinst] [-G mygroup] -e create \
1129        "<a href="postconf.5.html#config_directory">config_directory</a> = /path/to/config_directory" \
1130        "<a href="postconf.5.html#queue_directory">queue_directory</a> = /path/to/queue_directory" \
1131        "<a href="postconf.5.html#data_directory">data_directory</a> = /path/to/data_directory"
1132</pre>
1133</blockquote>
1134
1135<p> A note on the <b>-I</b> and <b>-G</b> options above. These are always
1136used to assign a name or group name to an instance, while the <b>-i</b>
1137and <b>-g</b> options always select existing instances.  By default,
1138the configuration directories of newly managed instances are appended
1139to the instance list. You can use the "-i" or "-g" or "-a" options to
1140insert the new instance before the specified instance or group, or at
1141the beginning of the instance list (<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter
1142of the default instance). </p>
1143
1144<p> If you do specify a name (use "-I" with a name that is not "-")
1145for the new instance, you may omit any of the 3 instance installation
1146parameters whose instance-name based value is acceptable. Otherwise, all
1147three instance installation parameters are required. You should set the
1148"<a href="postconf.5.html#syslog_name">syslog_name</a>" explicitly in the <a href="postconf.5.html">main.cf</a> file of a "nameless" instance,
1149in order to avoid confusion in the mail logs when multiple instances
1150are in use. </p>
1151
1152<h3><a name="destroy"> Destroying a Postfix instance </a></h3>
1153
1154<p> If you no longer need an instance, you can destroy it via: </p>
1155
1156<blockquote>
1157<pre>
1158# postmulti -i postfix-myinst -p stop
1159# postmulti -i postfix-myinst -e disable
1160# postmulti -i postfix-myinst -e destroy
1161</pre>
1162</blockquote>
1163
1164<p> The instance must be stopped, disabled and have no queued messages.
1165This is expected to fully delete a just created instance that has never
1166been used. If the instance is not freshly created, files added after
1167the instance was created will remain in the configuration, queue or
1168data directories, in which case the corresponding directory may not
1169be fully removed and a warning to that effect will be displayed. You
1170can complete the destruction of the instance manually by removing any
1171unwanted remnants of the instance-specific "private" directories. </p>
1172
1173<h3><a name="import"> Importing an existing Postfix instance </a></h3>
1174
1175<p> If you already have an existing secondary Postfix instance that is
1176not yet managed via <a href="postmulti.1.html">postmulti(1)</a>, you can "import" it into the list
1177of managed instances. If your instance is already using the default
1178configuration directory naming scheme, just specify the corresponding
1179instance name (the <a href="postconf.5.html#multi_instance_name">multi_instance_name</a> parameter in its configuration
1180file will be adjusted to match this name if necessary): </p>
1181
1182<blockquote>
1183<pre>
1184# postmulti -I postfix-myinst [-G mygroup] -e import
1185</pre>
1186</blockquote>
1187
1188<p> Otherwise, you must specify the location of its configuration
1189directory: </p>
1190
1191<blockquote>
1192<pre>
1193# postmulti [-I postfix-myinst] [-G mygroup] -e import \
1194        "<a href="postconf.5.html#config_directory">config_directory</a> = /path/of/config_directory"
1195</pre>
1196</blockquote>
1197
1198<p> When the instance is imported, you can assign a name or a group. As
1199with <a href="#create">"create"</a>, you can control the placement of the
1200new instance in the start order by using "-i", "-g" or "-a" to prepend
1201before the selected instance or instances. </p>
1202
1203<p> An imported instance is usually not multi-instance "enabled",
1204unless it was part of a multi-instance configuration at an earlier
1205time.  If it is fully configured and ready to run, don't forget
1206to <a href="#enable">enable</a> it and if necessary start it. When
1207other enabled instances are already running, new instances need to
1208be started individually when they are first created or imported.
1209</p>
1210
1211<p> To find out what instances are running, use: </p>
1212
1213<blockquote>
1214<pre>
1215# postfix status
1216</pre>
1217</blockquote>
1218
1219<h3><a name="deport"> Deporting a managed Postfix instance </a></h3>
1220
1221<p> You can "deport" an existing instance from the list of managed
1222instances.  This does not destroy the instance, rather the instance
1223just becomes a stand-alone Postfix instance not registered with the
1224multi-instance manager. <a href="postmulti.1.html">postmulti(1)</a> will refuse to "deport" an
1225instance that is not stopped and disabled. </p>
1226
1227<blockquote>
1228<pre>
1229# postmulti -i postfix-myinst -p stop
1230# postmulti -i postfix-myinst -e disable
1231# postmulti -i postfix-myinst -e deport
1232</pre>
1233</blockquote>
1234
1235<h3><a name="assign"> Assigning a new name or group name </a></h3>
1236
1237<p> You can assign a new name or new group to a managed instance.
1238Use "-" as the new value to assign the instance to no group or make it
1239nameless. To specify a nameless secondary instance use the configuration
1240directory path instead of the old name: </p>
1241
1242<blockquote>
1243<pre>
1244# postmulti -i postfix-old [-I postfix-new] [-G newgroup] -e assign
1245</pre>
1246</blockquote>
1247
1248<h3><a name="enable"> Enabling/disabling managed instances </a></h3>
1249
1250<p> You can enable or disable a managed instance. As documented in
1251<a href="postfix-wrapper.5.html">postfix-wrapper(5)</a>, disabled instances are skipped with actions
1252that <a href="postconf.5.html#postmulti_start_commands">start</a>,
1253<a href="postconf.5.html#postmulti_start_commands">stop</a> or <a
1254href="postconf.5.html#postmulti_control_commands">control</a> running
1255Postfix instances. </p>
1256
1257<blockquote>
1258<pre>
1259# postmulti -i postfix-myinst -e enable
1260# postmulti -i postfix-myinst -e disable
1261</pre>
1262</blockquote>
1263
1264<h2><a name="credits"> Credits </a></h2>
1265
1266<p> Wietse Venema created Postfix, designed and implemented the
1267multi-instance wrapper framework and provided design feedback that made
1268the <a href="postmulti.1.html">postmulti(1)</a> utility much more general and useful than originally
1269envisioned. </p>
1270
1271<p> The <a href="postmulti.1.html">postmulti(1)</a> utility was developed by Victor Duchovni of Morgan
1272Stanley, who also wrote the initial version of this document. </p>
1273
1274</body> </html>
1275