2016
April
Standard

WebVirtMgr@CentOS 6 KVM libvirtd

Install WebVirtMgr @ Centos 6:

# yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
# git clone git://github.com/retspen/webvirtmgr.git
# cd webvirtmgr
# pip install -r requirements.txt
# ./manage.py syncdb
# ./manage.py collectstatic


##########Adding additional superusers

# ./manage.py createsuperuser

######
# cd ..
# mv webvirtmgr /var/www/
####NGINX VIRTULKA HOST:

# cat /etc/nginx/conf.d/webvirtmgr.conf 
server {
    listen       6699;
    server_name  kvm.belomor.nl:6699;
    

    location /static/ {
root /var/www/webvirtmgr/webvirtmgr;        
expires max;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs 
    }
}

###Update SELinux policy

# setsebool httpd_can_network_connect true 

####SET OWNER nginx
# chown -R nginx:nginx /var/www/webvirtmgr


#####################

Continue Reading →

The end
Standard

Migrate KVM Guest running on LVM to another KVM Hypervizor.

Sharing tutorial how I have migrated vm.belomor.nl…

**///////////////// Create the key pair:

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
02:39:0b:41:de:2e:1c:65:dd:54:82:5a:64:68:1f:e0 root@source-kvm
The key's randomart image is:
+--[ RSA 2048]----+
| .o +=o+o..      |
| . *oo= ..       |
|  +.E+ .         |
| . +.+.          |
|  o o . S        |
|   .   .         |
|                 |
|                 |
|                 |
+-----------------+

**/////////////////Share pubkey between the two hosts from source server

# ssh-copy-id root@destination-kvm
root@destination-kvm's password: 
Now try logging into the machine, with "ssh 'root@destination-kvm'", and check in:

  .ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

**/////////////////Create Logical Volume on target:

# lvcreate -L 50G -n vm.belomor.nl vol_group_vm</strong>
  Logical volume "vm.belomor.nl" created

**/////////////////Pipe the volume to the target host:

# dd if=/dev/vol_group_vm/vm.belomor.nl | ssh root@destination-kvm 'dd of=/dev/vol_group_vm/vm.belomor.nl'

104857600+0 records in
104857600+0 records out
53687091200 bytes (54 GB) copied, 2632.79 s, 20.4 MB/s

**/////////////////Cofee Brake :)
**/////////////////Cofee Brake :)
**/////////////////Dump the xml definition.

# virsh dumpxml vm.belomor.nl > vm.belomor.nl_dump.xml

**/////////////////Transfer xml-file:

# scp vm.belomor.nl_dump.xml root@destination-kvm:/root/
vm.belomor.nl_dump.xml

**/////////////////Define the machine on target:

# virsh define vm.belomor.nl_dump.xml

Domain vm.belomor.nl defined from vm.belomor.nl_dump.xml

**/////////////////Start transferred machine:

# virsh start vm.belomor.nl

#######################AFTER SUCCESSFUL MIGRATION YOU CAN PROCEED WITH CLEAN UP PROCEDURE:

# virsh undefine vm.belomor.nl
Domain vm.belomor.nl has been undefined

# lvremove /dev/vol_group_vm/vm.belomor.nl 
Do you really want to remove active logical volume vm.belomor.nl? [y/n]: y
  Logical volume "vm.belomor.nl" successfully removed

Done...
# date
Tue Apr  5 13:56:10 AZT 2016

[email protected]; [email protected]

The end