WikiStart

Version 11 (lmuelle, 03/01/2008 10:12 pm)

1 11 lmuelle
_*This software is still beta - you use it at your own risk. Please create a ticket if you encounter bugs!*_
2 1
3 1
4 11 lmuelle
h1. DNBD
5 1
6 11 lmuelle
7 11 lmuelle
8 11 lmuelle
h2. Introduction
9 11 lmuelle
10 11 lmuelle
11 2 zitteret
DNBD (Distributed Network Block Device) is a read-only and caching network
12 2 zitteret
block device and supports following main features:
13 11 lmuelle
* replication of servers for robustness
14 11 lmuelle
* multicast communication and caching of network traffic for scalability
15 1
16 2 zitteret
These characteristics make it suitable especially for use in wireless networks,
17 2 zitteret
e.g. for diskless clients or to share multimedia files in such an environment.
18 2 zitteret
The servers can export a file or block device equipped with a operating system,
19 2 zitteret
movies, music, etc. Several clients can import the block device and access it
20 1
like a local hard disk. However, each block transfer over the network can be
21 2 zitteret
cached by all clients: If several users on each client start to watch a movie
22 2 zitteret
within a certain time interval, the movie data has to be transmitted only once
23 2 zitteret
(depending on the cache size). The network is not burdened with unnecessary
24 1
traffic. 
25 1
26 11 lmuelle
DNBD can be used together with "cowloop":http://www.atconsultancy.nl/cowloop/ or "unionfs":http://www.fsl.cs.sunysb.edu/project-unionfs.html in order to get local
27 1
write semantics, e.g. for diskless clients. Especially in wireless environments
28 7 zitteret
with limited bandwidth, caching can increase boot-up time enormously.
29 1
30 1
31 11 lmuelle
h2. Question, problems etc.
32 11 lmuelle
33 11 lmuelle
34 1
If you encounter any difficulties, please use search to find out if the problem is 
35 11 lmuelle
already known. Also, the [[FAQ|FAQ]] will contain typical problems.
36 1
37 1
38 11 lmuelle
h2. Download
39 11 lmuelle
40 11 lmuelle
41 1
The source code can be retrieved from the subversion repository.
42 11 lmuelle
<pre>
43 1
$ svn co http://svn.OpenSLX.org/svn/openslx/contrib/dnbd
44 11 lmuelle
</pre>
45 10 lmuelle
46 1
47 11 lmuelle
h2. Compilation
48 1
49 1
50 11 lmuelle
DNBD was developed for kernel 2.6.13 and later releases. For kernels later than 2.6.16 you will need to remove the "devfs" source from _kernel/main.c_ (simply search for "devfs" and remove all calls and includes). Kernel 2.4 is not supported. The kernel sources and common tools (gcc, make, etc.) have to be installed.
51 11 lmuelle
52 11 lmuelle
53 11 lmuelle
h3. Server and Client
54 11 lmuelle
55 11 lmuelle
56 2 zitteret
Compiling:
57 11 lmuelle
<pre>
58 2 zitteret
$ cd dnbd; make
59 11 lmuelle
</pre>
60 2 zitteret
61 1
62 11 lmuelle
h2. USAGE
63 1
64 11 lmuelle
65 11 lmuelle
66 11 lmuelle
h3. Server
67 11 lmuelle
68 11 lmuelle
69 2 zitteret
To show available command line parameters, start the server without
70 2 zitteret
arguments:
71 1
72 11 lmuelle
<pre>
73 2 zitteret
$ ./server/dnbd-server
74 2 zitteret
dnbd-server, version 0.9.0
75 2 zitteret
Usage: dnbd-server -m <address> -d <device/file> -i <number> 
76 2 zitteret
                  [-t <threads>]
77 2 zitteret
78 2 zitteret
description:
79 1
  -m|--mcast     <multicast address>
80 1
  -d|--device    <block device or file>
81 1
  -i|--id        <unique identification number>
82 1
  -t|--threads   <number of threads>
83 11 lmuelle
</pre>
84 2 zitteret
85 1
With the following command, the server will be started for the multicast
86 2 zitteret
network with address 239.0.0.1 and export the given file or block device.
87 2 zitteret
Its unique id is 1:
88 11 lmuelle
<pre>
89 2 zitteret
root@server1 $ ./server/dnbd-server -m 239.0.0.1 -d <partition/file> -i 1
90 11 lmuelle
</pre>
91 2 zitteret
To start a server on another computer, the used file or block device must have
92 2 zitteret
the same content and size as on the first server. However, the id has to be
93 2 zitteret
changed:
94 11 lmuelle
<pre>
95 2 zitteret
root@server2 $ ./server/dnbd-server -m 239.0.0.1 -d <partition/file> -i 2
96 11 lmuelle
</pre>
97 1
If DNBD is used for wired networks and on multi-processor machines, the
98 1
number of threads should be increased to the number of CPUs.
99 2 zitteret
100 2 zitteret
To access the exported file or block device, another computer is used as 
101 2 zitteret
client.
102 2 zitteret
103 2 zitteret
104 11 lmuelle
h3. Client
105 11 lmuelle
106 11 lmuelle
107 1
The kernel module has to be loaded, before the client application can be used:
108 11 lmuelle
<pre>
109 1
root@client1 $ insmod ./kernel/dnbd.ko
110 11 lmuelle
</pre>
111 1
There should be an entry in syslog after successful loading. With no command
112 1
line arguments the client gives available options:
113 11 lmuelle
<pre>
114 1
root@client1 $ ./client/dnbd-client
115 1
dnbd-client, version 0.9.0
116 1
Usage: dnbd-client -d device -b <address> [-c <file>]
117 1
    or dnbd-client -d device -u
118 1
    or dnbd-client -d device -c <file>
119 1
120 1
description:
121 1
  -d|--device    <device>
122 1
  -b|--bind      <multicast-address>
123 1
  -u|--unbind    
124 2 zitteret
  -c|--cache     <file>
125 11 lmuelle
</pre>
126 1
We will now import the block device of the server, e.g.:
127 11 lmuelle
<pre>
128 1
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -b 239.0.0.1
129 11 lmuelle
</pre>
130 1
The client should tell you that it found a server with id "1". If you exported
131 2 zitteret
a CDROM with a movie, you can watch it on the client over the network, e.g.
132 2 zitteret
with mplayer (usually after mounting).
133 2 zitteret
134 2 zitteret
If someone else wants to watch the movie on a different client, you should
135 1
enable caching either during operation
136 11 lmuelle
<pre>
137 1
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -c <cachefile>
138 11 lmuelle
</pre>
139 2 zitteret
or at the beginning
140 11 lmuelle
<pre>
141 2 zitteret
root@client2 $ ./client/dnbd-client -d /dev/dnbd0 -b 239.0.0.1 -c <cachefile>
142 11 lmuelle
</pre>
143 2 zitteret
To create a cache with, e.g. 32M use
144 11 lmuelle
<pre>
145 2 zitteret
root@client1$ dd if=/dev/zero of=/tmp/cachefile bs=1M count=32
146 11 lmuelle
</pre>
147 2 zitteret
Cache statistics are shown with
148 11 lmuelle
<pre>
149 2 zitteret
root@client1$ cat /proc/driver/dnbd/dnbd0
150 11 lmuelle
</pre>
151 2 zitteret
The block device has to be unbound before the module can be unloaded:
152 11 lmuelle
<pre>
153 2 zitteret
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -u
154 2 zitteret
root@client1 $ rmmod dnbd
155 11 lmuelle
</pre>
156 2 zitteret
157 11 lmuelle
h2. Files
158 11 lmuelle
159 11 lmuelle
160 11 lmuelle
161 11 lmuelle
h3. Client
162 11 lmuelle
163 11 lmuelle
<pre>
164 2 zitteret
./client
165 2 zitteret
   client.c		# client application
166 11 lmuelle
</pre>
167 11 lmuelle
168 11 lmuelle
h3. Server
169 11 lmuelle
170 11 lmuelle
<pre>
171 2 zitteret
./server
172 2 zitteret
   net.c		# network routines
173 2 zitteret
   query.c		# server request handling
174 2 zitteret
   filer.c		# file/device I/O
175 2 zitteret
   server.c		# server application (main file)
176 11 lmuelle
</pre>
177 11 lmuelle
178 11 lmuelle
h3. Kernel module
179 11 lmuelle
180 11 lmuelle
<pre>
181 2 zitteret
./kernel
182 2 zitteret
   net.c		# server management
183 2 zitteret
   queue.c		# queue handling for requests
184 2 zitteret
   cache.c		# cache implementation (red-black trees)
185 2 zitteret
   main.c		# module and block device (un)registration, threads
186 11 lmuelle
</pre>
187 6 zitteret
188 11 lmuelle
189 11 lmuelle
h2. License
190 11 lmuelle
191 6 zitteret
192 6 zitteret
DNBD is available through the GNU General Public License (GPL).
193 6 zitteret
194 6 zitteret
This distribution is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
195 6 zitteret
196 6 zitteret
The programs in this distribution are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
197 1
198 1
See the file COPYING that is also included with this distribution for more details.