WikiStart

Version 4 (zitteret, 03/27/2006 04:37 pm)

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