1 #title Monikop and Pokinom
2 #subtitle rsync between unconnected hosts
6 Suppose we have an isolated network of data producing computers
7 (Sources), e.g. in a surveying vehicle (Rover). The collected data (a
8 few Terabytes per day) need to be transferred to a processing server
9 (Destination) in office.
11 This data transfer, which happens by means of removable disks, is
12 Monikop's and Pokinom's job.
14 On Rover, a couple of removable disks are put into a dedicated computer where they are
15 filled automatically by Monikop with data pulled from Sources.
17 The disks are then carried to the office where they are put into another
18 dedicated computer. Here, Monikop's counterpart called Pokinom pushes
19 their content to Destination and makes the disks re-usable by
22 The heavy lifting is done by [[http://www.samba.org/rsync/][Rsync]]. Sources as well as Destination
23 need to have Rsync installed. Both can be running Linux as
26 - Transfer rates ca. ...
31 We assume Debian GNU/Linux here, but any distribution should
32 work. Adapt installation instructions accordingly.
38 - to install from a git repository: git-core;
40 - to run Monikop (on Rover) or Pokinom (in office):
41 rsync, mingetty, sudo, libcurses-perl, libfile-rsync-perl;
43 - to run the tests: bc, time.
47 ** Prepare Removable Disks
51 Create Filesystems with labels for the removable disks. Example
52 (suppose a removable disk tagged =disk_10= is attached to =/dev/sdg1=):
54 =mke2fs -j -L disk_10 /dev/sdg1=
56 On both Monikop's and Pokinom's host, label the system root
57 partition. If it were on =/dev/sda1/, that's e.g.=:
59 =e2label /dev/sda1 root=
61 On both Monikop's and Pokinom's host, label the swap partition. If it
62 happens to be on /dev/sda5, e.g.:
66 =mkswap -L swap /dev/sda5=
72 On both Monikop's and Pokinom's host, create mount points, one for
75 =mkdir -p /media/disk_{01,02,03,04...}=
77 =chmod a+rx /media/disk_{01,02,03,04...}=
79 In =/etc/fstab= on both Monikop's and Pokinom's host, make use of the disk labels:
82 ## System partitions ###
83 LABEL=root / ext3 defaults,errors=remount-ro 0 1
84 LABEL=swap none swap sw 0 0
86 LABEL=disk_01 /media/disk_01 ext3 rw,user,auto 0 0
87 LABEL=disk_02 /media/disk_02 ext3 rw,user,auto 0 0
88 LABEL=disk_03 /media/disk_03 ext3 rw,user,auto 0 0
89 LABEL=disk_04 /media/disk_04 ext3 rw,user,auto 0 0
93 Put each removable disk in and make it writable; e.g.:
95 =mount /media/disk_01=
97 =chmod a+rwx /media/disk_01=
99 ** Maintain Bootability
101 On both Monikop's and Pokinoms host, make sure the system boots
102 actually from its system disk rather than from some of the removable
103 ones. Change =/boot/grub/menu.lst= where it says
105 <code># kopt=root=...</code>:
108 ### BEGIN AUTOMAGIC KERNELS LIST
109 ## lines between the AUTOMAGIC KERNELS LIST markers will be modified
110 ## by the debian update-grub script except for the default options below
112 ## DO NOT UNCOMMENT THEM, Just edit them to your needs
114 ## ## Start Default Options ##
115 ## default kernel options
116 ## default kernel options for automagic boot options
117 ## If you want special options for specific kernels use kopt_x_y_z
118 ## where x.y.z is kernel version. Minor versions can be omitted.
119 ## e.g. kopt=root=/dev/hda1 ro
120 ## kopt_2_6_8=root=/dev/hdc1 ro
121 ## kopt_2_6_8_2_686=root=/dev/hdc2 ro
122 # kopt=root=/dev/disk/by-label/root noresume ro
130 ** Install Monikop and Pokinom
132 Create a user on both Monikop's and Pokinom's machine. For
133 description's sake, we assume they're called m-operator.
135 Get Monikop (and Pokinom); from m-operator's home directory say:
137 =git-clone (FIXME: repo here)=
139 Copy =monikop.config.example= to =monikop.config= and
140 =pokinom.config.example= to =pokinom.config, respectively,= and
141 adapt them according to your needs. Both have helpful comments,
142 and both are perl code, so be careful and keep the interpunction
145 Things you want to change for Monikop in =monikop.config=:
148 # Possible data sources, and by what directory name to represent them in
150 # When the latter is not unique, care must be taken that all pathnames in the
151 # respective sources are unique.
153 'data_producer1::data' => 'p1',
154 'data_producer2::data' => 'p2',
155 'data_producer3::data' => '',
156 'data_producer4::data' => '',
159 # Possible mount points of data destinations.
160 @usable_mount_points = (
167 =%sources= are the data producing Sources in a format Rsync
168 understands, together with a source-specific directory name where data
169 of the respective Source goes. Those directory names can be equal for
170 several Sources if all filenames in the payload are certain to be
173 =@usable_mount_points= are the mount points (directories) you set up earlier for your
176 Accordingly, for Pokinom in =pokinom.config, you should edit=:
179 # Possible mount points.
180 @usable_mount_points = (
190 'big-server::incoming/NEW_DATA';
192 # Credentials of the remote rsync server. String, or 0 if not used.
202 *** Automatic Program Start
205 =/home/m-operator/.profile= (create it if necessary):
208 /home/m-operator/monikop/monikop
214 /home/m-operator/monikop/pokinom,
218 If necessary, specify path to config file, e.g.
220 /home/m-operator/monikop/monikop /home/m-operator/monikop/monikop.config
226 On both Monikop's and Pokinom's host authorize m-operator to shut down computer.
227 Use =visudo= to change =/etc/sudoers=; add:
230 m-operator ALL=(ALL) NOPASSWD: /sbin/halt -p
231 m-operator ALL=(ALL) NOPASSWD: /sbin/reboot
237 On both Monikop's and Pokinom's host, change the line in
238 =/etc/inittab= line which says
241 1:2345:respawn:/sbin/getty 38400 tty1
247 1:2345:respawn:/sbin/mingetty --autologin m-operator --noclear tty1
252 ** Configure Rsync on Sources
254 Install package rsync.
256 Example for =/etc/rsyncd.conf=:
259 pid file=/var/run/rsyncd.pid
263 lock file = /var/lock/rsyncd
266 transfer logging = false
269 In =/etc/default/rsync=, change the line
283 =/etc/initd/rsync start=
289 [[http://sourceforge.net/projects/sereds/files/cwRsync/4.0.3/cwRsyncServer_4.0.3_Installer.zip/download][cwRsync]]. Click
290 Start, Programs, cwRsyncServer, rsyncd.conf; edit:
298 # /cygdrive/e/log stands for E:\log
299 path = /cygdrive/e/log
301 transfer logging = false
304 Configure service rsync for automatic start.
309 Depending on the amount of data to transfer, consider putting a
310 dedicated NIC for each Source into Monikop's machine. In this case,
311 you should provide for non-overlapping subnets. [[http://jodies.de/ipcalc][IP-Calculator]] may be
317 **** Name the Sources
319 Example for =/etc/hosts=:
323 192.168.200.10 data-producer1
324 192.168.200.20 data-producer2
325 192.168.200.30 data-producer3
326 192.168.200.50 data-producer4
327 192.168.178.1 monikop
333 Example for =/etc/network/interfaces=:
335 # The loopback network interface
337 iface lo inet loopback
339 # Net of smaller Sources
341 iface eth1 inet static
342 address 192.168.178.1
343 netmask 255.255.255.0
345 # Dedicated NIC for data-producer1
347 iface eth2 inet static
348 address 192.168.200.9
349 netmask 255.255.255.248
351 # Dedicated NIC for data_producer2
353 iface eth3 inet static
354 address 192.168.200.19
355 netmask 255.255.255.248
357 # Dedicated NIC for data_producer3
359 iface eth4 inet static
360 address 192.168.200.29
361 netmask 255.255.255.248
363 # Dedicated NIC for data_producer4
365 iface eth5 inet static
366 address 192.168.200.49
367 netmask 255.255.255.248
373 Use =/etc/hosts= as with Monikop. For Windows, it's =%SystemRoot%\system32\drivers\etc\hosts=.
378 Example for =/etc/network/interfaces=:
382 iface lo inet loopback
384 # service (not relevant for Monikop)
386 iface eth0 inet static
387 address 192.168.178.2
388 netmask 255.255.255.0
390 # Monikop's dedicated NIC
392 iface eth1 inet static
393 address 192.168.200.10
394 netmask 255.255.255.248
397 For Windows, configure your network settings accordingly.
402 Pokinom's network settings don't need any special treatment. Just
403 integrate it into the office LAN Destination is connected to.
407 *** Rsync Server on Destination
409 Install package rsync.
411 Adapt =/etc/rsyncd.conf=, e.g.:
414 gid = data_receiving_group
417 pid file = /var/run/rsyncd.pid
422 comment = Pokinom only; requires authentication
424 incoming chmod = g+r,g+w
427 hosts allow = 192.168.180.120
428 auth users = m-operator
429 secrets file = /etc/rsyncd.secrets
432 =/etc/rsyncd.secrets= contains Rsync's credentials which must
433 correspond to settings =$rsync_passwd= and =$rsync_username= in =pokinom.config=:
439 In =/etc/default/rsync=, change the line
453 =/etc/initd/rsync start=
457 With the above, rsync puts the payload it receives into
458 =/mnt/raid_0/NEW_DATA/=. ("=NEW_DATA=" was set with
459 =$destination= in =pokinom.config=.)
461 =NEW_DATA/= and everything inside belongs to user
462 nobody and group data_receiving_group.
464 If on Destination you can't do without Windows, install
465 [[http://sourceforge.net/projects/sereds/files/cwRsync/4.0.3/cwRsyncServer_4.0.3_Installer.zip/download][cwRsync]],
466 configure its =rsyncd.conf= accordingly, and set service rsync to
473 - You have to be able to tell from your data if it's complete.
474 - Monikop shows which disks have data and therefore should be
475 transferred to Pokinom.
476 - Monikop keeps starting over until shutdown or until disappearance
478 - Pokinom needs sufficient amount of free space on sink; must be
479 rebooted once this is not the case.
480 - File permissions in Destination's receiving directory must not be
481 changed such that the rsync server is prevented from modifying.
482 Best practice is to move them out of this directory prior to any
484 - fsck-monikop: to be run by root
485 - Backup functionality: data remains on disks until re-inserted in
486 Monikop. Names in use.
490 - Data must not contain any directories called $rsync_partial_dir_name
491 - Doesn't reflect disappearance of files on sources
492 - May ignore empty dirs (really?)
496 Copyright 2010 Bert Burgemeister. All rights reserved.
498 Redistribution and use in source and binary forms, with or without
499 modification, are permitted provided that the following conditions are
502 1. Redistributions of source code must retain the above copyright
503 notice, this list of conditions and the following disclaimer.
505 2. Redistributions in binary form must reproduce the above
506 copyright notice, this list of conditions and the following
507 disclaimer in the documentation and/or other materials provided
508 with the distribution.
510 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTERS
511 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
512 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
513 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
514 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
515 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
516 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
517 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
518 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
519 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
520 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH