Skip to content

Instantly share code, notes, and snippets.

@valentin2105
Last active July 6, 2018 10:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valentin2105/1cab6083dc575280f72cf89a62066c5f to your computer and use it in GitHub Desktop.
Save valentin2105/1cab6083dc575280f72cf89a62066c5f to your computer and use it in GitHub Desktop.
Manage a Ganeti Cluster
Add a VM in plain disk:
gnt-instance add plain --disk 0:size=20G --disk 1:size=200M \
-B memory=2G,vcpus=2 -o debootstrap+jessie --no-ip-check \ 
--no-name-check vm.domain.com
Add a VM in DRBD (fully-sharred between two servers) :
gnt-instance add drbd --disk 0:size=20G --disk 1:size=200M \
-B memory=2G,vcpus=2 -o debootstrap+jessie --no-ip-check \
--no-name-check -n server1.server2 vm.domain.com
Delete a VM :

gnt-instance remove vm.domain.com

Enable own-kernel for VM :
gnt-instance modify --hypervisor-parameters=kernel_path=\
/usr/lib/grub-xen/grub-x86_64-xen.bin vm.domain.com
Change VM Parameters
gnt-instance modify --backend-parameters=vcpus=4 vm.domain.com
gnt-instance modify -B memory=4096M vm.domain.com
Extend a VM's disk
gnt-instance grow-disk <vm> <disk-number> <size-to-grow>
gnt-instance reboot <vm>
# Run this on the VM :
fdisk /dev/xvda (in my case)
p # List and note starting partition number
d # Delete the partition
n # New partition with same number and starting number
w # Write
reboot
pvresize /dev/xvda1
lvextend -L+<size-in-giga> /dev/vg<vm>/<lv-to-extend>
resize2fs /dev/vg<vm>/<lv-to-extend>
Migrate a Drbd VM without shutdown :

gnt-instance migrate vm.domain.com

Add a node to the Cluster

gnt-node add server2

Migrate all VM from a node (DRBD)

gnt-node failover server2

Migrate the secondary disk to another node (DRBD)

gnt-instance replace-disks -n server3 vm.domain.com

Mark a node offline

gnt-node modify -C no -O yes server2

Check Cluster's health

gnt-cluster verify gnt-cluster verify-disks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment