mpalmer / lvmsync

Synchronise LVM LVs across a network by sending only snapshotted changes
http://theshed.hezmatt.org/lvmsync
GNU General Public License v3.0
383 stars 61 forks source link

Changes aren't being applied w/3.1.0 #34

Closed WMP closed 10 years ago

WMP commented 10 years ago

Hello, on version 3.1.0 finally lvmsync can send chunks to other server :D, but new files isn't on backup server. In addition, can not save snapback files:

root@backup ~ # md5sum /dev/vg0/test                                                                                                                                       
6dbbfec867e4229edebf6ce79910556c  /dev/vg0/test
root@backup ~ #
root@gaja ~/lvmsync # cat lvmsync_diff.sh 
#!/bin/bash
lvcreate --snapshot -L 100M -n test-snapshot virtual/test

echo "creating file normal_test.$(date +%Y%m%d-%H%M)"
mount /dev/virtual/test /mnt/test
echo 'testujemy snapshoty' >> /mnt/test/normal_test.$(date +%Y%m%d-%H%M)
umount /mnt/test

echo "creating file snapshot_test.$(date +%Y%m%d-%H%M)"
mount /dev/virtual/test-snapshot /mnt/test
echo 'testujemy snapshoty' >> /mnt/test/snapshot_test.$(date +%Y%m%d-%H%M)
umount /mnt/test
echo 'lvmsync...'

lvmsync -v --snapback /tmp/snapback.$(date +%Y%m%d-%H%M) /dev/virtual/test-snapshot backup.monogo.pl:/dev/vg0/test
echo 'lvmsync done'
echo 'cleanup'
lvremove -f /dev/virtual/test-snapshot
root@gaja ~/lvmsync # ./lvmsync_diff.sh 
   Logical volume "test-snapshot" created
creating file normal_test.20141009-1112
creating file snapshot_test.20141009-1112
lvmsync...
Origin device: virtual/test
Sending chunk 0..4095...
Seeking to 0 in /dev/mapper/virtual-test
Sending chunk 8667136..8671231...
Seeking to 8667136 in /dev/mapper/virtual-test
Sending chunk 92274688..92278783...
Seeking to 92274688 in /dev/mapper/virtual-test
Sending chunk 92278784..92282879...
Seeking to 92278784 in /dev/mapper/virtual-test
Sending chunk 299008..303103...
Seeking to 299008 in /dev/mapper/virtual-test
Sending chunk 92282880..92286975...
Seeking to 92282880 in /dev/mapper/virtual-test
Sending chunk 266240..270335...
Seeking to 266240 in /dev/mapper/virtual-test
Sending chunk 278528..282623...
Seeking to 278528 in /dev/mapper/virtual-test
Sending chunk 294912..299007...
Seeking to 294912 in /dev/mapper/virtual-test
Sending chunk 4489216..4493311...
Seeking to 4489216 in /dev/mapper/virtual-test
Transferred 40960 bytes in 2.48 seconds
You transferred your changes 5120.00x faster than a full dd!
lvmsync done
cleanup
  Logical volume "test-snapshot" successfully removed
root@gaja ~/lvmsync # 
md5sum /dev/vg0/test
6dbbfec867e4229edebf6ce79910556c  /dev/vg0/test
root@backup ~ # mount /dev/vg0/test /mnt/
root@backup ~ # ls /mnt
lost+found
root@backup ~ # umount /mnt
root@backup ~ # ls /tmp
root@backup ~ #
mpalmer commented 10 years ago

I've written a new test case that specifically exercises --snapback, and that appears to work OK, so I don't think anything's fundamentally broken with snapback. I've also tried to reproduce the problem you're having using your script, and I'm afraid I'm not having any luck.

As part of my attempts, I've significantly improved the way that problems in the receiving lvmsync are reported -- now it should be much more obvious when things go wrong on the remote end -- which is the most likely cause of the problem you're seeing. These changes are available in the freshly-released 3.1.1 version. Also as part of that version I cleaned up a couple of corner cases in the receiver, so it's possible that things might "just work" for you now. If they don't, though, at least there should be some more useful information about what went wrong.

WMP commented 10 years ago

Ok, on source server i have ruby 2.1.1 from rvm, and on backup i have 2.0.0. This is output:

root@gaja ~/lvmsync # ./lvmsync_diff.sh 
  Logical volume "test-snapshot" created
creating file normal_test.20141011-2214
creating file snapshot_test.20141011-2214
lvmsync...
Origin device: /dev/mapper/virtual-test
Sending chunk 0..4095...
Seeking to 0 in /dev/mapper/virtual-test
Remote prematurely closed the connection
/usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:210:in `readline': end of file reached (EOFError)
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:210:in `block (3 levels) in run_client'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:208:in `each'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:208:in `block (2 levels) in run_client'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:254:in `rescue in block (2 levels) in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:249:in `block (2 levels) in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:239:in `each'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:239:in `block in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:238:in `open'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:238:in `dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:204:in `block in run_client'
        from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/open3.rb:199:in `popen_run'
        from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/open3.rb:93:in `popen3'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:203:in `run_client'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:106:in `main'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.1/bin/lvmsync:296:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/lvmsync:23:in `load'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/lvmsync:23:in `<main>'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
lvmsync done
cleanup
  Logical volume "test-snapshot" successfully removed
mpalmer commented 10 years ago

So it looks like there's definitely a problem with the receiving lvmsync crashing out early ("Remote prematurely closed the connection"), but obviously the code to read from the pipe and display the remote's output isn't robust enough. Try again with the newly released 3.1.3, and we'll see if something more useful appears.

WMP commented 10 years ago
root@gaja ~/lvmsync # ./lvmsync_diff.sh 
  Logical volume "test-snapshot" already exists in volume group "virtual"
creating file normal_test.20141012-0936
creating file snapshot_test.20141012-0936
lvmsync...
Origin device: /dev/mapper/virtual-test
Sending chunk 0..4095...
Seeking to 0 in /dev/mapper/virtual-test
Remote prematurely closed the connection
remote:ERROR: No snapshot specified.  Exiting.
^C/usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:208:in `select': Interrupt
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:208:in `block (2 levels) in run_client'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:258:in `rescue in block (2 levels) in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:253:in `block (2 levels) in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:243:in `each'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:243:in `block in dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:242:in `open'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:242:in `dump_changes'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:204:in `block in run_client'
        from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/open3.rb:199:in `popen_run'
        from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/open3.rb:93:in `popen3'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:203:in `run_client'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:106:in `main'
        from /usr/local/rvm/gems/ruby-2.1.1/gems/lvmsync-3.1.3/bin/lvmsync:300:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/lvmsync:23:in `load'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/lvmsync:23:in `<main>'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'

root@gaja ~/lvmsync #

In backup server i have file /usr/local/bin/lvmsync:

#!/usr/bin/env bash

# load rvm ruby
source /usr/local/rvm/environments/ruby-2.0.0-p576

ruby /usr/local/rvm/gems/ruby-2.0.0-p576/bin/lvmsync
WMP commented 10 years ago

Sorry, i add to my lvmsync $@ and works good! All works :D