forked from adrian15/hazimbra-thesis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdrbd-setup.tex
203 lines (174 loc) · 6.03 KB
/
drbd-setup.tex
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
% DRBD Setup
\chapter{DRBD Setup}
\label{chap:drbd-setup}
This chapter explains the DRBD Setup.
\section {Introduction}
DRBD is a system that let us mirror a block device via an assigned device. DRBD can be understood as network based raid-1 and it is used in HA clusters (\cite{LinbitDRBDWhatIs}).
We are using DRBD to mirror the block device where Zimbra files will be stored in.
\section {Requirements}
We will install DRBD packages for the Ubuntu 12.04 system thanks to the following command:
\begin{verbatim}
sudo apt-get install drbd8-utils
\end{verbatim}
in both nodes.
\section {Communication hosts}
For the purpose of both DRBD and Corosync communication we need to define our hosts from the communication link point of view. We need to edit \textit{/etc/hosts} and make sure we have \textbf{in both nodes}:
\begin{verbatim}
10.0.66.201 primary.zimbraha.lan primary
10.0.66.202 secondary.zimbraha.lan secondary
\end{verbatim}
by the means of removing:
\begin{verbatim}
127.0.1.1 primary
\end{verbatim}
or
\begin{verbatim}
127.0.1.1 secondary
\end{verbatim}
if needed.
We also need to define the hostnames correctly in both nodes.
\textbf{On primary node} we will make sure that \textit{/etc/hostname} contains:
\begin{verbatim}
primary
\end{verbatim}
. In order to apply changes we will run:
\begin{verbatim}
service hostname restart
\end{verbatim}
Same operation but using \textit{secondary} will need to be performed \textbf{on secondary node}.
\section {Disable Zimbra}
As Zimbra is using the DRBD backing device which is \textit{/dev/sda3} we need to unmount it and that means that we need to stop Zimbra services before doing so.
So we will first stop zimbra on \textbf{primary node} by doing:
\begin{verbatim}
service zimbra stop
\end{verbatim}
And then in \textbf{both nodes} we will umount the partition with:
\begin{verbatim}
sudo umount /dev/sda3
\end{verbatim}
and make sure that the partition is not mounted automatically by editing:
\begin{verbatim}
/etc/fstab
\end{verbatim}
and commenting its line:
\begin{verbatim}
#UUID="f23efeab" /opt ext4 errors=remount-ro 0 1
\end{verbatim}
\section {DRBD Resource config}
\textbf{To be performed in both nodes}.
We will backup main DRBD configuration file:
\begin{verbatim}
cp /etc/drbd.conf /etc/drbd.conf.orig
\end{verbatim}
.
We then need to edit:
\begin{verbatim}
/etc/drbd.conf
\end{verbatim}
so that it has:
\begin{verbatim}
include "drbd.d/global_common.conf";
include "drbd.d/*.res";
resource zimbradata {
protocol C;
handlers {
pri-on-incon-degr "halt -f";
}
startup {
degr-wfc-timeout 120; # 2 min
}
disk {
on-io-error detach;
}
net {
}
syncer {
rate 10M;
al-extents 257;
}
on primary {
device /dev/drbd0;
disk /dev/sda3;
address 10.0.66.201:7788;
meta-disk /dev/sda2[0];
}
on secondary {
device /dev/drbd0;
disk /dev/sda3;
address 10.0.66.202:7788;
meta-disk /dev/sda2[0];
}
}
\end{verbatim}
Among other issues DRBD configuration settings establish a \textit{10 megabits synchronisation} rate using one of the DRBD available protocols (\textit{C}). It also defines that on the node named {\tt primary} we define a new DRBD \textit{device} named \textit{drbd0} which is going to track \textit{/dev/sda3} partition thanks to its meta-disk partition found in \textit{/dev/sda2}. The same setting is also specified for the node named {\tt secondary}. The only difference is IP \textit{address} where each one of the nodes have DRBD server listening to.
If we want to modify our drbd.conf to increase synchronisation rate, synchronised devices or any other settings we can check documentation at \cite{LinbitDRBDdrbdconf}.
\section {Start DRBD module}
\textbf{To be performed in both servers}.
\begin{verbatim}
modprobe drbd
\end{verbatim}
.
\section {Metadata disk initialisation}
\textbf{To be performed in both servers}.
We make sure the metadata partition does not have any prior metadata signature.
\begin{verbatim}
dd if=/dev/zero of=/dev/sda2 bs=1K count=100
\end{verbatim}
And we create the zimbradata metadata partition:
\begin{verbatim}
drbdadm create-md zimbradata
\end{verbatim}
.
The output for both servers will similar to:
\begin{verbatim}
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
\end{verbatim}
if sucedeed.
If it does not succeeded in less than two minutes you will need to cancel it thanks to {\tt CTRL+C} and run again the command while confirming that you want to overwrite already existing valid metadata.
\section {First DRBD synchronisation}
\textbf{To be performed in both servers}.
\begin{verbatim}
drbdadm up all
\end{verbatim}
If everything goes ok we should return to the prompt.
Were we will asked about usage, we just reply that we do not want to participate in the survey by saying 'no'.
\textbf{To be performed in Primary server only}.
\begin{verbatim}
drbdadm -- --overwrite-data-of-peer primary all
drbdadm -- connect all
\end{verbatim}
.
If we happen to find a \textit{net-config disconnect first} error we can safely ignore it.
We are goint to check DRBD first synchronisation status.
\begin{verbatim}
cat /proc/drbd
\end{verbatim}
which will output something like:
\begin{verbatim}
version: 0.7.20 (api:77/proto:74)
SVN Revision: 1743 build by <a href="mailto:phil@mescal">\
phil@mescal</a>, 2005-01-31 12:22:07
0: cs:SyncSource st:Primary/Secondary ld:Consistent
ns:13441632 nr:0 dw:0 dr:13467108 al:0 \
bm:2369 lo:0 pe:23 ua:226 ap:0
[==>..............] sync'ed: 3.1% (7000/7168)M
finish: 1:14:16 speed: 2,644 (2,204) K/sec
1: cs:Unconfigured
\end{verbatim}
.
We must wait for the first synchronisation to end so that we can safely complete the rest of the instructions.
Final end output will similar to:
\begin{verbatim}
version: 8.3.11 (api:88/proto:86-96)
srcversion: 93CE421BB73A731BDC72D8E
0: cs:Connected ro:Primary/Secondary
ds:UpToDate/UpToDate C r-----
ns:5691029 nr:0 dw:0 dr:6002290
al:0 bm:367 lo:0 pe:0 ua:0 ap:0
ep:1 wo:f oos:0
\end{verbatim}
where we can see that both primary and secondary are updated (\textit{UpToDate}).