File: replication_examples.rst.txt

package info (click to toggle)
cyrus-imapd 3.10.0~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 86,332 kB
  • sloc: ansic: 284,810; perl: 135,824; javascript: 9,562; sh: 5,728; yacc: 2,565; cpp: 2,147; makefile: 2,133; lex: 662; xml: 621; awk: 303; python: 279; asm: 262
file content (164 lines) | stat: -rw-r--r-- 5,462 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.. _imap-developer-guidance-replication-examples:

..  Note: This document was converted from the original by Nic Bernstein
    (Onlight).  Any formatting mistakes are my fault and not the
    original author's.

Cyrus IMAP Server: Replication Examples
=======================================

Introduction
------------

The replication system creates a link between two Cyrus mailstores: a
master and a replica system. Both systems can be live mailstores with
active users: here in Cambridge we install systems in pairs.

Typically half of the users will be using each system, and each system
replicates to its partner. In the event of a failover everyone uses the
remaining system in a pair. This is typically safe as the IMAP/POP/SMTP
servers define which of the two systems is the live server for any given
account, and the replica just plays a game of follow my leader.

Occasionally I think about introducing some form of sanity check so that
we have to explicitly issue a command to the remaining backend system as
well as the proxies in the event of a failover.

A short example of replication in action
----------------------------------------

::

    Index:

      #: Annotation
      C: Command issued by client
      S: Command issued by server

    # Authentication between systems is done using SSH key based authentication:

    C: $ ssh -x cyrus-2 /usr/local/cyrus/bin/sync_server
    S: * Sync Server v0.0 [EXPERIMENTAL]

    # Create new auth_state and ask for all information about given list of
    # folders (namely user.dpc22). Returns:
    #
    #   "**" unsolicited response for each mailbox. Returns:
    #      Folder UniqueID, Name, ACL, UIDlast, timestamp for last seen update.
    #
    #   "*" response for each mail message in folder:
    #      UID, GUID, flags (other than \Seen state)

    C: user_some dpc22 user.dpc22
    S: ** 6b98205c796c6c61 user.dpc22 \
    S:     "dpc22   lrswipcda       anonymous       0      " 4151 1062945305
    S: * 1 000000000000000000000000 ()
    S: * 3697 0101003f4c56b00545000000 ()
    S: * 3919 0101003f4c56b04b2900000d ()
    S: * 3937 0101003f4c56b0514900001f ()
    S: * 4066 0101003f4c56b07422000002 ()
    S: * 4089 0101003f4c56b07e56000023 (\answered)
    S: * 4118 0101003f4c56b08328000016 ()
    S: * 4131 0101003f4c56b084d7000002 ()
    S: * 4136 0101003f4c56b087f3000001 ()
    S: * 4140 0101003f4c56b08c9d000026 ()
    S: OK User_Some finished

    # Select a folder to work with

    C: select user.dpc22
    S: OK 6b98205c796c6c61 4151 1062945305

    # Remove message with UID "1" from folder list (message which has been
    # sitting in my inbox since January, has no GUID defined)

    C: expunge 1
    S: OK Expunge Complete

    # Set some user flags on message UID "4140"

    C: setflags 4140 (hello world)
    S: OK Updated flags on 1 messages okay

    # Demonstrate that something has changed:

    C: status
    S: * 3697 0101003f4c56b00545000000 ()
    S: * 3919 0101003f4c56b04b2900000d ()
    S: * 3937 0101003f4c56b0514900001f ()
    S: * 4066 0101003f4c56b07422000002 ()
    S: * 4089 0101003f4c56b07e56000023 (\answered)
    S: * 4118 0101003f4c56b08328000016 ()
    S: * 4131 0101003f4c56b084d7000002 ()
    S: * 4136 0101003f4c56b087f3000001 ()
    S: * 4140 0101003f4c56b08c9d000026 (hello world)
    S: OK 4151

    # Now lets correct the damage that we just inflicted:

    C: $ replicate -s cyrus-2 -v -v -m user.dpc22
    S: MAILBOXES user.dpc22
    S: USER_SOME dpc22 user.dpc22
    S: SELECT user.dpc22
    S: SETFLAGS [1 msgs]
    S: UPLOAD [1 msgs]
    S: SETSEEN dpc22 ...
    S: ENDUSER

    C: $ ssh -x cyrus-2 /usr/local/cyrus/bin/sync_server
    S: * Sync Server v0.0 [EXPERIMENTAL]
    S: user_some dpc22 user.dpc22
    S: ** 6b98205c796c6c61 user.dpc22 \
    S:    "dpc22   lrswipcda       anonymous       0      " 4156 1062968731
    S: * 1 000000000000000000000000 ()
    S: * 3697 0101003f4c56b00545000000 ()
    S: * 3919 0101003f4c56b04b2900000d ()
    S: * 3937 0101003f4c56b0514900001f ()
    S: * 4066 0101003f4c56b07422000002 ()
    S: * 4089 0101003f4c56b07e56000023 (\answered)
    S: * 4118 0101003f4c56b08328000016 ()
    S: * 4131 0101003f4c56b084d7000002 ()
    S: * 4136 0101003f4c56b087f3000001 ()
    S: * 4140 0101003f4c56b08c9d000026 ()
    S: OK User_Some finished

    # Back where we started: the replication engine reinserted message UID 0
    # which was missing, and removed "hello world" from message UID 4140

Tracking messages between folders
---------------------------------

::

    # I've just saved a message from my inbox into a folder named "zzz",
    # creating the folder the process.

    C: $ replicate -s cyrus-2 -v -v -m user.dpc22 user.dpc22.zzz

    Replication action on two MAILBOX objects:

    S: MAILBOXES user.dpc22 user.dpc22.zzz

    Ask server for contents of the two folders:

    S:   USER_SOME dpc22 ...

    Reserve message with given GUID in user.dpc22 so that it can be moved

    S:   RESERVE user.dpc22 ...

    Remove message from source folder (reserved copy left behind)

    S:   SELECT user.dpc22
    S:   EXPUNGE [1 msgs]
    S:   SETSEEN dpc22 ...

    Create target folder and copy in message that we reserved (doesn't have to
    be uploaded again)

    S:   CREATE user.dpc22.zzz 7f6f384c3f5ba99a
    S:      "dpc22        lrswipcda       anonymous       0       " 0 1062971802
    S: SELECT user.dpc22.zzz
    S: UPLOAD [1 msgs]
    S: SETSEEN dpc22 ...
    S: ENDUSER