WikiStart

Version 2 (zitteret, 03/02/2006 02:02 pm)

1 2 zitteret
= DNBD =
2 1
3 2 zitteret
== Introduction ==
4 1
5 2 zitteret
DNBD (Distributed Network Block Device) is a read-only and caching network
6 2 zitteret
block device and supports following main features:
7 2 zitteret
 * replication of servers for robustness
8 2 zitteret
 * multicast communication and caching of network traffic for scalability
9 1
10 2 zitteret
These characteristics make it suitable especially for use in wireless networks,
11 2 zitteret
e.g. for diskless clients or to share multimedia files in such an environment.
12 2 zitteret
The servers can export a file or block device equipped with a operating system,
13 2 zitteret
movies, music, etc. Several clients can import the block device and access it
14 2 zitteret
like a local hard disk. However, each block transfer over the network can be
15 2 zitteret
cached by all clients: If several users on each client start to watch a movie
16 2 zitteret
within a certain time interval, the movie data has to be transmitted only once
17 2 zitteret
(depending on the cache size). The network is not burdened with unnecessary
18 2 zitteret
traffic. 
19 1
20 2 zitteret
DNBD can be used together with [http://www.atconsultancy.nl/cowloop/ cowloop] or [http://www.fsl.cs.sunysb.edu/project-unionfs.html unionfs] in order to get local
21 2 zitteret
write semantics, e.g. for diskless clients. Especially in wireless environments
22 2 zitteret
with limited bandwidth, caching can increase boot-up time enormously.
23 1
24 2 zitteret
== Download ==
25 1
26 2 zitteret
The source code can be retrieved from the subversion repository.
27 2 zitteret
{{{
28 2 zitteret
$ svn co http://lp-srv02a.ruf.uni-freiburg.de/svn/dnbd
29 2 zitteret
}}}
30 1
31 2 zitteret
== Compilation ==
32 1
33 2 zitteret
DNBD was developed for kernel 2.6.13 and later releases. Kernel 2.4 is not
34 2 zitteret
supported. The kernel sources and common tools (gcc, make, etc.) have to be
35 2 zitteret
installed.
36 1
37 2 zitteret
=== Server and Client ===
38 1
39 2 zitteret
Unpacking:
40 2 zitteret
{{{
41 2 zitteret
$ tar xzvf dnbd.tar.gz
42 2 zitteret
}}}
43 2 zitteret
   
44 2 zitteret
Compiling:
45 2 zitteret
{{{
46 2 zitteret
$ cd dnbd; make
47 2 zitteret
}}}
48 1
49 2 zitteret
== USAGE ==
50 1
51 2 zitteret
=== Server ===
52 2 zitteret
53 2 zitteret
To show available command line parameters, start the server without
54 2 zitteret
arguments:
55 2 zitteret
56 2 zitteret
{{{
57 2 zitteret
$ ./server/dnbd-server
58 2 zitteret
dnbd-server, version 0.9.0
59 2 zitteret
Usage: dnbd-server -m <address> -d <device/file> -i <number> 
60 2 zitteret
                  [-t <threads>]
61 2 zitteret
62 2 zitteret
description:
63 2 zitteret
  -m|--mcast     <multicast address>
64 2 zitteret
  -d|--device    <block device or file>
65 2 zitteret
  -i|--id        <unique identification number>
66 2 zitteret
  -t|--threads   <number of threads>
67 2 zitteret
}}}
68 2 zitteret
69 2 zitteret
With the following command, the server will be started for the multicast
70 2 zitteret
network with address 239.0.0.1 and export the given file or block device.
71 2 zitteret
Its unique id is 1:
72 2 zitteret
{{{
73 2 zitteret
root@server1 $ ./server/dnbd-server -m 239.0.0.1 -d <partition/file> -i 1
74 2 zitteret
}}}
75 2 zitteret
To start a server on another computer, the used file or block device must have
76 2 zitteret
the same content and size as on the first server. However, the id has to be
77 2 zitteret
changed:
78 2 zitteret
{{{
79 2 zitteret
root@server2 $ ./server/dnbd-server -m 239.0.0.1 -d <partition/file> -i 2
80 2 zitteret
}}}
81 2 zitteret
If DNBD is used for wired networks and on multi-processor machines, the
82 2 zitteret
number of threads should be increased to the number of CPUs.
83 2 zitteret
84 2 zitteret
To access the exported file or block device, another computer is used as 
85 2 zitteret
client.
86 2 zitteret
87 2 zitteret
=== Client ===
88 2 zitteret
89 2 zitteret
The kernel module has to be loaded, before the client application can be used:
90 2 zitteret
{{{
91 2 zitteret
root@client1 $ insmod ./kernel/dnbd.ko
92 2 zitteret
}}}
93 2 zitteret
There should be an entry in syslog after successful loading. With no command
94 2 zitteret
line arguments the client gives available options:
95 2 zitteret
{{{
96 2 zitteret
root@client1 $ ./client/dnbd-client
97 2 zitteret
dnbd-client, version 0.9.0
98 2 zitteret
Usage: dnbd-client -d device -b <address> [-c <file>]
99 2 zitteret
    or dnbd-client -d device -u
100 2 zitteret
    or dnbd-client -d device -c <file>
101 2 zitteret
102 2 zitteret
description:
103 2 zitteret
  -d|--device    <device>
104 2 zitteret
  -b|--bind      <multicast-address>
105 2 zitteret
  -u|--unbind    
106 2 zitteret
  -c|--cache     <file>
107 2 zitteret
}}}
108 2 zitteret
We will now import the block device of the server, e.g.:
109 2 zitteret
{{{
110 2 zitteret
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -b 239.0.0.1
111 2 zitteret
}}}
112 2 zitteret
The client should tell you that it found a server with id "1". If you exported
113 2 zitteret
a CDROM with a movie, you can watch it on the client over the network, e.g.
114 2 zitteret
with mplayer (usually after mounting).
115 2 zitteret
116 2 zitteret
If someone else wants to watch the movie on a different client, you should
117 2 zitteret
enable caching either during operation
118 2 zitteret
{{{
119 2 zitteret
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -c <cachefile>
120 2 zitteret
}}}
121 2 zitteret
or at the beginning
122 2 zitteret
{{{
123 2 zitteret
root@client2 $ ./client/dnbd-client -d /dev/dnbd0 -b 239.0.0.1 -c <cachefile>
124 2 zitteret
}}}
125 2 zitteret
To create a cache with, e.g. 32M use
126 2 zitteret
{{{
127 2 zitteret
root@client1$ dd if=/dev/zero of=/tmp/cachefile bs=1M count=32
128 2 zitteret
}}}
129 2 zitteret
Cache statistics are shown with
130 2 zitteret
{{{
131 2 zitteret
root@client1$ cat /proc/driver/dnbd/dnbd0
132 2 zitteret
}}}
133 2 zitteret
The block device has to be unbound before the module can be unloaded:
134 2 zitteret
{{{
135 2 zitteret
root@client1 $ ./client/dnbd-client -d /dev/dnbd0 -u
136 2 zitteret
root@client1 $ rmmod dnbd
137 2 zitteret
}}}
138 2 zitteret
== Files ==
139 2 zitteret
140 2 zitteret
=== Client ===
141 2 zitteret
{{{
142 2 zitteret
./client
143 2 zitteret
   client.c		# client application
144 2 zitteret
}}}
145 2 zitteret
=== Server ===
146 2 zitteret
{{{
147 2 zitteret
./server
148 2 zitteret
   net.c		# network routines
149 2 zitteret
   query.c		# server request handling
150 2 zitteret
   filer.c		# file/device I/O
151 2 zitteret
   server.c		# server application (main file)
152 2 zitteret
}}}
153 2 zitteret
=== Kernel module ===
154 2 zitteret
{{{
155 2 zitteret
./kernel
156 2 zitteret
   net.c		# server management
157 2 zitteret
   queue.c		# queue handling for requests
158 2 zitteret
   cache.c		# cache implementation (red-black trees)
159 2 zitteret
   main.c		# module and block device (un)registration, threads
160 2 zitteret
}}}