Virtual Machine Migration Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Virtual Machine Migration Lab

1. Create 3 virtual machines.


2 Virtual machines will run the hypervisor and 1 virtual machine will be used as
central storage.
Hypervisor machine configuration - 2 CPU’s , 4 GB RAM , Enable Intel VT in the
processor setting. 20 GB Hardisk
Central storage machine configuration - 1 CPU, 2GB RAM, 50GB hardisk.
Keep Network in NAT mode for all the virtual machines.

2. Install Ubuntu server.


Install Ubuntu server operating system on all the three virtual machines. Then
update all virtual machines using command sudo apt update -y .

3. Configure the storage server


Install NFS server on the storage VM. Use sudo apt install nfs-server -y .
Create a directory to store virtual machine hard disk files. mkdir /vm-store.
Share this directory using NFS. To do this edit the /etc/exports file. It will be a blank
file. Add following line to the file and save the file.
/vm-store *(rw,no_root_squash)

Start the NFS service. sudo systemctl start nfs-server.


To check directory is shared using NFS, give following command.
showmount -e localhost
The command output should display the name of the directory.
Next disable the firewall if it is running. sudo systemctl status ufw.
If the firewall is running disable it by using following commands.
sudo systemctl stop ufw
sudo systemctl disable ufw

Note down the IP address of the storage server.

4. Configure the first hypervisor server.


First set the hostname of the server. Here we set the name as node1.
sudo hostnamectl set-hostname node1

Next install hypervisor packages on this server. Use following command.


sudo apt install qemu-kvm libvirt-bin virt-manager -y

Install NFS client and openssh server on server. Use following command.
sudo apt install nfs-client openssh-server -y

Install desktop on the server.


sudo apt install ubuntu-desktop -y
Restart the server. Login. Once you login, type following command to check
hypervisor is installed properly.
sudo virt-manager.
5. Configure the second hypervisor server.
Perform all the above steps performed to prepare the first hypervisor server on this
second VM.
Please give the name as node2.
All other commands will be same.

6. Configure password less ssh between 2 Hypervisor nodes.


Perform following steps on both servers running hypervisor.
First enable root login in ssh configuration. Edit the file /etc/ssh/sshd_config.
In Authentication section find the entry PermitRootLogin. Remove comment(#) from
it and change it to following. Also add following line.
PermitRootLogin yes
PermitRootLogin without-password

Save the file.


Re-Start the SSH Service.
sudo systemctl restart ssh

Enable root account and assign password to it. Use following commands.

sudo passwd -l root


Sudo passwd

Now generate ssh keys for both users (default user and root user). use following
commands. Press Enter at all prompts for both the commands.

ssh-keygen -t rsa
sudo ssh-keygen -t rsa

Now note down the IP address of both the hypervisor servers. Edit the /etc/hosts file.
Add following entries. **Replace IP address with your server IP address. Keep all
default entries as it is. Do not remove any earlier entry.
192.168.10.1 node1
192.168.10.2 node2

Save the file.

7. Copy ssh keys.

To copy SSH keys from node1 to node2 use following command.


sudo ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2

To copy SSH keys from node2 to node1 use following command.


sudo ssh-copy-id -i /root/.ssh/id_rsa.pub root@node1

Check by using sudo ssh node1 from node2 and sudo ssh node2 from node1.
8. Connect Hypervisor to NFS Share

Perform this action on both the hypervisor machines (node1 and node2).
Open virt-manager using sudo virt-manager command. Right click on the
QEMU/KVM option and click details. Click the Storage tab. The default storage pool
will be shown. Stop the pool using first red button below. Then delete this pool using
second red button. Then click Add pool button(Plus sign). Provide the name as
default. In the type drop down list select netfs : Network Exported directory option.
Click Forward.
In the hostname field type IP address of the storage server. In the source path field
type the directory name as /vm-store. Click Finish.

9. Create a VM and Install an operating system.

Attach the operating system iso image to first hypervisor node CD/DVD that you
want to install on the VM within this VM.

On the first hypervisor node open virt-manager using sudo virt-manager.


Create a new virtual machine. Set the RAM as 1500 if you are installing Windows. Set
Hard disk as 35GB for Windows. For Linux OS you can set RAM as 1024 and Hard disk
as 10 GB. Select default network. Once the VM is created start it and install OS.

10. Migrate above VM to second hypervisor.

Once the above VM is installed and running, you can migrate it. To migrate VM first
add second hypervisor to the virt-manager. To do this go to File and click Add
Coonection. In the window that opens click the check box - Connect to remote host.
Type node2 in the hostname field. Click the checkbox of Auto connect.
Click Connect.

Now the node2 hypervisor name will appear.

Click The running VM and right click and click Migrate. In the window that opens,
click Advanced options and click the check box of Allow Unsafe. Then click Migrate.

If any error appears …. Check Firewall status and disable it using following command.

sudo systemctl status ufw.


sudo systemctl stop ufw.

Then try migration again.

You might also like