On 4/23/2013 11:54 AM, David Teigland wrote:
I'm looking at the libvirt syntax is on this page under
"Device leases":
http://libvirt.org/formatdomain.html#elementsEvents
An example similar to what the sanlock man page has. I'll show all leases
at different offsets on a single 1GB lv (instead of using one lv per
lease, which is also possible). (Sorry, I haven't actually tried this
myself.)
shared storage for vms and leases: /dev/sdb1
shared vg for vms and leases: pool1
shared lv for all leases: /dev/pool1/leases
lockspace name: LS1
three vms: A, B, C
lease names: leaseA, leaseB, leaseC
vgcreate pool1 /dev/sdb1
lvcreate -n leases -L 1GB pool1
sanlock direct init -s LS1:0:/dev/pool1/leases:0
sanlock direct init -r LS1:leaseA:/dev/pool1/leases:1048576
sanlock direct init -r LS1:leaseB:/dev/pool1/leases:2097152
sanlock direct init -r LS1:leaseC:/dev/pool1/leases:3145728
The libvirt syntax for vm A:
<lease>
<lockspace>LS1</lockspace>
<key>leaseA</key>
<target path='/dev/pool1/leases' offset='1048576'/>
</lease>
The libvirt syntax for vm B:
<lease>
<lockspace>LS1</lockspace>
<key>leaseB</key>
<target path='/dev/pool1/leases' offset='2097152'/>
</lease>
Running this would be roughly:
all hosts: service wdmd start
all hosts: service sanlock start
all hosts: service libvirt start
host 1: sanlock add_lockspace -s LS1:1:/dev/pool1/leases:0
host 2: sanlock add_lockspace -s LS1:2:/dev/pool1/leases:0
(Note that each uses a different host_id there.)
Then, libvirt should acquire the leases when you run the vms.
Dave
Excellent, this was very helpful. Thank you!
So it looks like the only difference as far as keeping this automated on
startup of each host (after the initial configuration is completed of
course) is that each host needs to now run add_lockspace manually on
boot? Can this be safely automated through the daemon or an init script?