The method of creating and cloning the KVM virtual machine _KVM

Source: Internet
Author: User

Objective

This article introduces the creation and cloning of KVM virtual machine, the following words do not say, to see detailed procedures

First, create a virtual machine:

Qemu-img create-f qcow2-o preallocation=metadata/data/kvm_centos/centos6.7_base.qcow2 10G

virt-install--name= Centos6.7_base--ram--vcpus=1-f/data/kvm_centos/centos6.7_base.qcow2--location/data/soft/centos-6.7-x86_64- Bin-dvd1.iso--graphics vnc,listen=0.0.0.0,port=6900,--extra-args= ' console=tty0 console=ttyS0,115200n8 '- Network Network=default,--force--autostart

Second, cloning virtual machines:

The cloning of a KVM virtual machine, we can be divided into the following steps:

1. Cloning with the Virt-clone command

2. Modify the VNC connection port of cloned virtual machine by Virsh Edit command

3, configure the clone after the virtual machine host name, IP address and so on content

1, using the Virt-clone command to clone operations, the machine that remains cloned before cloning belongs to the shutdown state

[root@puppetnode01 yum.repos.d]# virsh list--all Id Name State------------------------------------------ -----------centos6.7_01 shut off [root@puppetnode01 yum.repos.d]# cd/data/kvm_centos/[root@puppetnode01 k vm_centos]# ll Total 2774424-rw-r--r--1 root 10739318784 Oct 15:54 centos6.7_01.qcow2 [root@puppetnode01 Kvm_cen tos]# virt-clone-o centos6.7_01-n centos_ansible_01-f/data/kvm_centos/centos_ansible_01.qcow2 Cloning. Qcow2 |
Ten GB 01:16 Clone ' centos_ansible_01 ' created successfully. [root@puppetnode01 kvm_centos]# virsh list--all Id Name State-------------------------------------------- ---------centos6.7_01 shut off-centos_ansible_01 shut off [root@puppetnode01 kvm_centos]# [Roo T@PUPPETNODE01 kvm_centos]# virsh start centos_ansible_01 Domain centos_ansible_01 started [root@puppetnode01 kvm_ centos]# Virsh List--all Id Name State----------------------------------------------------3 centos_ansible_01  running-centos6.7_01 shut off [root@puppetnode01 kvm_centos]#

After cloning, you need some of the following operations to use this new machine.

1, modify VNC port address, because the cloned machine in the establishment of the time with the VNC port content

[root@puppetnode01 kvm_centos]# Virsh edit centos_ansible_01 <graphics type= ' vnc ' port= ' 5900 ' autoport= '
  no ' listen= ' 0.0.0.0 ' >
   <listen type= ' address ' address= ' 0.0.0.0 '/>
  </graphics>

2, use Virsh console login machine, modify the host name, IP address and other content

[Root@centos_init ~]# cat/etc/sysconfig/network
networking=yes
hostname=centos_ansible_01
[ Root@centos_init ~]# cat/etc/hosts
127.0.0.1 centos_ansible_01 localhost localhost.localdomain localhost4  Localhost4.localdomain4
:: 1     localhost localhost.localdomain localhost6 localhost6.localdomain6
[ Root@centos_init ~]# cat/etc/sysconfig/network-scripts/ifcfg-eth0 
device=eth1
Hwaddr=52:54:00:20:d6:f6
type=ethernet
uuid=21114847-3d8c-4e4b-86be-04c76d848c92
onboot=yes
nm_controlled=yes
bootproto=static
gateway=192.168.122.1
ipaddr=192.168.122.11
dns=192.168.122.1

It can be used normally after reboot.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.