PAD 12 Best practices in virtualized environments Power
PAD 12 Best practices in virtualized environments (Power. KVM) q Picture Breno Leitao Advisory Software Engineer brenohl@br. ibm. com © 2014 IBM Corporation
Introduction Learn best practices on Kernel-based Virtual Machine. Agenda: Command line management Storage Network CPU Snapshots General tips © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Terminology © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
General Understanding IBM Power. KVM is the KVM ported to IBM POWER processors. Plus some ad-dons: Virtualized device drivers Micro threading Extra RAS tools © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 4
General Understanding IBM Power. KVM management screen (GUI) © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 5
Command line Using command line provides you more control over you environment. Images and other files are at /var/libvirt Network Storage Every configuration is an XML file # virsh edit/dump-xml © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 6
Command line: How to handle the VM more properly Examples: • Create amount of disk – # qemu-img create -f qcow 2 /var/libvirt/images/ubuntu. qcow 2 50 G – # virsh vol-create-as disks ubuntu 50 G --format qcow 2 • Virt-install: – # virt-install --name=ubuntu 1410 --cdrom=/root/utopic-serverppc 64 el. iso --memory=4096 --disk 10 G --network=default • Keep the machine up after a reboot – #virsh autostart <VM name> • Edit VM configuration: – # virsh edit <VM name> • Log into the console: – # virsh console <VM name> © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 7
Storage (Disk) Use Logical disk for performance. Use File system images for storage virtualization. VM File system VM Image Hypervisor File system Hypervisor Disk Many other types of pool: NFS SCSI ISCSI ZFS VM Disk Hypervisor Disk © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 8
Storage (Images) Qcow 2 – Copy on Write file format. – Supports backing file: • Have a base file and all changes on the base files are written in a different file. – Usually small than raw format – Create snapshot Raw – File system as a file – Can be mounted as a file system – The image file will be as big as the VM file system You can convert from one type to another using qemu-image too. $ virsh vol-create-as disks qcow_image 10 G --format qcow 2 Vol qcow_image created $ virsh vol-create-as disks raw 10 G --format raw Vol raw created $ ls /tmp/pool/qcow_image -lah -rw------- 1 brenohl 193 K Oct 28 11: 13 /tmp/pool/qcow_image $ ls /tmp/pool/raw -lah -rw------- 1 brenohl 10 G Oct 28 11: 15 /tmp/pool/raw QCOW 2 © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil RAW
Network Storage © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Networking Interfaces All the host network interfaces are managed by virsh. Easily create or assign NIC to a guest. Create and handle bridges. Network transactions and network commits. Net Used to create bridges automatically Many type of network pools. Isolated Forward NAT Bridged Route Passthrough hostdev <network> <name>nat_pool</name> <uuid>11 f 69826 -6 dec-47 fc-ae 46 -efa 0 f 9 b 714 f 4</uuid> <forward mode='nat'/> <bridge name='virbr 1' stp='on' delay='0'/> <mac address='52: 00: d 1: 19: b 5'/> <ip address='192. 168. 22. 1' netmask='255. 0'> <dhcp> <range start='192. 168. 22. 2' end='192. 168. 22. 254'/> </dhcp> </ip> </network> © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Networking Bridging is usually the best way to configure your network if you are not able to passthrough. # virsh net-info default Name default UUID 11 f 69826 -6 de Active: yes Persistent: yes Autostart: yes Bridge: virbr 1 © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Snapshots Always use snapshot when you reach a point you want to 'save'. You run the snapshot command live: No Downtime at saving or backing up. Very fast and easy to be done Demo how to create a snapshot and how to recover it. $ virsh help snapshot Snapshot (help keyword 'snapshot'): snapshot-create Create a snapshot from XML snapshot-create-as Create a snapshot from a set of args snapshot-current Get or set the current snapshot-delete Delete a domain snapshot-dumpxml Dump XML for a domain snapshot-edit XML for a snapshot-info snapshot information snapshot-list List snapshots for a domain snapshot-parent Get the name of the parent of a snapshot-revert Revert a domain to a snapshot $ virsh help snapshot-list © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Creating snapshot © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Reverting snapshot © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Virt. IO The Virt. IO API is a high performance API that para-virtualized devices use to gain speed and efficiency. Virtio-scsi Virtio-blk Virtio-console Virtio_net The guest OS needs to have the drivers installed: At the moment, only Ubuntu versions have them. © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 16
CPU overcommitment Guest usually does not run on 100% of the CPU all the time CPUs run in burst mode CPU overcommitment is usually a good thing to do. The overcommitment rate depends on the workload, but usually 20 -50% of overcommitment is a good number Best practice: Target system use at 80% or lower © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 17
CPU Micro Threading Versus © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 18
Enabling CPU Micro Threading 1) Ensure that all guests are not running. 2) Set the number of subcores to 1: # ppc 64_cpu --subcores-per-core=1 3) Enable SMT on the host: # ppc 64_cpu --smt=on 4) Set the number of subcores to 4: # ppc 64_cpu --subcores-per-core=4 5) Turn the SMT off on the host: # ppc 64_smt --smt=off © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 19
CPU Pinning CPU pinning allows a guest virtual machine to be pinned to a given CPU or set of CPUs. It means that the hypervisor will schedule only v. CPUs in those CPUs that the guest is pinned to. By default, the guest can be scheduled on any CPU. <vcpu placement=’static’ cpuset=’ 0, 8’>8</vcpu> CPU Sharing CPU sharing defines the amount of CPU time a VM will have Usually a VM has sharing time of 1024. If your VM is configured to have 2048, it is going to have twice the CPU time compared to a default VM in an overcommitment scenario. <cputune> <shares>256</shares> </cputune> © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Kernel Same page Merge (KSM) KSM is a kernel feature in KVM that shares memory pages between various processes, over-committing the memory. How to enable: # systemctl start ksmtuned Monitoring: # cat /sys/kernel/mm/ksm/page_shared # cat /sys/kernel/mm/ksm/page_sharing # cat /sys/kernel/mm/ksm/sleep_milisecs # cat /sys/kernel/mm/ksm/full_scans If you configure KSM to act too aggressively, KSM might use an entire processor thread. © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Huge Pages The bigger pages (huge page) you have in the hypervisor, the less page your system needs, turning the memory management easier when looking for contiguous memory. Configuration: <memory. Backing> <hugepages/> </memory. Backing> Memory balloning Memory ballooning is a technique that allows the guest memory to be increased or decreased cooperatively, depending on the amount of free memory available on the guests and hypervisor. Configuration <memballoon model=’ virtio’> © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
Memory ballooning demo © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 23
Network Time Protocol (NTP) Set the same time on guest and hypervisor. © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 24
Disk Hot Plug Attaching disks to the virtual machine On the guest, you need to re scan the SCSI bus, usually calling rescan-scsi bus command © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 25
USB Passthrough Assign a USB device to the guest XML configuration on VM (USB) XML configuration on VM (PCI) © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 26
IPMI tips Uses an updated IPMI package on the client IPMI is based on UDP, so, avoid networks that lose packets. © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil 27
Thank you! © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
KVM vs Power. VM © 2014 IBM Corporation ● Systems Technical University ● 28 – 30 October | Atibaia, Sao Paulo, Brazil
- Slides: 29