• kvm初体验之八:调整vm的vcpu, memory, disk大小


    假设host上创建的vm的名字为vm1

    1. 查看vm1domain information

    [root@tanghuimin thm]# virsh dominfo vm1

    Id: 10

    Name: vm1

    UUID: e2597379-5cc5-4ffa-0531-a073a81c5811

    OS Type: hvm

    State: running

    CPU(s): 1

    CPU time: 52.6s

    Max memory: 1048576 KiB

    Used memory: 1048576 KiB

    Persistent: yes

    Autostart: disable

    Managed save: no

    Security model: selinux

    Security DOI: 0

    Security label: system_u:system_r:svirt_t:s0:c790,c799 (enforcing)


    2. 修改vm1vcpu, memory

    1)实时修改vcpumemory

    virsh setvcpus vm1 xxx #数值不能超过vm1.xml中配置的vcpu

    virsh setmaxmem vm1 xxx #vm1处于shut off状态时才能设置成功

    virsh setmem vm1 xxx #数值不能超过maxmem


    2)配置文件修改vcpu, memory

    修改vm1的配置文件

    virsh edit vm1

    <memory>对应dominfo中的Max memory

    <currentMemory>对应dominfo中的Used memory

    <vcpu>对应dominfo中的CPU(s)

    <memory unit='KiB'>1048576</memory>

    <currentMemory unit='KiB'>1048576</currentMemory>

    <vcpu placement='static'>1</vcpu>

    vm1先关机再启动即可生效

    virsh destroy vm1

    virsh start vm1


    3. vm1扩展一个10Gdisk

    生成一个大小为10G的磁盘文件/vm/vm1-add

    dd if=/dev/zero of=/vm/vm1-add bs=1M count=10240

    修改vm1的配置文件

    virsh edit vm1

    vm1现有的磁盘文件为/vm/vm1

    <disk type='file' device='disk'>

    <driver name='qemu' type='raw' cache='none'/>

    <source file='/vm/vm1'/>

    <target dev='hda' bus='ide'/>

    <address type='drive' controller='0' bus='0' target='0' unit='0'/>

    </disk>

    在后面追加如下几行

    <disk type='file' device='disk'>

    <driver name='qemu' type='raw' cache='none'/>

    <source file='/vm/vm1-add'/>

    <target dev='hdb' bus='ide'/>

    <address type='drive' controller='0' bus='0' target='0' unit='1'/>

    </disk>

    vm1先关机再启动即可生效

    virsh destroy vm1

    virsh start vm1

    查看vm1的磁盘信息

    root@localhost ~]# fdisk -l| grep Disk

    Disk /dev/sda: 2147 MB, 2147483648 bytes

    Disk identifier: 0x000e3e47

    Disk /dev/sdb: 10.7 GB, 10737418240 bytes

    Disk identifier: 0x00000000

    Disk /dev/mapper/VolGroup-lv_root: 1405 MB, 1405091840 bytes

    Disk identifier: 0x00000000

    Disk /dev/mapper/VolGroup-lv_swap: 213 MB, 213909504 bytes

    Disk identifier: 0x00000000


  • 相关阅读:
    day10 基本数据类型介绍-整形的魔法
    python 快捷键
    F5负载均衡 简要原理解析以及命令行命令
    Python之路(2)
    Pycharm的安装
    集合框架(Collection和Collections的区别)
    集合框架(04)HashMap扩展知识
    集合框架(04)HashMap
    集合框架(03)泛型
    MVC
  • 原文地址:https://www.cnblogs.com/tanghuimin0713/p/4550407.html
Copyright © 2020-2023  润新知