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