本文共 4798 字,大约阅读时间需要 15 分钟。
Guest virtual machine installation
===================================================== 使用virt-install创建虚拟机 [root@uplook ~]# virt-install --help [root@uplook ~]# mkdir -pv /vmdisk #创建磁盘镜像保存目录 创建虚拟机vm00(已测OK): 注:\换行符的后面不能有空格。virt-install \ --name=vm00 \ --ram 1024 \ --vcpus=1 \ --disk path=/vmdisk/vm00.img,size=5,format=qcow2 \ --vnc --vncport=5910 --vnclisten=0.0.0.0 \ --location=ftp://192.168.10.7/dvd 创建pc虚拟机(金测OK,安装并进入系统) virt-install \ --graphics vnc,listen=0.0.0.0,port=5920,keymap='en-us' \ --name=pc \ --ram=512 \ --vcpus=1 \ --disk path=/var/lib/libvirt/images/pc.img,size=3,format=qcow2 \ --location=ftp://192.168.10.7/dvd 163网易centos7源: 创建虚拟机vm01(已测OK): 注:本例采用163网络源共享的centos7.3安装文件,启动速度很慢。virt-install \ --name=vm01 \ --ram 1200 \ --vcpus=1 \ --disk path=/vmdisk/vm01.img,size=5 \ --vnc --vncport=5911 --vnclisten=0.0.0.0 \ --location= 创建虚拟机vm02(已测OK):virt-install \ --name=vm02 \ --ram 1024 \ --vcpus=1 \ --disk path=/vmdisk/vm02.img,size=7 \ --vnc --vncport=5912 --vnclisten=0.0.0.0 \ --cdrom /opt/rhel73.iso 创建虚拟机vm03(已测OK):virt-install \ --name=vm03 \ --ram=512 \ --vcpus=1 \ --arch=x86_64 \ --os-type=linux \ --os-variant=rhel6 \ --hvm \ --bridge=virbr0 \ --disk path=/vmdisk/vm03.img,size=7 \ --cdrom /opt/rhel65.iso \ --graphics vnc,listen=0.0.0.0,port=5920,password=123 \ --extra-args="ks=ftp://172.16.8.100/rhel6.5.ks" --noautoconsole ---------------------------------------------------------------------- 创建虚拟机的练习: [root@uplook ~]# /usr/sbin/virt-install \ 后面不能有空格 --graphics vnc \ --name=uplook \ --ram=512 \ --vcpus=1 \ --arch=x86_64 \ --os-type=linux \ --os-variant=rhel6 \ --hvm \ --disk path=/var/lib/libvirt/images/uplook.img,size=8,format=qcow2 \ --bridge=virbr0 \ --location=ftp://172.16.8.100/rhel6.4 \ --extra-args="ks=ftp://172.16.8.100/rhel6.4.ks" [root@uplook ~]# /usr/sbin/virt-install \ --graphics vnc,listen=0.0.0.0,port=5920,password=123 \ --noautoconsole \ --name=uplook1 \ --ram=512 \ --vcpus=1 \ --arch=x86_64 \ --os-type=linux \ --os-variant=rhel6 \ --hvm \ --disk path=/var/lib/libvirt/images/uplook1.img,size=8,format=qcow2 \ --bridge=virbr0 \ --location=ftp://172.16.8.100/rhel6.4 \ --extra-args="ks=ftp://172.16.8.100/rhel6.4.ks" [root@uplook ~]# /usr/sbin/virt-install \ --nographics \ --name=centos7-1 \ --ram=512 \ --vcpus=1 \ --arch=x86_64 \ --os-type=linux \ --hvm \ --disk path=/var/lib/libvirt/images/centos7-1.img,size=8,format=qcow2 \ --location= \ --extra-args="ks= console=ttyS0"虚拟机相关文件 [root@uplook ~]# virsh list --all Id Name State ---------------------------------------------------- - node1 shut off - uplook shut off1. 配置文件虚拟机配置文件xml [root@uplook ~]# ls /etc/libvirt/qemu autostart networks node1.xml uplook.xml [root@uplook ~]# virsh edit uplook [root@uplook ~]# virsh dumpxml uplook > newhost 设置自动运行vm [root@uplook ~]# virsh autostart uplook Domain uplook marked as autostarted [root@uplook ~]# ls /etc/libvirt/qemu/autostart/ uplook.xml [root@uplook ~]# ll /etc/libvirt/qemu/autostart/uplook.xml lrwxrwxrwx. 1 root root 29 Jul 30 13:46 /etc/libvirt/qemu/autostart/uplook.xml -> /etc/libvirt/qemu/uplook.xml网络配置文件xml [root@uplook ~]# ls /etc/libvirt/qemu/networks/ autostart default.xml [root@uplook ~]# [root@uplook ~]# ls /etc/libvirt/qemu/networks/autostart/ default.xml存储池配置文件xml [root@uplook ~]# ls /etc/libvirt/storage/ autostart default.xml [root@uplook ~]# ls /etc/libvirt/storage/autostart/ default.xml2. 镜像文件[磁盘文件] [root@uplook ~]# ls /var/lib/libvirt/images/ node1.img uplook.img [root@uplook ~]# man virt-install General Options: Installation Method Options: Storage Configuration: Networking Configuration: Graphics Configuration: Device Options: Virtualization Platform Options: -v, --hvm This guest should be a fully virtualized guest -p, --paravirt This guest should be a paravirtualized guest --arch=ARCH The CPU architecture to simulate sparse稀疏模式 分10G不一定立马分配 spice virt-install --connect URI 连接其他机器安装系统 -c maxmemory 最大内存 -vcpus 5,maxcpus=2,cpuset=1-4,6,8指定处理器 -l url -x 扩展参数 kickstart --------------------------------------------本文转自rshare 51CTO博客,原文链接:http://blog.51cto.com/1364952/1964941,如需转载请自行联系原作者