~ubuntu-branches/ubuntu/jaunty/ubuntu-docs/jaunty-proposed

« back to all changes in this revision

Viewing changes to serverguide/C/clustering.xml

  • Committer: Bazaar Package Importer
  • Author(s): Matthew East
  • Date: 2009-02-15 11:50:28 UTC
  • Revision ID: james.westby@ubuntu.com-20090215115028-exdnd0gtie61uvn2
Tags: 9.04.2
* Various serverguide fixes:
  - Grammar error (LP: #203829) - Dean Sas
  - Fix mailman dependencies (LP: #291772) - Morten Siebuhr
  - CVS installation error (LP: #298605) - Thomas M
  - Postfox installation error (LP: #306289) - Adam Sommer
  - SSH update (LP: #311900) - Dean Sas
  - unzoo replaced by zoo (LP: #312506)
  - Samba instructions update (LP: #313232) - Adam Sommer
  - Clearer SSL instructions (LP: #314951) - Adam Sommer
  - LDAP error (LP: #319179) - Adam Sommer
  - MoinMoin installation fix (LP: #320840) - Adam Sommer
  - Postfix ssl improvements (LP: #323203) - Adam Sommer
  - Ebox instructions error (LP: #324399) - Dean Sas
  - Typo in openssh section (LP: #325828) - Dean Sas
  - Typo in samba section (LP: #285484) - Nick Ellery
  - SSHD fix (LP: #295279) - Adam Sommer
  - Jeos fix (LP: #307582) - Adam Sommer
  - Remove reference to ebox-all package (LP: #322367) - Adam Sommer

* Typo in "switching from windows" (LP: #309735)
* Broken link in "programming" (LP: #310081) - Jonathan Jesse
* lsb_release issue in "basic commands" (LP: #310713) - Thomas M
* Updating logout instructions (LP: #327060) - Dean Sas
* Updating all documents to use apt-url for installation instructions
* Refreshing pot files for Rosetta
* Recompress *.png files with 'advpng -z -4 file.png' to save space -  Sahak Petrosyan
* Improve instructions on pasting commands (LP: #185892) - Martin Mai
* Rewrite of networking instructions (LP: #298513, LP: #321308, LP: #314680, LP: #321179) - Dougie Richardson
* Amend punctuation of about-ubuntu (LP: #275592) - Dougie Richardson
* Documentation for automatic login (LP: #290467) - Dougie Richardson

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
 
3
        "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
 
4
<!ENTITY % globalent SYSTEM "../../libs/global.ent">
 
5
%globalent;
 
6
<!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
 
7
%gnome-menus-C;
 
8
<!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
 
9
%xinclude;
 
10
<!ENTITY language "&EnglishAmerican;">
 
11
]>
 
12
<chapter id="clustering" status="review">
 
13
  <title>Clustering</title>
 
14
 
 
15
  <sect1 id="drbd" status="review">
 
16
    <title>DRBD</title>
 
17
 
 
18
    <para>
 
19
    Distributed Replicated Block Device (DRBD) mirrors block devices between multiple hosts.  The replication is 
 
20
    transparent to other applications on the host systems.  Any block device hard disks, partitions, RAID devices,
 
21
    logical volumes, etc can be mirrored.
 
22
    </para>
 
23
 
 
24
    <para>
 
25
    To get started using <application>drbd</application>, first install the necessary packages.  From a terminal enter:
 
26
    </para>
 
27
 
 
28
<screen>
 
29
<command>sudo apt-get install drbd8-utils</command>
 
30
</screen>
 
31
 
 
32
    <para>
 
33
    This section covers setting up a <application>drbd</application> to replicate a separate <filename>/srv</filename>
 
34
    partition, with an <application>ext3</application> filesystem between two hosts.  The partition size is not 
 
35
    particularly relevant, but both partitions need to be the same size.  
 
36
    </para>
 
37
 
 
38
    <sect2 id="drbd-configuration" status="review">
 
39
      <title>Configuration</title>
 
40
 
 
41
      <para>
 
42
      The two hosts in this example will be called <emphasis>drbd01</emphasis> and <emphasis>drbd02</emphasis>.
 
43
      They will need to have name resolution configured either through DNS or the <filename>/etc/hosts</filename> 
 
44
      file.  See <xref linkend="dns"/> for details.  
 
45
      </para>
 
46
 
 
47
      <itemizedlist>
 
48
        <listitem>
 
49
          <para>
 
50
          To configure <application>drbd</application>, on the first host edit <filename>/etc/drbd.conf</filename>:
 
51
          </para>
 
52
 
 
53
<programlisting>
 
54
global { usage-count no; }
 
55
common { syncer { rate 100M; } }
 
56
resource r0 {
 
57
        protocol C;
 
58
        startup {
 
59
                wfc-timeout  15;
 
60
                degr-wfc-timeout 60;
 
61
        }
 
62
        net {
 
63
                cram-hmac-alg sha1;
 
64
                shared-secret "secret";
 
65
                allow-two-primaries;
 
66
        }
 
67
        on drbd01 {
 
68
                device /dev/drbd0;
 
69
                disk /dev/sdb1;
 
70
                address 192.168.0.1:7788;
 
71
                meta-disk internal;
 
72
        }
 
73
        on drbd02 {
 
74
                device /dev/drbd0;
 
75
                disk /dev/sdb1;
 
76
                address 192.168.0.2:7788;
 
77
                meta-disk internal;
 
78
        }
 
79
 
80
</programlisting>
 
81
 
 
82
          <note>
 
83
            <para>
 
84
            There are many other options in <filename>/etc/drbd.conf</filename>, but for this example their default
 
85
            values are fine.
 
86
            </para>
 
87
          </note>
 
88
        </listitem>
 
89
        <listitem>
 
90
   
 
91
          <para>
 
92
          Now copy <filename>/etc/drbd.conf</filename> to the second host:
 
93
          </para> 
 
94
 
 
95
<screen>
 
96
<command>scp /etc/drbd.conf drbd02:~</command>
 
97
</screen>
 
98
 
 
99
        </listitem>
 
100
        <listitem>
 
101
 
 
102
          <para>
 
103
          And, on <emphasis>drbd02</emphasis> move the file to <filename>/etc</filename>:
 
104
          </para> 
 
105
 
 
106
<screen>
 
107
<command>sudo mv drbd.conf /etc/</command>
 
108
</screen>
 
109
 
 
110
        </listitem>
 
111
        <listitem>
 
112
 
 
113
          <para>
 
114
          Next, on both hosts, start the <application>drbd</application> daemon:
 
115
          </para> 
 
116
 
 
117
<screen>
 
118
<command>sudo /etc/init.d/drbd start</command>
 
119
</screen>
 
120
 
 
121
        </listitem>
 
122
        <listitem>
 
123
 
 
124
          <para>
 
125
          Now using the <application>drbdadm</application> utility initialize the meta data storage.  On each server
 
126
          execute:
 
127
          </para> 
 
128
 
 
129
<screen>
 
130
<command>sudo drbdadm create-md r0</command>
 
131
</screen>
 
132
 
 
133
        </listitem>
 
134
        <listitem>
 
135
 
 
136
          <para>
 
137
          On the <emphasis>drbd01</emphasis>, or whichever host you wish to be the primary, enter the following:
 
138
          </para> 
 
139
 
 
140
<screen>
 
141
<command>sudo drbdadm -- --overwrite-data-of-peer primary all</command>
 
142
</screen>
 
143
 
 
144
        </listitem>
 
145
        <listitem>
 
146
 
 
147
          <para>
 
148
          After executing the above command, the data will start syncing with the secondary host.  To watch the progresss, on
 
149
          <emphasis>drbd02</emphasis> enter the following:
 
150
          </para> 
 
151
 
 
152
<screen>
 
153
<command>watch -n1 cat /proc/drbd</command>
 
154
</screen>
 
155
 
 
156
          <para>
 
157
          To stop watching the output press <emphasis>Ctrl+c</emphasis>.
 
158
          </para>
 
159
 
 
160
        </listitem>
 
161
        <listitem>
 
162
 
 
163
      <para>
 
164
      Finally, add a filesystem to <filename>/dev/drbd0</filename> and mount it:
 
165
      </para> 
 
166
 
 
167
<screen>
 
168
<command>sudo mkfs.ext3 /dev/drbd0</command>
 
169
<command>sudo mount /dev/drbd0 /srv</command>
 
170
</screen>
 
171
 
 
172
        </listitem>
 
173
      </itemizedlist>
 
174
 
 
175
    </sect2>
 
176
    <sect2 id="drbd-testing" status="review">
 
177
      <title>Testing</title>
 
178
 
 
179
      <para>
 
180
      To test that the data is actually syncing between the hosts copy some files on the <emphasis>drbd01</emphasis>, the 
 
181
      primary, to <filename>/srv</filename>:
 
182
      </para>
 
183
 
 
184
<screen>
 
185
<command>sudo cp -r /etc/default /srv</command>
 
186
</screen>
 
187
 
 
188
      <para>
 
189
      Next, unmount <filename>/srv</filename>:
 
190
      </para>
 
191
 
 
192
<screen>
 
193
<command>sudo umount /srv</command>
 
194
</screen>
 
195
 
 
196
      <para>
 
197
      <emphasis>Demote</emphasis> the <emphasis>primary</emphasis> server to the <emphasis>secondary</emphasis> role:
 
198
      </para>
 
199
 
 
200
<screen>
 
201
<command>sudo drbdadm secondary r0</command>
 
202
</screen>
 
203
 
 
204
      <para>
 
205
      Now on the the <emphasis>secondary</emphasis> server <emphasis>promote</emphasis> it to the <emphasis>primary</emphasis> role:
 
206
      </para>
 
207
 
 
208
<screen>
 
209
<command>sudo drbdadm primary r0</command>
 
210
</screen>
 
211
 
 
212
      <para>
 
213
      Lastly, mount the partition:
 
214
      </para>
 
215
 
 
216
<screen>
 
217
<command>sudo mount /dev/drbd0 /srv</command>
 
218
</screen>
 
219
 
 
220
      <para>
 
221
      Using <emphasis>ls</emphasis> you should see <filename>/srv/default</filename> copied from the former <emphasis>primary</emphasis>         
 
222
      host <emphasis>drbd01</emphasis>.
 
223
      </para>
 
224
 
 
225
    </sect2>
 
226
    <sect2 id="drbd-references" status="review">
 
227
      <title>References</title>
 
228
     
 
229
      <itemizedlist>
 
230
        <listitem>
 
231
          <para>
 
232
          For more information on <application>DRBD</application> see the <ulink url="http://www.drbd.org/">DRBD web site</ulink>.
 
233
          </para>
 
234
        </listitem>
 
235
        <listitem>
 
236
          <para>
 
237
          The <ulink url="http://manpages.ubuntu.com/manpages/jaunty/en/man5/drbd.conf.5.html">drbd.conf man page</ulink> contains
 
238
          details on the options not covered in this guide.
 
239
          </para>
 
240
        </listitem>
 
241
        <listitem>
 
242
          <para>
 
243
          Also, see the <ulink url="http://manpages.ubuntu.com/manpages/jaunty/en/man8/drbdadm.8.html">drbdadm man page</ulink>.
 
244
          </para>
 
245
        </listitem>
 
246
      </itemizedlist>
 
247
 
 
248
    </sect2>
 
249
  </sect1>
 
250
</chapter>