kvm磁盘管理

kvm虚拟机虚拟磁盘格式转换

各种格式说明介绍

  1. row:裸格式,占用空间较大,不支持快照功能,性能较好,不方便传输(顺序读写) 50G 2G 传输50G
  2. qcow2:cow 占用空间小,支持快照,性能比raw差一点,方便传输(随机读写) 50G 2G 传输2G
  1. qemu-img
  2. info 查看虚拟磁盘信息
  3. create 创建虚拟磁盘文件
  4. qemu-img create test.raw 5G
  5. qemu-img create -f qcow2 test.qcow2 5G
  6. resize 调整虚拟磁盘容量大小
  7. qemu-img resize test.raw +5G
  8. qemu-img resize test.qcow2 5G
  9. 不管是什么格式的虚拟磁盘,不能缩容
  10. convert 转换磁盘格式
  11. 1.#创建一块qcow2的虚拟硬盘(仅测试使用,无实际意义)
  12. [root@qiudao /opt]# mkdir /data
  13. [root@qiudao /opt]# cd /data/
  14. [root@qiudao /data]# qemu-img create -f qcow2 centos7.qcow2 2G
  15. Formatting 'centos7.qcow2', fmt=qcow2 size=2147483648 encryption=off cluster_size=65536 lazy_refcounts=off
  16. [root@qiudao /data]# ll -h
  17. total 196K
  18. -rw-r--r-- 1 root root 193K 2019-07-23 10:58 centos7.qcow2
  19. #查看当前虚拟机硬盘信息
  20. [root@qiudao /data]# qemu-img info /data/centos7.qcow2
  21. image: /data/centos7.qcow2
  22. file format: qcow2
  23. virtual size: 2.0G (2147483648 bytes)
  24. disk size: 196K
  25. cluster_size: 65536
  26. Format specific information:
  27. compat: 1.1
  28. lazy refcounts: false
  29. #转换格式,语法说明
  30. [root@qiudao /data]# qemu-img --help |grep convert
  31. convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename
  32. 2.#转换原有磁盘格式
  33. [root@qiudao /opt]# qemu-img convert -f raw -O qcow2 centos7.raw centos7.qcow2
  34. #转化之后,要想使用,要修改kvm虚拟机的主配置文件
  35. [root@qiudao /opt]# virsh edit centos7
  36. 32 <disk type='file' device='disk'>
  37. 33 <driver name='qemu' type='qcow2'/> #将原来的raw改成qcow2
  38. 34 <source file='/opt/centos7.qcow2'/> #将原来的raw改成qcow2
  39. 35 <target dev='vda' bus='virtio'/>
  40. 36 <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
  41. 37 </disk>
  42. 3.#删除原磁盘文件
  43. [root@qiudao /opt]# rm -f centos7.raw
  44. 4.#启动kvm虚拟机
  45. [root@qiudao /opt]# virsh start centos7
  46. 5.#连接测试
  47. [root@qiudao /opt]# virsh console centos7

kvm在线热添加硬盘

  1. #进入/opt目录下,添加一块硬盘
  2. [root@qiudao ~]# cd /opt/
  3. [root@qiudao /opt]# ll
  4. total 10003908
  5. -rw-r--r-- 1 qemu qemu 3916431360 2019-07-22 22:03 CentOS-6.8-x86_64-bin-DVD1.iso
  6. -rw-r--r-- 1 qemu qemu 1752956928 2019-07-24 01:04 centos7.qcow2
  7. -rw-r--r-- 1 qemu qemu 4588568576 2019-07-22 17:58 CentOS-7-x86_64-DVD-1810.iso
  8. #添加5G硬盘
  9. [root@qiudao /opt]# qemu-img create -f qcow2 /opt/centos7-add01.qcow2 5G
  10. Formatting '/opt/centos7-add01.qcow2', fmt=qcow2 size=5368709120 encryption=off cluster_size=65536 lazy_refcounts=off
  11. #查看信息
  12. [root@qiudao /opt]# qemu-img info centos7-add01.qcow2
  13. image: centos7-add01.qcow2
  14. file format: qcow2
  15. virtual size: 5.0G (5368709120 bytes)
  16. disk size: 196K
  17. cluster_size: 65536
  18. Format specific information:
  19. compat: 1.1
  20. lazy refcounts: false
  21. #给kvm虚拟机centos7热添加硬盘
  22. [root@qiudao /opt]# virsh attach-disk centos7 /opt/centos7-add01.qcow2 vdb --live --cache=none --subdriver=qcow2 #临时生效
  23. Disk attached successfully
  24. [root@qiudao /opt]# virsh attach-disk centos7 /opt/centos7-add01.qcow2 vdb --live --cache=none --subdriver=qcow2 --config #永久生效,最好写绝对路径
  25. vdb #第二块硬盘
  26. --live #热添加
  27. --cache=none #宿主机对客户机的镜像的读写cache开启,off表示关闭
  28. --subdriver #驱动类型
  29. #vnc查看添加结果
  30. [root@kvm01 opt]# virsh console centos7
  31. [root@centos7 ~]# lsblk
  32. #剥离磁盘
  33. [root@kvm01 opt]# virsh detach-disk centos7 vdb
  34. Disk detached successfully
  35. [root@kvm01 opt]# virsh console centos7
  36. Connected to domain centos7
  37. Escape character is ^]
  38. [root@centos7 ~]# lsblk

在线扩容磁盘的大小

  1. #增加硬盘大小,生产环境中,只加不减
  2. [root@qiudao /opt]# qemu-img resize /opt/centos7-add01.qcow2 +5G
  3. Image resized.
  4. [root@qiudao /opt]# qemu-img info /opt/centos7-add01.qcow2
  5. image: /opt/centos7-add01.qcow2
  6. file format: qcow2
  7. virtual size: 10G (10737418240 bytes)
  8. disk size: 260K
  9. cluster_size: 65536
  10. Format specific information:
  11. compat: 1.1
  12. lazy refcounts: false
  13. #再重新给centos7热添加硬盘
  14. [root@qiudao /opt]# virsh attach-disk centos7 /opt/centos7-add01.qcow2 vdb --live --cache=none --subdriver=qcow2 #最好写绝对路径
  15. Disk attached successfully
  16. #控制台登录
  17. [root@kvm01 opt]# virsh console centos7
  18. Connected to domain centos7
  19. Escape character is ^]
  20. [root@centos7 ~]# lsblk
  21. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  22. sr0 11:0 1 1024M 0 rom
  23. vda 252:0 0 10G 0 disk
  24. ├─vda1 252:1 0 1G 0 part /boot
  25. └─vda2 252:2 0 9G 0 part
  26. ├─centos-root 253:0 0 8G 0 lvm /
  27. └─centos-swap 253:1 0 1G 0 lvm [SWAP]
  28. vdb 252:16 0 10G 0 disk
  29. #格式化操作,创建文件系统
  30. [root@centos7 ~]# mkfs.xfs /dev/vdb
  31. meta-data=/dev/vdb isize=512 agcount=4, agsize=655360 blks
  32. = sectsz=512 attr=2, projid32bit=1
  33. = crc=1 finobt=0, sparse=0
  34. data = bsize=4096 blocks=2621440, imaxpct=25
  35. = sunit=0 swidth=0 blks
  36. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  37. log =internal log bsize=4096 blocks=2560, version=2
  38. = sectsz=512 sunit=0 blks, lazy-count=1
  39. realtime =none extsz=4096 blocks=0, rtextents=0
  40. #挂载使用
  41. [root@centos7 ~]# mount /dev/vdb /opt/
  42. [root@centos7 ~]# df -h
  43. Filesystem Size Used Avail Use% Mounted on
  44. /dev/mapper/centos-root 8.0G 1007M 7.1G 13% /
  45. devtmpfs 988M 0 988M 0% /dev
  46. tmpfs 1000M 0 1000M 0% /dev/shm
  47. tmpfs 1000M 8.5M 992M 1% /run
  48. tmpfs 1000M 0 1000M 0% /sys/fs/cgroup
  49. /dev/vda1 1014M 133M 882M 14% /boot
  50. tmpfs 200M 0 200M 0% /run/user/0
  51. /dev/vdb 10G 33M 10G 1% /opt

普通分区的扩容

  1. 1检查是否挂载,有卸载,剥离出来
  2. 2.外面添加
  3. qemu-img resize web02.add.qcow2 15G
  4. 3.挂载
  5. virsh console centos7
  6. mount /dev/vdb /opt/
  7. 4.跟新文件系统,调整元数据
  8. xfs_growfs /opt

根分区扩容

  1. #根分区扩容
  2. 1.先关机,存在快照,删除快照
  3. 2.扩容根分区
  4. [root@kvm01 opt]# qemu-img resize /opt/centos7.qcow2 +10G
  5. Image resized.
  6. 3.登录进行从新分区
  7. virsh console centos7
  8. [root@qiudao /opt]# fdisk /dev/vda
  9. 删除原有的分区,重新创建分区
  10. partprobe #通知内核系统分区发生变化
  11. 4.重启
  12. reboot
  13. 5.跟新文件系统
  14. [root@centos7 ~]# xfs_growfs /dev/centos/root #更新文件系统
  15. 具体详见:RAID&LVM有关磁盘的故障

kvm快照管理(写实复制,相当于创建分支)

基本命令

  1. #创建
  2. virsh snapshot-create centos7
  3. #查看
  4. virsh snapshot-list centos7
  5. #恢复
  6. virsh snapshot-revert centos7 --snapshotnanme +时间戳
  7. #删除
  8. virsh snapshot-delete centos7 --snapshotname +时间戳
  9. #注意:raw格式的磁盘无法创建快照,qcow2支持快照,并且快照就保存在qcow2的磁盘文件中
  1. 1.#创建快照
  2. [root@qiudao ~]# virsh snapshot-create centos7
  3. Domain snapshot 1563866292 created
  4. #开机状态下的快照
  5. [root@kvm01 opt]# virsh snapshot-create centos7
  6. Domain snapshot 1575391158 created
  7. [root@kvm01 opt]# ll /var/lib/libvirt/qemu/snapshot/centos7/
  8. total 16
  9. -rw------- 1 root root 4951 Dec 4 00:39 1575390933.xml
  10. -rw------- 1 root root 4973 Dec 4 00:39 1575391158.xml
  11. #查看主机快照列表
  12. [root@qiudao ~]# virsh snapshot-list centos7
  13. Name Creation Time State
  14. ------------------------------------------------------------
  15. 1563866292 2019-07-23 15:18:12 +0800 running
  16. #查看快照信息
  17. [root@qiudao ~]# virsh snapshot-info centos7 --snapshotname 1563866292
  18. Name: 1563866292
  19. Domain: centos7
  20. Current: yes
  21. State: running
  22. Location: internal
  23. Parent: -
  24. Children: 0
  25. Descendants: 0
  26. Metadata: yes
  27. #模拟虚拟机故障,登陆虚拟机,进行删除操作。
  28. [root@qiudao ~]# virsh console centos7
  29. [root@centos7 ~]# rm -rf /*
  30. #登录测试
  31. [root@qiudao ~]# virsh console centos7
  32. Connected to domain centos7
  33. Escape character is ^]
  34. -bash: /bin/rm: No such file or directory
  35. [root@centos7 ~]# ll
  36. -bash: /bin/ls: No such file or directory
  37. [root@centos7 ~]# ls
  38. -bash: /bin/ls: No such file or directory
  39. #还原快照
  40. [root@qiudao ~]# virsh snapshot-revert centos7 1563866292
  41. #登录测试
  42. [root@qiudao ~]# virsh console centos7
  43. Connected to domain centos7
  44. Escape character is ^]
  45. CentOS Linux 7 (Core)
  46. Kernel 3.10.0-957.el7.x86_64 on an x86_64
  47. centos7 login: root
  48. Password:
  49. Last login: Tue Jul 23 11:33:15 on ttyS0
  50. [root@centos7 ~]# ll
  51. total 4
  52. -rw-------. 1 root root 1161 Jul 22 20:52 anaconda-ks.cfg
  53. #快照配置文件位置
  54. [root@qiudao ~]# tree /var/lib/libvirt/qemu/snapshot/
  55. /var/lib/libvirt/qemu/snapshot/
  56. └── centos7
  57. └── 1563866292.xml
  58. #删除快照
  59. [root@qiudao ~]# virsh snapshot-delete centos7 1563866292
  60. Domain snapshot 1563866292 deleted

克隆

手动克隆

  1. 1.关机
  2. [root@kvm01 opt]# virsh shutdown centos7-clone
  3. 2.到户配置信息
  4. [root@kvm01 opt]# virsh dumpxml centos7 >centos7.3bak
  5. 3.拷贝
  6. cp 磁盘(注意快照也会)
  7. [root@kvm01 opt]# cp centos7.qcow2 web02.qcow2
  8. 4.修改路径
  9. [root@kvm01 opt]# vim centos7.3bak
  10. 编辑如下几个配置文件
  11. vi /etc/libvirt/qemu/centos7.xml
  12. <name>centos7</name>
  13. <uuid>ec29ba5d-863f-4317-b4dd-c7e1f23260d9</uuid> #删掉
  14. <source file='/opt/centos7.qcow2'/>
  15. <mac address='52:54:00:6a:e9:e4'/> #删掉
  16. 5.导入配置
  17. [root@kvm01 opt]# virsh define centos7.3bak
  18. 6.启动kvm
  19. [root@kvm01 opt]# virsh start web02
  20. 7.进入kvm
  21. [root@kvm01 opt]# virsh console web02
  22. 8.测试 连接
  23. ifup eth0 #启动网卡

完整克隆

  1. [root@qiudao /opt]# virsh shutdown centos7        #只有关机状态才能克隆
  2. Domain centos7 is being shutdown
  3. [root@qiudao /opt]# virsh list --all
  4. ## Id Name State
  5. - centos6 shut off
  6. - centos7 shut off
  7. --auto-clone     #从原始客户机配置中自动生成克隆名称和存储路径。
  8. -o                #原始客户机名称;必须为关闭或者暂停状态。
  9. [root@qiudao /opt]# virt-clone --auto-clone -o centos7 -n centos7-v1
  10. Allocating 'centos72-clone.qcow2' | 10 GB 00:01:01
  11. Clone 'centos7-v1' created successfully.
  12. [root@qiudao /opt]# virsh list --all
  13. ## Id Name State
  14. - centos6 shut off
  15. - centos7 shut off
  16. - centos7-v1 shut off        #克隆主机名称
  17. [root@qiudao /opt]# ll
  18. total 11851148
  19. -rw-r--r-- 1 qemu qemu 3916431360 2019-07-22 22:03 CentOS-6.8-x86_64-bin-DVD1.iso
  20. -rw------- 1 root root 1468268544 2019-08-30 21:07 centos7-clone.qcow2     #克隆机的镜像文件
  21. -rw-r--r-- 1 root root 1752956928 2019-08-30 21:05 centos7.qcow2
  22. -rw-r--r-- 1 root root 11534336 2019-08-30 21:05 centos7-add01.qcow2
  23. -rw-r--r-- 1 qemu qemu 4588568576 2019-07-22 17:58 CentOS-7-x86_64-DVD-1810.iso
  24. [root@qiudao /opt]# ll /etc/libvirt/qemu/
  25. total 20
  26. drwxr-xr-x 2 root root 6 2019-07-23 10:28 autostart
  27. -rw------- 1 root root 3906 2019-07-22 22:11 centos6.xml
  28. -rw------- 1 root root 4377 2019-08-30 21:06 centos7-v1.xml        #克隆机的配置文件
  29. -rw------- 1 root root 4365 2019-07-23 16:23 centos7.xml
  30. drwx------ 3 root root 42 2019-07-22 17:03 networks

连接克隆

  1. #Kvm手动克隆虚拟机:
  2. 前提:关机状态下
  3. 1:创建基于链接克隆的虚拟磁盘文件
  4. qemu-img create -f qcow2 -b old_disk new_disk
  5.   
  6. 2:备份centos7的虚拟机配置文件,另存为centos7-v2
  7. 3:修改centos7-v2的虚拟机配置文件
  8.     a:<name>centos7-v2</name>
  9.     b:删除uuid
  10.     c:删除mac address
  11.     d:修改虚拟机磁盘路径
  12. 4:导入centos7-v2
  13. 5:检查是否正常启动
  14. 6:编写自动化脚本
  15. [root@kvm01 opt]# cat link_clone.sh
  16. #!/bin/bash
  17. Old_name=$1
  18. New_name=$2
  19. #1.关闭宿主机
  20. virsh shutdown $Old_name &>/dev/null
  21. sleep 3
  22. #2.导出宿主机配置信息
  23. virsh dumpxml $Old_name > /opt/${New_name}.xml
  24. #3.创建基于宿主机的磁盘文件
  25. qemu-img create -f qcow2 -b /opt/${Old_name}.qcow2 /opt/${New_name}.qcow2 &>/dev/null
  26. #4.编辑配置文件
  27. sed -i "s#$Old_name#$New_name#g" /opt/${New_name}.xml
  28. sed -i '/uuid/d' /opt/${New_name}.xml
  29. sed -i '/mac address/d' /opt/${New_name}.xml
  30. #5.导入配置
  31. virsh define /opt/${New_name}.xml &>/dev/null
  32. #6.启动测试
  33. virsh start $New_name &>/dev/null
  34. #执行测试
  35. [root@kvm01 opt]# sh link_clone.sh centos7 lb01
  36. #7.console登录
  37. virsh console $New_name
  38. #一键创建连接克隆
  39. [root@qiudao /opt]# virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web05 --memory 1024 --vcpus 1 --disk /opt/web05.qcow2 --boot hd --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
  40. 本地硬盘 web05.qcow2
  41. --boot #指定启动路径
  42. hd 磁盘

kvm虚拟机的桥接网络

NAT连接

问题:用户访问跟我们的业务的ip地址不一样

前期测试

  1. #查看交换机
  2. [root@kvm01 opt]# brctl show
  3. bridge name bridge id STP enabled interfaces
  4. virbr0 8000.5254004f87a6 yes virbr0-nic
  5. vnet0
  6. #查看内核转换参数
  7. [root@kvm01 opt]# sysctl -a|grep ipv4|grep forward
  8. net.ipv4.ip_forward = 1 #开启
  9. sysctl net.ipv4.ip_forward = 1 可以手动控制

新创建的kvm-NAT

  1. virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web05 --memory 1024 --vcpus 1 --disk /opt/web05.qcow2 --boot hd --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole

前期准备

  1. #创建一个桥接网络,执行命令
  2. [root@qiudao ~]# virsh iface-bridge eth0 br0
  3. Created bridge br0 with attached device eth0
  4. Bridge interface br0 started
  5. #查看
  6. [root@qiudao ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
  7. DEVICE="br0"
  8. ONBOOT="yes"
  9. TYPE="Bridge"
  10. BOOTPROTO="none"
  11. IPADDR="10.0.0.100"
  12. NETMASK="255.255.255.0"
  13. GATEWAY="10.0.0.254"
  14. IPV6INIT="yes"
  15. IPV6_AUTOCONF="yes"
  16. DHCPV6C="no"
  17. STP="on"
  18. DELAY="0"
  19. [root@qiudao ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
  20. DEVICE=eth0
  21. ONBOOT=yes
  22. BRIDGE="br0"
  23. #查看桥接网络信息
  24. [root@qiudao ~]# brctl show
  25. bridge name bridge id STP enabled interfaces
  26. br0 8000.000c2990428b yes eth0
  27. virbr0 8000.5254007cc337 yes virbr0-nic

桥接模式

新创建的,走桥接模式

  1. virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web05 --memory 1024 --vcpus 1 --disk /opt/web05.qcow2 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole

修改桥接模式

  1. #关闭主机centos7
  2. [root@qiudao ~]# virsh shutdown centos7
  3. Domain centos7 is being shutdown
  4. [root@qiudao ~]# virsh list --all
  5. Id Name State
  6. ----------------------------------------------------
  7. - centos6 shut off
  8. - centos7 shut off
  9. - centos7-v1 shut off
  10. #修改配置文件
  11. [root@qiudao ~]# virsh edit centos7
  12. 74 <interface type='bridge'> #类型修改为bridge
  13. 75 <mac address='52:54:00:59:9d:20'/>
  14. 76 <source bridge='br0'/> #类型和名称
  15. 77 <model type='virtio'/>
  16. 78 <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
  17. 79 </interface>
  18. #启动主机
  19. [root@qiudao ~]# virsh start centos7
  20. Domain centos7 started
  21. [root@qiudao ~]# virsh list --all
  22. Id Name State
  23. ----------------------------------------------------
  24. 2 centos7 running
  25. - centos6 shut off
  26. - centos7-v1 shut off
  27. #连接修改网卡信息
  28. [root@qiudao ~]# virsh console centos7
  29. [root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
  30. TYPE="Ethernet"
  31. BOOTPROTO="none"
  32. NAME="eth0"
  33. DEVICE="eth0"
  34. ONBOOT="yes"
  35. IPADDR="10.0.0.101"
  36. NETMASK="255.255.255.0"
  37. GATEWAY="10.0.0.254"
  38. DNS1="223.5.5.5"
  39. #重启网络
  40. [root@centos7 ~]# systemctl restart network
  41. [root@centos7 ~]# systemctl stop NetworkManager
  42. [root@centos7 ~]# systemctl disable NetworkManager
  43. systemctl start libvirtd
  44. #配置dns解析
  45. [root@webvirtmgr ~]# cat /etc/resolv.conf
  46. # Generated by NetworkManager
  47. nameserver 223.5.5.5
  48. nameserver 223.6.6.6
  49. #测试上网
  50. [root@centos7 ~]# ping baidu.com
  51. PING baidu.com (39.156.69.79) 56(84) bytes of data.
  52. 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=128 time=29.5 ms
  53. 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=128 time=30.5 ms
  54. #本地直接连接kvm虚拟机
  55. [C:\~]$ ssh root@10.0.0.101
  56. Connecting to 10.0.0.101:22...
  57. Connection established.
  58. To escape to local shell, press 'Ctrl+Alt+]'.
  59. Last failed login: Fri Aug 30 23:46:16 CST 2019 from 10.0.0.1 on ssh:notty
  60. There was 1 failed login attempt since the last successful login.
  61. Last login: Fri Aug 30 23:26:26 2019
  62. [root@centos7 ~]#

热添加网卡,内存,cpu

  1. 1.kvm添加网卡
  2. virsh attach-interface web04 --type bridge --source br0 --model virtio #临时
  3. virsh attach-interface web04 --type bridge --source br0 --model virtio --config #永久
  4. #剥离网卡
  5. detach-interface web04 --type bridge --mac +地址
  6. #查看挂载硬盘
  7. virsh # domblklist web02
  8. Target Source
  9. ------------------------------------------------
  10. vda /opt/web02.qcow2
  11. hda -
  12. #查看mac地址
  13. virsh # domiflist web02
  14. Interface Type Source Model MAC
  15. -------------------------------------------------------
  16. vnet0 bridge br0 virtio 52:54:00:9e:c8:b7
  17. vnet3 bridge br0 virtio 52:54:00:f4:f3:9a
  18. 2.热添加内存
  19. #连接克隆
  20. virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web01 --memory 512,maxmemory=2048 --vcpus 1 --disk /opt/web01.qcow2 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
  21. #添加内存
  22. virsh setmem web02 1024M --live
  23. #登录kvm,查看
  24. free -m
  25. 3.添加cpu
  26. virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name web01 --memory 512,maxmemory=2048 --vcpus 1,maxvcpus=10 --disk /opt/web01.qcow2 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
  27. #进入kvm查看cpu核数
  28. lscpu
  29. #添加核数
  30. virsh setvcpus web02 2

kvm磁盘管理的更多相关文章

  1. Kvm--02 安装centos6系统 ,kvm磁盘管理

    目录 1.安装一个CentOS6的系统的虚拟主机 2.虚拟机的备份 3.企业案例: 4.Kvm磁盘管理 1.安装一个CentOS6的系统的虚拟主机 #上传一个CenOS6系统的镜像到/opt目录下 [ ...

  2. 虚拟化技术之kvm磁盘管理工具qemu-img

    在前边的博客中,我们大致了解了virsh这个工具对kvm虚拟机的一些操作,回顾请参考https://www.cnblogs.com/qiuhom-1874/tag/virsh/:今天我们来了解下kvm ...

  3. KVM -> 虚拟机磁盘管理_03

    1.KVM磁盘管理 1.KVM qcow2.raw.vmdk等镜像格式说明:http://blog.csdn.net/zhengmx100/article/details/53887162 raw: ...

  4. 如何在KVM中管理存储池

    来自:http://blog.csdn.net/my2005lb/article/details/8635661 KVM平台以存储池的形式对存储进行统一管理,所谓存储池可以理解为本地目录.通过远端磁盘 ...

  5. KVM镜像管理利器-guestfish使用详解

    原文  http://xiaoli110.blog.51cto.com/1724/1568307   KVM镜像管理利器-guestfish使用详解 本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8 ...

  6. libguestfs-tools 虚拟机磁盘管理工具

    libguestfs-tools虚拟机磁盘管理工具: 官网:http://libguestfs.org/ 这是一个非常强大的虚拟机磁盘管理工具,该工具包内包含的工具有virt-cat.virt-df. ...

  7. [原创]KVM虚拟化管理平台的实现

    KVM虚拟化管理平台的实现 源码链接:https://github.com/wsjhk/IaaS_admin.git 根据KVM虚拟化管理的要求,设计并实现网页操作管理KVM虚拟机.设计原理架构如下图 ...

  8. kvm虚拟机管理 系统自动化安装

    原创博文安装配置KVM http://www.cnblogs.com/elvi/p/7718574.htmlweb管理kvm http://www.cnblogs.com/elvi/p/7718582 ...

  9. kvm虚拟机管理基础

    部署 KVM 虚拟机 a.kvm 安装 环境:centos7,cpu 支持虚拟化,关闭 selinux,关闭 firewalld yum install libvirt virt-install qe ...

随机推荐

  1. Idea创建maven项目,报错xxx already exists in VFS

    1.问题描述: 我打算在父级maven项目中创建子级project,但是一直报错如下: 2.stackover flow中找到了问题的答案, 地址:https://stackoverflow.com/ ...

  2. 11-kubernetes RBAC 及授权

    目录 RBAC role 和 clusterrole rolebinding 和 clusterrolebinding 公共权限 clusterrole user 创建测试 创建role案例 创建 r ...

  3. 小白都会用的免配置 Aria2 图形界面版免费开源下载软件PDM

    如今的迅雷真的越发让人失望,好好的下载软件变成了广告浏览器,最近又关停了“远程下载”功能,就算花钱加入会员,很多资源现在也不允许下载了,鸡肋的很. 然而除了 IDM.Folx.qBitorrent 等 ...

  4. Java 从入门到进阶之路(十一)

    之前的文章我们介绍了一下 Java 中的继承,接下来我们继续看一下 Java 中的继承. 在有些时候,我们通过类继承的方式可以获取父类的方法,但是有些时候父类为我们提供的方法并不完全符合我们的需求,这 ...

  5. 【集合系列】- 深入浅出的分析 Properties

    一.摘要 在集合系列的第一章,咱们了解到,Map 的实现类有 HashMap.LinkedHashMap.TreeMap.IdentityHashMap.WeakHashMap.Hashtable.P ...

  6. 用正则表达式来验证QQ号是否合法

    import re #首先我们定义一个函数利用正则表达式来获取QQ号 def testQQ(qq): pattern = re.compile('[1-9][0-9]{4,10}$') result ...

  7. hibernate查询方式(三)

    QBC查询 (Query By Criteria) *****QBC查询有三个特点 **查询时不写sql语句 而是用方法来查询 **操作实体类和属性 **通过criteria对象来实现 1.查询所有 ...

  8. 侠梦说pinpoint--界面上的图标之AgetnInfo数据研究

    前言 在启动一个挂载pinpoint的springboot项目的时候,界面上显示成了jboss的图标,所以今天研究了一下这个数据是怎么来的. 我们知道不同图标和服务类型有关,服务不同,图标就不同,这在 ...

  9. 【Springboot】Springboot整合Jasypt,让配置信息安全最优雅方便的方式

    1 简介 在上一篇文章中,介绍了Jasypt及其用法,具体细节可以查看[Java库]如何使用优秀的加密库Jasypt来保护你的敏感信息?.如此利器,用之得当,那将事半功倍.本文将介绍Springboo ...

  10. Redis 命令执行过程(下)

    在上一篇文章中<Redis 命令执行过程(上)>中,我们首先了解 Redis 命令执行的整体流程,然后细致分析了从 Redis 启动到建立 socket 连接,再到读取 socket 数据 ...