In daily learning, if you encounter cluster and load balancing experiments, you need to use a lot of virtual machines, if one to create, it is obviously very laborious and inefficient. So today we give you how to use snapshots to make virtual machines. How much you want to ^_^. As long as the memory is enough!
The snapshot of a virtual machine is divided into the following steps:
1. First we will create a stored logical volume to generate the template and snapshot files;
2. Make the template of the snapshot;
3. Create a snapshot.
1. Create a logical Volume:
(1) FDISK/DEV/SDA (make LVM logical volume, then scan the disk again;)
(2) partx-d/DEV/SDA
Partx-a/DEV/SDA
(3) Create the LV file:
Pvcreate/dev/sda
Vgcreate-s 4M Vg1/dev/sda5
Lvcreate-l 10g-n Base Vg1
(4) You can then create a virtual machine template:
This time you can install a normal virtual machine like. What to do once the reboot is complete (because you're making a template, so the template has to be universal)
2. Create a Template:
There are a few things to do in the template virtual machine:
1. Close firewall and SELinux (modified in file):
Vim/etc/sysconfig/selinux
2. Modify the network configuration file and delete the network card information:
Vim/etc/sysconfig/network-script/ifcfg-eth0
3. Modify the Yum source to a stable address:
Vim/etc/yum.repos.d/yum.repo
3. Create a Snapshot:
After the completion of our template has been completed, this time on the real machine with a snapshot of it to take pictures, but before taking the picture must be closed off, usually we give a picture of the time is also to his static ^_^.
Select our Snapshot file:
Direct start vm2, instantly open, his state is the initial state of the template, very convenient.
Let's calculate the total cost:
Template (10G)
In the future, each virtual machine needs to be about 4G, which makes a lot of virtual machines. No installation is required, and space overhead is greatly reduced.
Conclusion:
Let's go to practice for the little friends.