]> git.proxmox.com Git - pmg-docs.git/blame - pmgcm.adoc
add SSL ceriticate generation doc
[pmg-docs.git] / pmgcm.adoc
CommitLineData
a0f910ae
DM
1[[chapter_pmgcm]]
2ifdef::manvolnum[]
3pmgcm(1)
4========
5:pmg-toplevel:
6
7NAME
8----
9
10pmgcm - Proxmox Mail Gateway Cluster Management Toolkit
11
12
13SYNOPSIS
14--------
15
16include::pmgcm.1-synopsis.adoc[]
17
18
19DESCRIPTION
20-----------
21endif::manvolnum[]
22ifndef::manvolnum[]
3ea67bfe
DM
23Cluster Management
24==================
a0f910ae
DM
25:pmg-toplevel:
26endif::manvolnum[]
27
3ea67bfe
DM
28We are living in a world where email becomes more and more important -
29failures in email systems are just not acceptable. To meet these
30requirements we developed the Proxmox HA (High Availability) Cluster.
31
32The {pmg} HA Cluster consists of a master and several slave nodes
33(minimum one node). Configuration is done on the master. Configuration
34and data is synchronized to all cluster nodes over a VPN tunnel. This
35provides the following advantages:
36
37* centralized configuration management
38
39* fully redundant data storage
40
41* high availability
42
43* high performance
44
45We use a unique application level clustering scheme, which provides
46extremely good performance. Special considerations where taken to make
47management as easy as possible. Complete Cluster setup is done within
48minutes, and nodes automatically reintegrate after temporary failures
49without any operator interaction.
50
51image::images/pmg-ha-cluster.png[]
52
53
54Hardware requirements
55---------------------
56
57There are no special hardware requirements, although it is highly
58recommended to use fast and reliable server with redundant disks on
59all cluster nodes (Hardware RAID with BBU and write cache enabled).
60
61The HA Cluster can also run in virtualized environments.
62
63
64Subscriptions
65-------------
66
67Each host in a cluster has its own subscription. If you want support
68for a cluster, each cluster node needs to have a valid
69subscription. All nodes must have the same subscription level.
70
71
72Load balancing
73--------------
74
9aaf2a8c
DM
75It is usually advisable to distribute mail traffic among all cluster
76nodes. Please note that this is not always required, because it is
77also reasonable to use only one node to handle SMTP traffic. The
78second node is used as quarantine host, and only provides the web
79interface to the user quarantine.
80
81The normal mail delivery process looks up DNS Mail Exchange (`MX`)
82records to determine the destination host. A `MX` record tells the
83sending system where to deliver mail for a certain domain. It is also
84possible to have several `MX` records for a single domain, they can have
85different priorities. For example, our `MX` record looks like that:
86
87----
88# dig -t mx proxmox.com
89
90;; ANSWER SECTION:
91proxmox.com. 22879 IN MX 10 mail.proxmox.com.
92
93;; ADDITIONAL SECTION:
94mail.proxmox.com. 22879 IN A 213.129.239.114
95----
96
97Please notice that there is one single `MX` record for the Domain
98`proxmox.com`, pointing to `mail.proxmox.com`. The `dig` command
99automatically puts out the corresponding address record if it
100exists. In our case it points to `213.129.239.114`. The priority of
101our `MX` record is set to 10 (preferred default value).
102
103
104Hot standby with backup `MX` records
105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
107Many people do not want to install two redundant mail proxies, instead
108they use the mail proxy of their ISP as fall-back. This is simply done
109by adding an additional `MX` Record with a lower priority (higher
110number). With the example above this looks like that:
111
112----
113proxmox.com. 22879 IN MX 100 mail.provider.tld.
114----
115
116Sure, your provider must accept mails for your domain and forward
117received mails to you. Please note that such setup is not really
118advisable, because spam detection needs to be done by that backup `MX`
119server also, and external servers provided by ISPs usually don't do
120that.
121
122You will never lose mails with such a setup, because the sending Mail
123Transport Agent (MTA) will simply deliver the mail to the backup
124server (mail.provider.tld) if the primary server (mail.proxmox.com) is
125not available.
126
127NOTE: Any resononable mail server retries mail devivery if the target
128server is not available, i.e. {pmg} stores mail and retries delivery
129for up to one week. So you will not loose mail if you mail server is
130down, even if you run a single server setup.
131
132
133Load balancing with `MX` records
134~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135
136Using your ISPs mail server is not always a good idea, because many
137ISPs do not use advanced spam prevention techniques, or do not filter
138SPAM at all. It is often better to run a second server yourself to
139avoid lower spam detection rates.
140
141Anyways, it’s quite simple to set up a high performance load balanced
142mail cluster using `MX` records. You just need to define two `MX` records
143with the same priority. I will explain this using a complete example
144to make it clearer.
145
146First, you need to have at least 2 working {pmg} servers
147(mail1.example.com and mail2.example.com) configured as cluster (see
148section xref:pmg_cluster_administration[Cluster administration]
149below), each having its own IP address. Let us assume the following
150addresses (DNS address records):
151
152----
153mail1.example.com. 22879 IN A 1.2.3.4
154mail2.example.com. 22879 IN A 1.2.3.5
155----
156
157Btw, it is always a good idea to add reverse lookup entries (PTR
158records) for those hosts. Many email systems nowadays reject mails
159from hosts without valid PTR records. Then you need to define your `MX`
160records:
161
162----
163example.com. 22879 IN MX 10 mail1.example.com.
164example.com. 22879 IN MX 10 mail2.example.com.
165----
166
167This is all you need. You will receive mails on both hosts, more or
168less load-balanced using round-robin scheduling. If one host fails the
169other is used.
170
171
172Other ways
173~~~~~~~~~~
174
175Multiple address records
176^^^^^^^^^^^^^^^^^^^^^^^^
177
178Using several DNS `MX` record is sometime clumsy if you have many
179domains. It is also possible to use one `MX` record per domain, but
180multiple address records:
181
182----
183example.com. 22879 IN MX 10 mail.example.com.
184mail.example.com. 22879 IN A 1.2.3.4
185mail.example.com. 22879 IN A 1.2.3.5
186----
187
188
189Using firewall features
190^^^^^^^^^^^^^^^^^^^^^^^
191
192Many firewalls can do some kind of RR-Scheduling (round-robin) when
193using DNAT. See your firewall manual for more details.
3ea67bfe
DM
194
195
9aaf2a8c 196[[pmg_cluster_administration]]
3ea67bfe
DM
197Cluster administration
198----------------------
199
200Cluster administration is done with a single command line utility
201called `pmgcm'. So you need to login via ssh to manage the cluster
202setup.
203
204NOTE: Always setup the IP configuration before adding a node to the
205cluster. IP address, network mask, gateway address and hostname can’t
206be changed later.
207
208
209Creating a Cluster
210~~~~~~~~~~~~~~~~~~
211
212You can create a cluster from any existing Proxmox host. All data is
213preserved.
214
215* make sure you have the right IP configuration
216 (IP/MASK/GATEWAY/HOSTNAME), because you cannot changed that later
217
218* run the cluster creation command:
219+
220----
221pmgcm create
222----
223
224
225List Cluster Status
226~~~~~~~~~~~~~~~~~~~
227
228----
229pmgcm status
230--NAME(CID)--------------IPADDRESS----ROLE-STATE---------UPTIME---LOAD----MEM---DISK
231pmg5(1) 192.168.2.127 master A 1 day 21:18 0.30 80% 41%
232----
233
234
235Adding Cluster Nodes
236~~~~~~~~~~~~~~~~~~~~
237
238When you add a new node to a cluster (join) all data on that node is
239destroyed. The whole database is initialized with cluster data from
240the master.
241
242* make sure you have the right IP configuration
243
244* run the cluster join command (on the new node):
245+
246----
247pmgcm join <master_ip>
248----
249
250You need to enter the root password of the master host when asked for
251a password.
252
253CAUTION: Node initialization deletes all existing databases, stops and
254then restarts all services accessing the database. So do not add nodes
255which are already active and receive mails.
256
257Also, joining a cluster can take several minutes, because the new node
258needs to synchronize all data from the master (although this is done
259in the background).
260
261NOTE: If you join a new node, existing quarantined items from the other nodes are not synchronized to the new node.
262
263
264Deleting Nodes
265~~~~~~~~~~~~~~
266
267Please detach nodes from the cluster network before removing them
268from the cluster configuration. Then run the following command on
269the master node:
270
271----
272pmgcm delete <cid>
273----
274
275Parameter `<cid>` is the unique cluster node ID, as listed with `pmgcm status`.
276
277
278Disaster Recovery
279~~~~~~~~~~~~~~~~~
280
281It is highly recommended to use redundant disks on all cluster nodes
282(RAID). So in almost any circumstances you just need to replace the
283damaged hardware or disk. {pmg} uses an asynchronous
284clustering algorithm, so you just need to reboot the repaired node,
285and everything will work again transparently.
286
287The following scenarios only apply when you really loose the contents
288of the hard disk.
289
290
291Single Node Failure
292^^^^^^^^^^^^^^^^^^^
293
294* delete failed node on master
295+
296----
297pmgcm delete <cid>
298----
299
300* add (re-join) a new node
301+
302----
303pmgcm join <master_ip>
304----
305
306
307Master Failure
308^^^^^^^^^^^^^^
309
310* force another node to be master
311+
312-----
313pmgcm promote
314-----
315
316* tell other nodes that master has changed
317+
318----
319pmgcm sync --master_ip <master_ip>
320----
321
322
323Total Cluster Failure
324^^^^^^^^^^^^^^^^^^^^^
325
326* restore backup (Cluster and node information is not restored, you
327 have to recreate master and nodes)
328
329* tell it to become master
330+
331----
332pmgcm create
333----
334
335* install new nodes
336
337* add those new nodes to the cluster
338+
339----
340pmgcm join <master_ip>
341----
342
a0f910ae
DM
343
344ifdef::manvolnum[]
345include::pmg-copyright.adoc[]
346endif::manvolnum[]