切换风格

Wizard Sky California Sunset glow Black Cloud Beige Dragon Lavender NewYear City Snow Flowers London
收藏本站XSS平台字符串转换jsfuck
324 ZZ KVM –virt[复制链接]
发表于 2012-10-13 14:25:13 | 显示全部楼层 |!read_mode!
安装
  1. root@Dis9Team:/vm# apt-get install virtinst
复制代码
启动

  1. root@Dis9Team:/vm# virsh
  2. Welcome to virsh, the virtualization interactive terminal.

  3. Type:  'help' for help with commands
  4.        'quit' to quit

  5. virsh #
复制代码
安装一个虚拟机

  1. root@Dis9Team:/vm# virt-install --name ubuntu --ram 512 --disk path=linux.img --cdrom /ubuntu-11.04-desktop-i386.iso

  2. Starting install...
  3. Creating domain...                                       |    0 B     00:00     
  4. WARNING  Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package.
  5. Domain installation still in progress. You can reconnect to
  6. the console to complete the installation process.
  7. root@Dis9Team:/vm#
复制代码



安装virt-viewer

  1. root@Dis9Team:/vm# apt-get install virt-viewer
复制代码


链接虚拟机
  1. root@Dis9Team:/vm# virt-viewer -r ubuntu
复制代码




配置文件
  1. root@Dis9Team:/# cd /etc/libvirt/qemu
  2. root@Dis9Team:/etc/libvirt/qemu# ls
  3. networks  ubuntu.xml
  4. root@Dis9Team:/etc/libvirt/qemu# cat ubuntu.xml
  5. <domain type='kvm'>
  6.   <name>ubuntu</name>
  7.   <uuid>5c7b56a0-a568-7a60-9dbb-ab0bf347b7e6</uuid>
  8.   <memory>524288</memory>
  9.   <currentMemory>524288</currentMemory>
  10.   <vcpu>1</vcpu>
  11.   <os>
  12.     <type arch='i686' machine='pc-0.14'>hvm</type>
  13.     <boot dev='hd'/>
  14.   </os>
  15.   <features>
  16.     <acpi/>
  17.     <apic/>
  18.     <pae/>
  19.   </features>
  20.   <clock offset='utc'/>
  21.   <on_poweroff>destroy</on_poweroff>
  22.   <on_reboot>restart</on_reboot>
  23.   <on_crash>restart</on_crash>
  24.   <devices>
  25.     <emulator>/usr/bin/kvm</emulator>
  26.     <disk type='file' device='disk'>
  27.       <driver name='qemu' type='raw'/>
  28.       <source file='/vm/linux.img'/>
  29.       <target dev='hda' bus='ide'/>
  30.       <address type='drive' controller='0' bus='0' unit='0'/>
  31.     </disk>
  32.     <disk type='block' device='cdrom'>
  33.       <driver name='qemu' type='raw'/>
  34.       <target dev='hdc' bus='ide'/>
  35.       <readonly/>
  36.       <address type='drive' controller='0' bus='1' unit='0'/>
  37.     </disk>
  38.     <controller type='ide' index='0'>
  39.       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
  40.     </controller>
  41.     <interface type='bridge'>
  42.       <mac address='52:54:00:5e:3b:67'/>
  43.       <source bridge='br0'/>
  44.       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
  45.     </interface>
  46.     <serial type='pty'>
  47.       <target port='0'/>
  48.     </serial>
  49.     <console type='pty'>
  50.       <target type='serial' port='0'/>
  51.     </console>
  52.     <input type='mouse' bus='ps2'/>
  53.     <graphics type='vnc' port='-1' autoport='yes'/>
  54.     <video>
  55.       <model type='cirrus' vram='9216' heads='1'/>
  56.       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
  57.     </video>
  58.     <memballoon model='virtio'>
  59.       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  60.     </memballoon>
  61.   </devices>
  62. </domain>
  63. root@Dis9Team:/etc/libvirt/qemu#
复制代码


列出虚拟机

  1. root@Dis9Team:/etc/libvirt/qemu# virsh
  2. Welcome to virsh, the virtualization interactive terminal.

  3. Type:  'help' for help with commands
  4.        'quit' to quit

  5. virsh # list
  6. Id Name                 State
  7. ----------------------------------
  8.   1 ubuntu               running

  9. virsh #
复制代码



状态是正在运行

关闭电源

  1. virsh # destroy ubuntu
  2. Domain ubuntu destroyed

  3. virsh # list
  4. Id Name                 State
  5. ----------------------------------

  6. virsh #
复制代码



启动已有虚拟机

  1. virsh # start ubuntu
  2. Domain ubuntu started

  3. virsh # list
  4. Id Name                 State
  5. ----------------------------------
  6.   2 ubuntu               running

  7. virsh #
复制代码



移除虚拟机
  1. virsh # undefine 虚拟机名字
复制代码


根据主机配置文档添加虚拟机
  1. virsh # define /x.xml
复制代码


SSH链接

必须是安装好的LINUX

  1. root@Dis9Team:/vm# virt-viewer -c qemu+ssh://用户@ip/system ubuntu
复制代码

编辑虚拟机默认方式是VI

  1. root@Dis9Team:/vm# virsh edit ubuntu
复制代码





附件: 你需要登录才可以下载或查看附件。没有帐号?加入Team
操千曲而后晓声,观千剑而后识器。

代码区

GMT+8, 2020-10-2 03:20

Powered by Discuz! X2

© 2001-2018 Comsenz Inc.

回顶部