19 March 2013

Can't remove open logical volume "lv_name"

This was an interesting thing to find...
# lvremove /dev/vg00/lv_name
Can't remove open logical volume "lv_name"
So I checked if my LV is mounted... and it was.
# mount
...
/dev/mapper/vg00-lv_name on /mount_point type ext4 (rw,noatime,errors=remount-ro)
...
Standard unmounting didn't help...
# umount /tmp/OUHObyUhPi
umount: /tmp/OUHObyUhPi: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Of course there was nothing in lsof:
# lsof | grep /tmp/OUHObyUhPi
#
dmsetup was showing my lv_name as open:
# dmsetup info -c /dev/mapper/vg00-lv_name
Name Maj Min Stat Open Targ Event UUID
vg00-lv_name 254 0 L--w 1 1 0 LVM-CqfjODkizlaDYpfk1631CZ06tTL2D2wp6kGNTj1EeCR8SPnIeE0NhSbdKZTYO4Jc
But it wasn't able to turn it off:
# dmsetup remove /dev/mapper/vg00-lv_name
device-mapper: remove ioctl failed: Device or resource busy
What worked for me, was lazy unmount:
# umount -l /tmp/OUHObyUhPi/
Then I could remove the LV:
# lvremove /dev/vg00/lv_name-disk
Do you really want to remove active logical volume lv_name? [y/n]: y
Logical volume "lv_name" successfully removed

04 March 2013

mongodb & PHP: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found'

While playing with mongodb, i got the following error in PHP:
2013/03/04 16:47:27 [error] 1399#0: *376172 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found' in /not/relevant/mongoDB.php:28
Stack trace:
#0 /not/relevant/mongoDB.php(28): Mongo->__construct('mongodb://10.0....', Array)
#1 /not/relevant.php(46): Mongo_DB->connect(Array)
#2 /not/relevant/index.php(63): API->__construct('json/notificati...')
#3 {main}
thrown in /not/relevant/mongoDB.php on line 28" while reading response header from upstream, client: 127.0.0.1, server: not_relevant.com, request: "POST /json/ HTTP/1.0", upstream: "fastcgi://unix:///tmp/php.sock:", host: "127.0.0.1:8081", referrer: "http://not_relevant.com"

To fix it, check the following:
1. You don't use localhost/127.0.0.1 as a node in your cluster
2. You have the right IPs in the connect to replica field. Check this again.
3. You are using the MongoClient::RP_SECONDARY_PREFERRED and not the MongoClient::RP_SECONDARY
4. Check google, I'm out of ideas. The above helped me.

03 March 2013

Debian BUG XEN: NameError: name 'output_directory' is not defined

On a new Debian Squeeze installation I got the following errors when starting a VM:
Using to parse /boot/grub/menu.lst
Traceback (most recent call last):
File "/usr/lib/xen-default/bin/pygrub", line 705, in
output_directory, not_really)
NameError: name 'output_directory' is not defined

[2013-03-03 05:52:58 1270] DEBUG (XendDomainInfo:101) XendDomainInfo.create(['vm', ['name', 'not_relevant'], ['memory', '1024'], ['on_poweroff', 'destroy'], ['on_reboot', 'restart'], ['on_crash', 'restart'], ['on_xend_start', 'ignore'], ['on_xend_stop', 'ignore'], ['vcpus', '2'], ['oos', 1], ['bootloader', '/usr/lib/xen-default/bin/pygrub'], ['bootloader_args', '-q'], ['image', ['linux', ['root', '/dev/xvda1 ro'], ['videoram', 4], ['tsc_mode', 0], ['nomigrate', 0]]], ['s3_integrity', 1], ['device', ['vbd', ['uname', 'phy:/dev/vg00/not_relevant-disk'], ['dev', 'xvda1'], ['mode', 'w']]], ['device', ['vif', ['ip', '1.2.3.4'], ['mac', '00:16:3E:F6:31:8C'], ['bridge', 'br0']]]])
[2013-03-03 05:52:58 1270] DEBUG (XendDomainInfo:2508) XendDomainInfo.constructDomain
[2013-03-03 05:52:58 1270] DEBUG (balloon:220) Balloon: 32145744 KiB free; need 16384; done.
[2013-03-03 05:52:58 1270] DEBUG (XendDomain:464) Adding Domain: 15
[2013-03-03 05:52:58 1270] DEBUG (XendDomainInfo:2818) XendDomainInfo.initDomain: 15 256
[2013-03-03 05:52:58 18007] DEBUG (XendBootloader:113) Launching bootloader as ['/usr/lib/xen-default/bin/pygrub', '--args=root=/dev/xvda1 ro ', '--output=/var/run/xend/boot/xenbl.29813', '-q', '/dev/vg00/not_relevant-disk'].
[2013-03-03 05:52:58 1270] ERROR (XendBootloader:214) Boot loader didn't return any data!
[2013-03-03 05:52:58 1270] ERROR (XendDomainInfo:483) VM start failed
Traceback (most recent call last):
File "/usr/lib/xen-4.0/lib/python/xen/xend/XendDomainInfo.py", line 469, in start
XendTask.log_progress(31, 60, self._initDomain)
File "/usr/lib/xen-4.0/lib/python/xen/xend/XendTask.py", line 209, in log_progress
retval = func(*args, **kwds)
File "/usr/lib/xen-4.0/lib/python/xen/xend/XendDomainInfo.py", line 2820, in _initDomain
self._configureBootloader()
File "/usr/lib/xen-4.0/lib/python/xen/xend/XendDomainInfo.py", line 3266, in _configureBootloader
bootloader_args, kernel, ramdisk, args)
File "/usr/lib/xen-4.0/lib/python/xen/xend/XendBootloader.py", line 215, in bootloader
raise VmError, msg
VmError: Boot loader didn't return any data!


It seems this is a BUG and it took me only couple of hours to find it. For some reasons google didn't show it when searching for "NameError: name 'output_directory' is not defined".

The fix in my case is to add the following to the /usr/lib/xen-default/bin/pygrub:
not_really = False
output_directory = "/var/run/xend/boot"