1 M
\bMa
\ban
\bna
\bag
\bgi
\bin
\bng
\bg m
\bmu
\bul
\blt
\bti
\bip
\bpl
\ble
\be P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs o
\bon
\bn a
\ba s
\bsi
\bin
\bng
\bgl
\ble
\be h
\bho
\bos
\bst
\bt
3 -------------------------------------------------------------------------------
5 O
\bOv
\bve
\ber
\brv
\bvi
\bie
\bew
\bw
7 This document is a guide to managing multiple Postfix instances on a single
8 host using the postmulti(1) instance manager. Multi-instance support is
9 available with Postfix version 2.6 and later. See the postfix-wrapper(5) manual
10 page for background on the instance management framework, and on how to deploy
11 a custom instance manager.
13 Topics covered in this document:
15 * Why multiple Postfix instances
16 * Null-client instances versus service instances
17 * Multi-instance walk-through
18 * Components of a Postfix system
19 * The default Postfix instance
21 * Multi-instance configuration parameters
22 * Using the postmulti(1) command
25 W
\bWh
\bhy
\by m
\bmu
\bul
\blt
\bti
\bip
\bpl
\ble
\be P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs
27 Postfix is a general-purpose mail system that can be configured to serve a
28 variety of needs. Examples of Postfix applications are:
30 * Local mail submission for shell users and system processes.
32 * Incoming (MX host) email from the Internet.
34 * Outbound mail relay for a corporate network.
36 * Authenticated submission for roaming users.
38 * Before/after content-filter mail.
40 A single Postfix configuration can provide many or all of these services, but a
41 complex interplay of settings may be required, for example with master.cf
42 options overriding main.cf settings. In this document we take the view that
43 multiple Postfix instances may be a simpler way to configure a multi-function
44 Postfix system. With multiple Postfix instances, each instance has its own
45 directories for configuration, queue and data files, but it shares all Postfix
46 program and documentation files with other instances.
48 Since there is no single right way to configure your system, we recommend that
49 you choose what makes you most comfortable. If different Postfix services don't
50 involve incompatible main.cf or master.cf settings, and if they can be combined
51 together without complex tricks, then a single monolithic configuration may be
52 the simplest approach.
54 The purpose of multi-instance support in Postfix is not to force you to create
55 multiple Postfix instances, but rather to give you a choice. Multiple instances
56 give you the freedom to tune each Postfix instance to a single task that it
57 does well and to combine instances into complete systems.
59 With the introduction of the postmulti(1) utility and the reduction of the per-
60 instance configuration footprint of a secondary Postfix instance to just a
61 main.cf and master.cf file (other files are now in shared locations), we hope
62 that multiple instances will be easier to use than ever before.
64 N
\bNu
\bul
\bll
\bl-
\b-c
\bcl
\bli
\bie
\ben
\bnt
\bt i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs v
\bve
\ber
\brs
\bsu
\bus
\bs s
\bse
\ber
\brv
\bvi
\bic
\bce
\be i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs
66 In the multi-instance approach to configuring Postfix, the first simplification
67 is with the default local-submission Postfix instance.
69 Most UNIX systems require support for email submission with the sendmail(1)
70 command so that system processes such as cron jobs can send status reports, and
71 so that system users can send email with command-line utilities. Such email can
72 be handled with a null-client Postfix configuration that forwards all mail to a
73 central mail hub. The null client will typically either not run an SMTP
74 listener at all (master_service_disable = inet), or it will listen only on the
75 loopback interface (inet_interfaces = loopback-only).
77 When implementing specialized servers for inbound Internet email, outbound
78 MTAs, internal mail hubs, and so on, we recommend using a null client for local
79 submission and creating single-function secondary Postfix instances to serve
80 the specialized needs.
82 Note: usually, you need to use different "myhostname" settings when you run
83 multiple instances on the same host. Otherwise, there will be false "mail
84 loops back to myself" alarms when one instance tries to send mail into
85 another instance. Typically, the null-client instance will use the system's
86 hostname, and other instances will use their own dedicated "myhostname"
87 settings. Different names are not needed when instances send mail to each
88 other with a protocol other than SMTP, or with SMTP over a TCP port other
89 than 25 as is usual with SMTP-based content filters.
91 M
\bMu
\bul
\blt
\bti
\bi-
\b-i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be w
\bwa
\bal
\blk
\bk-
\b-t
\bth
\bhr
\bro
\bou
\bug
\bgh
\bh
93 Before discussing the fine details of multi-instance operation we first show
94 the steps for creating a border mail server. This server has with a null-client
95 Postfix instance for local submission, an input Postfix instance to receive
96 mail from the Internet, plus an advanced SMTP content-filter and an output
97 Postfix instance to deliver filtered email to its internal destination.
99 S
\bSe
\bet
\btt
\bti
\bin
\bng
\bg u
\bup
\bp t
\bth
\bhe
\be n
\bnu
\bul
\bll
\bl-
\b-c
\bcl
\bli
\bie
\ben
\bnt
\bt P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
101 On a border mail hub, while mail from the Internet requires a great deal of
102 scrutiny, locally submitted messages are typically limited to mail from cron
103 jobs and other system services. In this regard the border MTA is not different
104 from other Unix hosts in your environment. For this reason, it will submit
105 locally-generated email to the internal mail hub. We start the construction of
106 the border mail server with the default instance, which will be a local-
107 submission null client:
109 /etc/postfix/main.cf:
110 # We are mta1.example.com
112 myhostname = mta1.example.com
113 mydomain = example.com
115 # Flat user-account namespace in example.com:
117 # user@example.com not user@host.example.com
121 # Postfix 2.6+, disable inet services, specifically disable smtpd(8)
123 master_service_disable = inet
128 local_transport = error:5.1.1 Mailbox unavailable
131 local_recipient_maps =
133 # Send everything to the internal mailhub
135 relayhost = [mailhub.example.com]
137 # Indexed table macro:
138 # (use "hash", ... when cdb is not available)
140 default_database_type = cdb
141 indexed = ${default_database_type}:${config_directory}/
143 # Expose origin host of mail from "root", ...
145 smtp_generic_maps = ${indexed}generic
147 # Send messages addressed to "root", ... to the MTA support team
149 virtual_alias_maps = ${indexed}virtual
151 /etc/postfix/generic:
152 # The smarthost supports "+" addressing (recipient_delimiter = +).
153 # Mail from "root" exposes the origin host, without replies
154 # and bounces going back to the same host.
156 # On clustered MTAs this file is typically machine-built from
157 # a template file. The build process expands the template into
158 # "mtaadmin+root=mta1"
160 root mtaadmin+root=mta1
162 /etc/postfix/virtual:
168 You would typically also add a Makefile, to automatically run postmap(1)
169 commands when source files change. This Makefile also creates a "generic"
170 database when none exists.
172 /etc/postfix/Makefile:
175 all: virtual.cdb generic.cdb
180 @printf '%s\t%s+root=%s\n' root $MTAADMIN `uname -n` > $@.tmp
186 Construct the "virtual" and "generic" databases (the latter is created by
187 running "make"), then start and test the null-client:
189 # cd /etc/postfix; make
191 # sendmail -i -f root -t <<EOF
199 The test message should be delivered the members of the "mtaadmin" address
200 group (or whatever address group you choose) with the following headers:
202 From: mtaadmin+root=mta1@example.com
203 To: mtadmin+root=mta1@example.com
206 S
\bSe
\bet
\btt
\bti
\bin
\bng
\bg u
\bup
\bp t
\bth
\bhe
\be "
\b"o
\bou
\but
\btp
\bpu
\but
\bt"
\b" P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
208 With the null-client instance out of the way, we can create the MTA "output"
209 instance that will deliver filtered mail to the inside network. We add the
210 "output" instance first, because the output instance needs to be up and running
211 before the input instance can be fully tested, and when the system boots, the
212 "output" instance must start before the input instance. We will put the output
213 and input instances into a single instance group named "mta".
215 Just once, when adding the first secondary instance, enable multi-instance
216 support in the default (null-client) instance:
220 Then create the output instance:
222 # postmulti -I postfix-out -G mta -e create
224 The instance configuration directory defaults to /etc/postfix-out, more
225 precisely, the "postfix-out" subdirectory of the parent directory of the
226 default-instance configuration directory. The new instance will be created in a
229 /etc/postfix-out/main.cf
231 # ... "stock" main.cf settings ...
233 multi_instance_name = postfix-out
234 queue_directory = /var/spool/postfix-out
235 data_directory = /var/lib/postfix-out
237 multi_instance_enable = no
238 master_service_disable = inet
239 authorized_submit_users =
241 This instance has a "stock" master.cf file, and its queue and data directories,
242 also named "postfix-out", will be located in the same parent directories as the
243 corresponding directories of the default instance (e.g., /var/spool/postfix-out
244 and /var/lib/postfix-out).
246 While this instance is immediately safe to start, it is not yet usefully
247 configured. It needs to be customized to fit the role of a post-filter re-
248 injection SMTP service. Typical additions include:
250 /etc/postfix-out/master.cf:
251 # Replace default "smtp inet" entry with one listening on port 10026.
252 127.0.0.1:10026 inet n - n - - smtpd
254 /etc/postfix-out/main.cf
257 # Comment out if you don't use IPv6 internally
258 # inet_protocols = ipv4
259 inet_interfaces = loopback-only
260 mynetworks_style = host
261 smtpd_authorized_xforward_hosts = $mynetworks
263 # Don't anvil(8) control the re-injection port.
265 smtpd_client_connection_count_limit = 0
266 smtpd_client_event_limit_exceptions = $mynetworks
268 # Best practice when inet_interfaces is set, as this is not a
269 # "secondary IP personality" configuration.
271 smtp_bind_address = 0.0.0.0
273 # All header rewriting happens upstream
275 local_header_rewrite_clients =
277 # No local delivery on border gateway
282 local_recipient_maps =
283 local_transport = error:5.1.1 Mailbox unavailable
285 # May need a recipient_delimiter for per-user transport lookups:
287 recipient_delimiter = +
289 # Only one (unrestricted client)
290 # With multiple instances, rarely need "-o param=value" overrides
291 # in master.cf, each instance gets its own main.cf file.
293 smtpd_recipient_restrictions = permit_mynetworks, reject
295 # Tolerate occasional high latency in the content filter.
297 smtpd_timeout = 1200s
299 # Best when empty, with all parent domain matches explicit.
301 parent_domain_matches_subdomains =
303 # Use the "relay" transport for inbound mail, and the default
304 # "smtp" transport for outbound mail (bounces, ...). The latter
305 # won't starve the former of delivery agent slots.
307 relay_domains = example.com, .example.com
309 # With xforward, match the input instance setting, if you
310 # want "yes", set both to "yes".
312 smtpd_client_port_logging = no
314 # Transport settings ...
316 # Concurrency tuning for "relay" and "smtp" transport
319 With the "output" configuration in place, enable and start the instance:
321 1 # postmulti -i postfix-out -x postconf -e \
322 2 "master_service_disable =" "authorized_submit_users = root"
323 3 # postmulti -i postfix-out -e enable
324 4 # postmulti -i postfix-out -p start
326 This uses the postmulti(1) command to invoke postconf(1) in the context
327 (MAIL_CONFIG=/etc/postfix-out) of the output instance.
329 * Lines 1-2: With "authorized_submit_users = root", the superuser can test
330 the postix-out instance with "postmulti -i postfix-out -x sendmail -bv
331 recipient...", but otherwise local submission remains disabled.
333 * Lines 1-2: With "master_service_disable =", the "inet" listeners are re-
336 * Line 3: The output instance is enabled for multi-instance start/stop.
338 * Line 4: The output instance is started.
340 Test the output instance by submitting probe messages via "sendmail -bv" and
341 "telnet". For production systems, in-depth configuration tests should be done
342 on a lab system. The simple tests just suggested will only confirm successful
343 deployment of a configuration that should already be known good.
345 S
\bSe
\bet
\btt
\bti
\bin
\bng
\bg u
\bup
\bp t
\bth
\bhe
\be c
\bco
\bon
\bnt
\bte
\ben
\bnt
\bt-
\b-f
\bfi
\bil
\blt
\bte
\ber
\br p
\bpr
\bro
\box
\bxy
\by
347 With the output instance ready, deploy your content-filter proxy. Most proxies
348 will need their own /etc/rc* start/stop script. Some proxies, however, are
349 started on demand by the Postfix spawn(8) service, in which case you need to
350 add the relevant spawn(8) entry to the output instance master.cf file.
352 Configure the proxy to listen on 127.0.0.1:10025 and to re-inject filtered
353 email to 127.0.0.1:10026. Start the proxy service if necessary, then test the
354 proxy via "telnet" or automated SMTP injectors. The proxy should support the
355 following ESMTP features: DSN, 8BITMIME, and XFORWARD. In addition, the proxy
356 should support multiple mail deliveries within an SMTP session.
358 S
\bSe
\bet
\btt
\bti
\bin
\bng
\bg u
\bup
\bp t
\bth
\bhe
\be i
\bin
\bnp
\bpu
\but
\bt P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
360 The input Postfix instance receives mail from the network and sends it through
361 the content filter. Now we create the input instance, also part of the "mta"
364 # postmulti -I postfix-in -G mta -e create
366 The new instance configuration directory defaults to /etc/postfix-in, more
367 precisely, the "postfix-in" subdirectory of the parent directory of the
368 default-instance configuration directory. The new instance will be created in a
371 /etc/postfix-in/main.cf
373 # ... "stock" main.cf settings ...
375 multi_instance_name = postfix-in
376 queue_directory = /var/spool/postfix-in
377 data_directory = /var/lib/postfix-in
379 multi_instance_enable = no
380 master_service_disable = inet
381 authorized_submit_users =
383 As before, make appropriate changes to main.cf and master.cf to make the
384 instance production ready. Consider setting "soft_bounce = yes" during the
385 first few hours of deployment, so you can iron-out any unexpected "kinks".
387 Manual testing can start with:
389 /etc/postfix-in/main.cf
390 # Accept only local traffic, but allow impersonation:
391 inet_interfaces = 127.0.0.1
392 smtpd_authorized_xclient_hosts = 127.0.0.1
394 This allows you to use the Postfix-specific XCLIENT SMTP command to safely
395 simulate connections from remote systems before any remote systems are able to
396 connect. If the test results look good, revert the above settings to the
397 required production values. Typical settings in the pre-filter input instance
400 /etc/postfix-in/main.cf
405 # No local delivery on border gateway
410 local_recipient_maps =
411 local_transport = error:5.1.1 Mailbox unavailable
413 # Don't rewrite remote headers
415 local_header_rewrite_clients =
417 # All recipients of not yet filtered email go to the same filter
420 # With multiple instances, the content-filter is specified
421 # via transport settings not the "content_filter" transport
422 # switch override! Here the filter listens on local port 10025.
424 # If you need to route some users or recipient domains directly to the
425 # output instance bypassing the filter, just define a transport table
426 # with suitable entries.
428 default_transport = smtp:[127.0.0.1]:10025
429 relay_transport = $default_transport
430 virtual_transport = $default_transport
433 # Pass original client log information through the filter.
435 smtp_send_xforward_command = yes
437 # Avoid splitting the envelope and scanning messages multiple times.
438 # Match the re-injection server's recipient limit.
440 smtp_destination_recipient_limit = 1000
442 # Tolerate occasional high latency in the content filter.
444 smtp_data_done_timeout = 1200s
446 # With xforward, match the output instance setting, if you
447 # want "yes", set both to "yes".
449 smtpd_client_port_logging = no
451 # ... Lots of settings for inbound MX host ...
453 With the "input" instance configured, enable and start it:
455 # postmulti -i postfix-in -x postconf -e \
456 "master_service_disable =" "authorized_submit_users = root"
457 # postmulti -i postfix-in -e enable
458 # postmulti -i postfix-in -p start
460 That's it. You now have a 3-instance configuration. A null-client sending all
461 locally submitted mail to the internal mail hub and a pair of "mta" instances
462 that receive mail from the Internet, pass it through a content-filter, and then
463 deliver it to the internal destination.
465 Running "postfix start" or "postfix stop" will now start/stop all three Postfix
466 instances. You can use "postfix -c /config/path start" to start just one
467 instance, or use the instance name (or instance group name) via postmulti(1):
469 # postmulti -i - -p stop
470 # postmulti -g mta -p status
471 # postmulti -i postfix-out -p flush
472 # postmulti -i postfix-in -p reload
475 This example ends the multi-instance "walk through". The remainder of this
476 document provides background information on Postfix multi-instance support
477 features and options.
479 C
\bCo
\bom
\bmp
\bpo
\bon
\bne
\ben
\bnt
\bts
\bs o
\bof
\bf a
\ba P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx s
\bsy
\bys
\bst
\bte
\bem
\bm
481 A Postfix system consists of the following components:
483 Shared among all instances:
485 * Command-line utilities for administrators and users installed in
486 $command_directory, $sendmail_path, $mailq_path and $newaliases_path.
488 * Daemon executables, and run-time support files installed in
491 * Bundled documentation, installed in $html_directory, $manpage_directory and
494 * Entries in /etc/passwd and /etc/group for the $mail_owner user and
495 $setgid_group group. The the $mail_owner user provides the mail system with
496 a protected (non-root) execution context. The $setgid_group group is used
497 exclusively to support the setgid postdrop(1) and postqueue(1) utilities
498 (it m
\bmu
\bus
\bst
\bt n
\bno
\bot
\bt be the primary group or secondary group of any users,
499 including the $mail_owner user).
501 Private to each instance:
503 * The main.cf, master.cf (and other optional) configuration files in
506 * The maildrop, incoming, active, deferred and hold queues in
507 $queue_directory (which contains additional directories needed by Postfix,
508 and which optionally doubles as a chroot jail for Postfix daemon
511 * Various caches (TLS session, address verification, ...) in $data_directory.
513 The Postfix configuration parameters mentioned above are collectively referred
514 to as "installation parameters". Their default values are set when the Postfix
515 software is built from source, and all but one may be optionally set to a non-
516 default value via the main.cf file. The one parameter that (catch-22) cannot be
517 set in main.cf is $config_directory, as this defines the location of the
520 Though config_directory cannot be set in main.cf, postfix(1) and most of the
521 other command-line Postfix utilities allow you to specify a non-default
522 configuration directory via a command line option (typically -
\b-c
\bc) or via the
523 MAIL_CONFIG environment variable. In this way, it is possible to have multiple
524 configuration directories on the same machine, and to have multiple running
525 master(8) daemons each with its own configuration files, queue directory and
528 These multiple running copies of master(8) share the base Postfix software.
529 They do not (and cannot) share their configuration directories, queue
530 directories or data directories.
532 Each combination of configuration directory, together with the queue directory
533 and data directory (specified in the corresponding main.cf file) make up a
534 Postfix i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be.
536 T
\bTh
\bhe
\be d
\bde
\bef
\bfa
\bau
\bul
\blt
\bt P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
538 One Postfix instance is special: this is the instance whose configuration
539 directory is the default one compiled into the Postfix utilities. The location
540 of the default configuration directory is typically /etc/postfix, and can be
541 queried via the "postconf -d config_directory" command. We call the instance
542 with this configuration directory the "default instance".
544 The default instance is responsible for local mail submission. The setgid
545 postdrop(1) utility is used by the sendmail(1) local submission program to
546 spool messages into the m
\bma
\bai
\bil
\bld
\bdr
\bro
\bop
\bp sub-directory of the queue directory of the
549 Even in the rare case when "sendmail -C" is used to submit local mail into a
550 non-default Postfix instance, for security reasons, postdrop(1) will consult
551 the default main.cf file to check the validity of the requested non-default
552 configuration directory.
554 So, while in most other respects, all instances are equal, the default instance
555 is "more equal than others". You may choose to create additional instances, but
556 you must have at least the default instance, with its configuration directory
557 in the default compiled-in location.
559 I
\bIn
\bns
\bst
\bta
\ban
\bnc
\bce
\be g
\bgr
\bro
\bou
\bup
\bps
\bs
561 The postmulti(1) multi-instance manager supports the notion of an instance
562 "group". Typically, the member instances of an instance group constitute a
563 logical service, and are expected to all be running or all be stopped.
565 In many cases a single Postfix instance will be a complete logical "service".
566 You should define such instances as stand-alone instances that are not members
567 of any instance "group". The null-client instance is an example of a non-group
570 When a logical service consists of multiple Postfix instances, often a pair of
571 pre-filter and post-filter instances with a content filter proxy between them,
572 the related instances should be members of a single instance group (however,
573 the content filter usually has its own start/stop procedure that is separate
574 from any Postfix instance).
576 The default instance main.cf file's $multi_instance_directories configuration
577 parameter lists the configuration directories of all secondary (non-default)
578 instances. Together with the default instance, these secondary instances are
579 managed by the multi-instance manager. Instances are started in the order
580 listed, and stopped in the opposite order. For instances that are members of a
581 service "group", you should arrange to start the service back-to-front, with
582 the output stages started and ready to receive mail before the input stages are
585 M
\bMu
\bul
\blt
\bti
\bi-
\b-i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be c
\bco
\bon
\bnf
\bfi
\big
\bgu
\bur
\bra
\bat
\bti
\bio
\bon
\bn p
\bpa
\bar
\bra
\bam
\bme
\bet
\bte
\ber
\brs
\bs
587 multi_instance_wrapper
588 This default-instance configuration parameter must be set to a suitable
589 multi-instance manager's "wrapper" program that controls the starting,
590 stopping, etc. of a multi-instance Postfix system. To use the postmulti(1)
591 manager described in this document, this parameter should be set with the
592 "postmulti -e init" command.
594 multi_instance_directories
595 This default-instance configuration parameter specifies an optional list of
596 the secondary instances controlled via the multi-instance manager.
597 Instances are listed in their "start" order, with the default instance
598 always started first (if enabled). If $multi_instance_directories is left
599 empty, the postfix(1) command runs with multi-instance support turned off,
600 and none of the multi_instance_ configuration parameters will have any
603 Do not assign a non-empty list of secondary instance configuration
604 directories to multi_instance_directories until you have configured a
605 suitable multi_instance_wrapper setting! This is best accomplished via the
606 "postmulti -e init" command.
609 Each Postfix instance may be assigned a distinct name (with "postfix -
610 e create/import/assign -I name..."). This name can be used with the
611 postmulti(1) command-line utility to perform tasks on the instance by name
612 (rather than the full pathname of its configuration directory). Choose a
613 name that concisely captures the role of the instance (it must start with
614 "postfix-"). It is an error for two instances to have the same
615 $multi_instance_name. You can leave an instance "nameless" by leaving this
616 parameter at the default empty setting.
618 To avoid confusion in your logs, if you don't assign each secondary
619 instance a non-empty (distinct) $multi_instance_name, you should make sure
620 that the $syslog_name setting is different for each instance. The
621 $syslog_name parameter defaults to $multi_instance_name when the latter is
622 non-empty. If at all possible, the syslog_name should start with "postfix-
623 ", this helps log parsers to identify log entries from secondary Postfix
627 Each Postfix instance may be assigned an "instance group" name (with
628 "postfix -e create/import/assign -G name..."). The default (empty) value of
629 multi_instance_group parameter indicates a stand-alone instance that is not
630 part of any group. The group name can be used with the postmulti(1)
631 command-line utility to perform a task on the members of a group by name.
632 Choose a single-word group name that concisely captures the role of the
635 multi_instance_enable
636 This parameter controls whether a Postfix instance will be started by a
637 Postfix multi-instance manager. The default value is "no". The instance can
638 be started explicitly with "postfix -c /path/to/config/directory"; this is
641 When an instance is disabled, the postfix(1) "start" command is replaced by
644 Some postfix(1) commands (such as "stop", "flush", ...) require a running
645 Postfix instance, and skip instances that are disabled.
647 Other postfix(1) commands (such as "status", "set-permissions", "upgrade-
648 configuration", ...) do not require a running Postfix system, and apply to
649 all instances whether enabled or not.
651 The postmulti(1) utility can be used to create (or destroy) instances. It can
652 also be used to "import" or "deport" existing instances into or from the list
653 of managed instances. When using postmulti(1) to manage instances, the above
654 configuration parameters are managed for you automatically. See below.
656 U
\bUs
\bsi
\bin
\bng
\bg t
\bth
\bhe
\be p
\bpo
\bos
\bst
\btm
\bmu
\bul
\blt
\bti
\bi(
\b(1
\b1)
\b) c
\bco
\bom
\bmm
\bma
\ban
\bnd
\bd
658 * Initializing the multi-instance manager
659 * Listing managed instances
660 * Starting or stopping a multi-instance system
661 * Ad-hoc multi-instance operations
662 * Creating a new Postfix instance
663 * Destroying a Postfix instance
664 * Importing an existing Postfix instance
665 * Deporting a managed Postfix instance
666 * Assigning a new name or group name
667 * Enabling/disabling managed instances
669 I
\bIn
\bni
\bit
\bti
\bia
\bal
\bli
\biz
\bzi
\bin
\bng
\bg t
\bth
\bhe
\be m
\bmu
\bul
\blt
\bti
\bi-
\b-i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be m
\bma
\ban
\bna
\bag
\bge
\ber
\br
671 Before postmulti(1) is used for the first time, you must install it as the
672 multi_instance_wrapper for your Postfix system and enable multi-instance
673 operation of the default Postfix instance. You can then proceed to add new or
674 existing instances to the multi-instance configuration. This initial
675 installation is accomplished as follows:
679 This updates the default instance main.cf file as follows:
681 # Use postmulti(1) as a postfix-wrapper(5)
683 multi_instance_wrapper = ${command_directory}/postmulti -p --
685 # Configure the default instance to start when in multi-instance mode
687 multi_instance_enable = yes
689 If you prefer, you can make these changes by editing the default main.cf
690 directly, or by using "postconf -e".
692 L
\bLi
\bis
\bst
\bti
\bin
\bng
\bg m
\bma
\ban
\bna
\bag
\bge
\bed
\bd i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs
694 The list of managed instances consists of the default instance and the
695 additional instances whose configuration directories are listed (in start
696 order) under the multi_instance_directories parameter of the default main.cf
699 You can list selected instances, groups of instances or all instances by
700 specifying only the instance matching options with the "-l" option. The "-a"
701 option is assumed if no other instance selection options are specified (this
702 behavior changes with the "-e" option). As a special case, even if it has an
703 explicit name, the default instance can always be selected via "-i -".
706 # postmulti -l -g a_group
707 # postmulti -l -i an_instance
709 The output is one line per instance (in "postfix start" order):
711 _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b
712 |n
\bna
\bam
\bme
\be |g
\bgr
\bro
\bou
\bup
\bp|e
\ben
\bna
\bab
\bbl
\ble
\bed
\bd|c
\bco
\bon
\bnf
\bfi
\big
\bg_
\b_d
\bdi
\bir
\bre
\bec
\bct
\bto
\bor
\bry
\by |
713 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
714 |- |- |yes |/etc/postfix |
715 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
716 |mta-out|mta |yes |/etc/postfix/mta-out|
717 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
718 |mta-in |mta |yes |/etc/postfix-mta-in |
719 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
720 |msa-out|msa |yes |/etc/postfix-msa-out|
721 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
722 |msa-in |msa |yes |/etc/postfix-msa-in |
723 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
724 |test |- |no |/etc/postfix-test |
725 |_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b|_
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b _
\b |
727 The first line showing the column headings is not part of the output. When
728 either the instance name or the instance group is not set, it is shown as a "-
731 When selecting an existing instance via the "-i" option, you can always use the
732 full pathname of its configuration directory instead of the instance (short)
733 name. This is the only way to select a non-default nameless instance. The
734 default instance can be selected via "-i -", whether it has a name or not.
736 To list instances in reverse start order, include the "-R" option together with
737 the instance selection options.
739 S
\bSt
\bta
\bar
\brt
\bti
\bin
\bng
\bg o
\bor
\br s
\bst
\bto
\bop
\bpp
\bpi
\bin
\bng
\bg a
\ba m
\bmu
\bul
\blt
\bti
\bi-
\b-i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be s
\bsy
\bys
\bst
\bte
\bem
\bm
741 To start, stop, reload, etc. the complete (already configured as above) multi-
742 instance system just use postfix(1) as you would with a single-instance system.
743 The Postfix multi-instance wrapper framework insulates Postfix init.d start and
744 package upgrade scripts from the details of multi-instance management!
746 The -
\b-p
\bp option of postmulti(1) turns on postfix(1) compatibility mode. With this
747 option the remaining arguments are exactly those supported by postfix(1), but
748 commands are applied to all instances or all enabled instances as appropriate.
749 As described above, this switch is required when using postmulti(1) as the
750 multi_instance_wrapper.
752 If you want to specify a subset of instances by name, or group name, or run
753 arbitrary commands (not just "postfix stop/start/etc. in the context
754 (MAIL_CONFIG environment variable setting) of a particular instance or group of
755 instances, then you can use the instance-aware postmulti(1) utility directly.
757 A
\bAd
\bd-
\b-h
\bho
\boc
\bc m
\bmu
\bul
\blt
\bti
\bi-
\b-i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be o
\bop
\bpe
\ber
\bra
\bat
\bti
\bio
\bon
\bns
\bs
759 The postmulti(1) command can be used by the administrator to run arbitrary
760 commands in the context of one or more Postfix instances. The most common use-
761 case is stopping or starting a group of Postfix instances:
763 # postmulti -g mygroup -p start
764 # postmulti -g mygroup -p flush
765 # postmulti -g mygroup -p reload
766 # postmulti -g mygroup -p status
767 # postmulti -g mygroup -p stop
768 # postmulti -g mygroup -p upgrade-configuration
770 The -
\b-p
\bp option is essentially a short-hand for a leading p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx command
771 argument, but with appropriate additional options turned on depending on the
772 first argument. In the case of "start", disabled instances are "checked"
773 (postfix check) rather than simply skipped.
775 The resulting command is executed for each candidate instance with the
776 M
\bMA
\bAI
\bIL
\bL_
\b_C
\bCO
\bON
\bNF
\bFI
\bIG
\bG environment variable set to the configuration directory of the
777 corresponding Postfix instance.
779 The postmulti(1) utility is able to launch commands other than postfix(1), Use
780 the -
\b-x
\bx option to ask postmulti to execute an ad-hoc command for all instances,
781 a group of instances, or just one instance. With ad-hoc commands the
782 multi_instance_enable parameter is ignored: the command is unconditionally
783 executed for the instances selected via -a, -g or -i. In addition to
784 MAIL_CONFIG, the following instance parameters are exported into the command
787 command_directory=$command_directory
788 daemon_directory=$daemon_directory
789 config_directory=$config_directory
790 queue_directory=$queue_directory
791 data_directory=$data_directory
792 multi_instance_name=$multi_instance_name
793 multi_instance_group=$multi_instance_group
794 multi_instance_enable=$multi_instance_enable
796 The config_directory setting is of course the same as MAIL_CONFIG, and is
797 arguably redundant, but leaving it in is less surprising. If you want to skip
798 disabled instances, just check multi_instance_enable environment variable and
799 exit if it is set to "no".
801 The ability to run ad-hoc commands opens up a wealth of additional
804 * Specify an instance by name rather than configuration directory when using
805 sendmail(1) to send a verification probe:
807 $ postmulti -i postfix-myinst -x sendmail -bv test@example.net
809 * Display non-default main.cf settings of all Postfix instances. This uses an
810 inline shell script to package together multiple shell commands to execute
813 $ postmulti -x sh -c 'echo "-- $MAIL_CONFIG"; postconf -n'
815 * Put all mail in enabled member instances of a group on hold:
817 # postmulti -g group_name -x \
818 sh -c 'test $multi_instance_enable = yes && postsuper -h ALL'
820 * Show top 10 domains in the deferred queue of all instances:
822 # postmulti -x sh -c 'echo "-- $MAIL_CONFIG"; qshape deferred | head -
825 C
\bCr
\bre
\bea
\bat
\bti
\bin
\bng
\bg a
\ba n
\bne
\bew
\bw P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
827 The postmulti(1) command can be used to create additional Postfix instances.
828 New instances are created with local submission and all "inet" services
829 disabled via the following non-default parameter settings in the main.cf file:
831 authorized_submit_users =
832 master_service_disable = inet
834 The above settings ensure that new instances are safe to start immediately:
835 they will not conflict with inet listeners in existing Postfix instances. They
836 will also not accept any mail until they are fully configured, at which point
837 you can do away with one or both of the above safety measures.
839 The postmulti(1) command encourages a preferred way of organizing the
840 configuration directories, queue directories and data directories of non-
841 default instances. If the default instance settings are:
843 config_directory = /conf-path/postfix
844 queue_directory = /queue-path/postfix
845 data_directory = /data-path/postfix
847 A newly-created instance named postfix-myinst will by default have:
849 multi_instance_enable = no
850 multi_instance_name = postfix-myinst
851 config_directory = /conf-path/postfix-myinst
852 queue_directory = /queue-path/postfix-myinst
853 data_directory = /data-path/postfix-myinst
855 You can override any of these defaults when creating the instance, but unless
856 you want to spread instance queue directories over multiple file-systems, use
857 the default naming strategy. It keeps the multiple instances organized in a
858 uniform, predictable fashion.
860 When specifying the instance name later, you can refer to it either as
861 "postfix-myinst", or via the full path of the configuration directory.
863 To create a new instance just use the -
\b-e
\be c
\bcr
\bre
\bea
\bat
\bte
\be option:
865 # postmulti -I postfix-myinst -e create
867 If the new instance is to belong to a group of related instances that implement
868 a single logical service, assign it to a group:
870 # postmulti -I postfix-myinst -G mygroup -e create
872 If you want to override the conventional values of the instance installation
873 parameters, specify their values on the command-line:
875 # postmulti [-I postfix-myinst] [-G mygroup] -e create \
876 "config_directory = /path/to/config_directory" \
877 "queue_directory = /path/to/queue_directory" \
878 "data_directory = /path/to/data_directory"
880 A note on the -
\b-I
\bI and -
\b-G
\bG options above. These are always used to assign a name
881 or group name to an instance, while the -
\b-i
\bi and -
\b-g
\bg options always select
882 existing instances. By default, the configuration directories of newly managed
883 instances are appended to the instance list. You can use the "-i" or "-g" or "-
884 a" options to insert the new instance before the specified instance or group,
885 or at the beginning of the instance list (multi_instance_directories parameter
886 of the default instance).
888 If you do specify a name (use "-I" with a name that is not "-") for the new
889 instance, you may omit any of the 3 instance installation parameters whose
890 instance-name based value is acceptable. Otherwise, all three instance
891 installation parameters are required. You should set the "syslog_name"
892 explicitly in the main.cf file of a "nameless" instance, in order to avoid
893 confusion in the mail logs when multiple instances are in use.
895 D
\bDe
\bes
\bst
\btr
\bro
\boy
\byi
\bin
\bng
\bg a
\ba P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
897 If you no longer need an instance, you can destroy it via:
899 # postmulti -i postfix-myinst -p stop
900 # postmulti -i postfix-myinst -e disable
901 # postmulti -i postfix-myinst -e destroy
903 The instance must be stopped, disabled and have no queued messages. This is
904 expected to fully delete a just created instance that has never been used. If
905 the instance is not freshly created, files added after the instance was created
906 will remain in the configuration, queue or data directories, in which case the
907 corresponding directory may not be fully removed and a warning to that effect
908 will be displayed. You can complete the destruction of the instance manually by
909 removing any unwanted remnants of the instance-specific "private" directories.
911 I
\bIm
\bmp
\bpo
\bor
\brt
\bti
\bin
\bng
\bg a
\ban
\bn e
\bex
\bxi
\bis
\bst
\bti
\bin
\bng
\bg P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
913 If you already have an existing secondary Postfix instance that is not yet
914 managed via postmulti(1), you can "import" it into the list of managed
915 instances. If your instance is already using the default configuration
916 directory naming scheme, just specify the corresponding instance name (the
917 multi_instance_name parameter in its configuration file will be adjusted to
918 match this name if necessary):
920 # postmulti -I postfix-myinst [-G mygroup] -e import
922 Otherwise, you must specify the location of its configuration directory:
924 # postmulti [-I postfix-myinst] [-G mygroup] -e import \
925 "config_directory = /path/of/config_directory"
927 When the instance is imported, you can assign a name or a group. As with
928 "create", you can control the placement of the new instance in the start order
929 by using "-i", "-g" or "-a" to prepend before the selected instance or
932 An imported instance is usually not multi-instance "enabled", unless it was
933 part of a multi-instance configuration at an earlier time. If it is fully
934 configured and ready to run, don't forget to enable it and if necessary start
935 it. When other enabled instances are already running, new instances need to be
936 started individually when they are first created or imported.
938 To find out what instances are running, use:
942 D
\bDe
\bep
\bpo
\bor
\brt
\bti
\bin
\bng
\bg a
\ba m
\bma
\ban
\bna
\bag
\bge
\bed
\bd P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\be
944 You can "deport" an existing instance from the list of managed instances. This
945 does not destroy the instance, rather the instance just becomes a stand-alone
946 Postfix instance not registered with the multi-instance manager. postmulti(1)
947 will refuse to "deport" an instance that is not stopped and disabled.
949 # postmulti -i postfix-myinst -p stop
950 # postmulti -i postfix-myinst -e disable
951 # postmulti -i postfix-myinst -e deport
953 A
\bAs
\bss
\bsi
\big
\bgn
\bni
\bin
\bng
\bg a
\ba n
\bne
\bew
\bw n
\bna
\bam
\bme
\be o
\bor
\br g
\bgr
\bro
\bou
\bup
\bp n
\bna
\bam
\bme
\be
955 You can assign a new name or new group to a managed instance. Use "-" as the
956 new value to assign the instance to no group or make it nameless. To specify a
957 nameless secondary instance use the configuration directory path instead of the
960 # postmulti -i postfix-old [-I postfix-new] [-G newgroup] -e assign
962 E
\bEn
\bna
\bab
\bbl
\bli
\bin
\bng
\bg/
\b/d
\bdi
\bis
\bsa
\bab
\bbl
\bli
\bin
\bng
\bg m
\bma
\ban
\bna
\bag
\bge
\bed
\bd i
\bin
\bns
\bst
\bta
\ban
\bnc
\bce
\bes
\bs
964 You can enable or disable a managed instance. As documented in postfix-wrapper
965 (5), disabled instances are skipped with actions that start, stop or control
966 running Postfix instances.
968 # postmulti -i postfix-myinst -e enable
969 # postmulti -i postfix-myinst -e disable
971 C
\bCr
\bre
\bed
\bdi
\bit
\bts
\bs
973 Wietse Venema created Postfix, designed and implemented the multi-instance
974 wrapper framework and provided design feedback that made the postmulti(1)
975 utility much more general and useful than originally envisioned.
977 The postmulti(1) utility was developed by Victor Duchovni of Morgan Stanley,
978 who also wrote the initial version of this document.