标签:qcow2 os virt 虚拟机 KVM web04 创建 virsh type
安装:
yum install libvirt virt-install qemu-kvm -y
介绍:
libvirt服务:管理kvm虚拟机的生命周期
virt-install工具:创建安装虚拟机
qemu-kvm工具:使用qemu-img为虚拟机提供硬盘
新创建一个虚拟机:
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7
--memory 1024 --vcpus 1 --disk /opt/centos2.raw,format=raw,size=10
--cdrom /opt/CentOS-7-x86_64-DVD-1708.iso
--network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
创建虚拟磁盘
qemu-img create test.raw 10G
qemu-img create -f qcow2 test.qcow2 10G
查看虚拟磁盘信息
qemu-img info test.raw
调整虚拟磁盘容量大小
qemu-img resize test.raw +5G
磁盘格式转换
qemu-img convert -f raw -O qcow2 test.raw oldboy.qcow2
创建快照
virsh snapshot-create centos7
查看快照
virsh snapshot-list centos7
还原快照
virsh snapshot-revert centos7 --snapshotname 1516574134
删除快照
virsh snapshot-delete centos7 --snapshotname 1516636570
完整克隆
实现方法:
virt-clone -o web01 --auto-clone
链接克隆
1:克隆虚拟磁盘文件
cp centos7.qcow2 web03.qcow2
2:生成新的虚拟机配置文件
name修改
uuid删掉
disk路径/opt/web03.qcow2
mac地址删除
3:测试启动
virsh define web01.xml
qemu-img create -f qcow2 -b cetnos7.qcow2 web04.qcow2
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web02 --memory 1024 --vcpus 1 --disk /opt/web04.qcow2,format=qcow2,size=10 --boot hd --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
创建桥接网络
1:virsh iface-bridge eth0 br0
基于桥接网络创建虚拟机
2:virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web04 --memory 1024 --vcpus 1 --disk /opt/web04.qcow2,format=qcow2,size=10 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
1:virsh edit centos7
<interface type='bridge'>
<mac address='52:54:00:55:aa:fa'/>
<source bridge='br0’/>
2:修改虚拟机ip地址
/etc/sysconfig/network-scripts/ifcfg-eth0
创建硬盘
qemu-img create -f qcow2 centos7-add01.qcow2 5G
热添加硬盘
virsh attach-disk web01 /opt/centos7-add01.qcow2 vdb --live --cache=none --subdriver=qcow2
添加网卡
virsh attach-interface web04 --type bridge --model virtio --source br0
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web01 --memory 1024 --vcpus 1,maxvcpus=4 --disk /opt/web04.qcow2,format=qcow2,size=10 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
热添加cpu
virsh setvcpus web04 --count=2
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web04 --memory 512,maxmemory=2048 --vcpus=1,maxvcpus=2 --disk /opt/web04.qcow2,format=qcow2,size=10 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
热添加内存
virsh setmem web04 1G
标签:qcow2,os,virt,虚拟机,KVM,web04,创建,virsh,type 来源: http://blog.51cto.com/12083623/2343431
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。