Openstack中qcow2镜像制作
2016-04-15 09:58
525 查看
1.首先从mirrors.aliyun.com网站下载所需要的iso文件,也可以直接从本地的iso文件夹中直接拷贝。
2.使用命令在所在目录创建镜像文件(此文件就是之后需要上传的镜像文件)
qemu-img create -f qcow2 ./test.qcow2 50G(镜像大小要和flavor匹配,不能随意配置)
#本例使用qcow2格式,镜像名字为test,大小为50G
3.写xml文件test.xml,其中cdrom为所选择的iso文件,修改好文件目录
<domain type='kvm'>
<name>test</name>
<memory>8388608</memory>
<currentMemory>8388608</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/qcow2/test.qcow2'/>
<target dev='hda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/home/iso/CentOS-7-2.iso'/>
<target dev='hdb' bus='ide'/>
</disk>
<interface type='bridge'>
<source bridge='virbr0'/>
<model type="virtio"/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>
</devices>
</domain>
4.创建虚拟机
a. virsh define test.xml #定义xml文件
b. virsh start test #启动test虚拟机
5.使用VNC登录然后安装(此过程也是iso写入qcow2的过程)
c.virsh vncdisplay test #查看vnc端口
d. 使用VNC客户端登录虚拟机按Centos(Windows一样)步骤安装,直至安装成功。
e. 如果是windows镜像,需要安装virtio驱动
安装完毕后会发现网络连接不上,这是网卡驱动未更新的原因,
需要右键点击计算机——管理——设备管理器,会发现有感叹号的2个文件,右键点击以太网络适配器,选择更新驱动,选择手动安装,进入
E:/virtio-win/NetKVM/w2k8R2/amd64, 安装完毕后网络会自动连接上
6.关闭虚拟机(建议在虚拟机内部执行关机操作,否则有可能导致蓝屏)
virsh destroy test
7. 此test.qcow2就是我们所需要的镜像文件
8.上传镜像至glance
glance image-create --name centos_test --disk-format=qcow2 --container-format=bare --is-public=True --file=/home/qcow2/test.qcow2
#上传名字为centos_test的镜像(和test.qcow2一模一样)
上传完毕后使用 glance image-list 命令进行查看是否成功
2.使用命令在所在目录创建镜像文件(此文件就是之后需要上传的镜像文件)
qemu-img create -f qcow2 ./test.qcow2 50G(镜像大小要和flavor匹配,不能随意配置)
#本例使用qcow2格式,镜像名字为test,大小为50G
3.写xml文件test.xml,其中cdrom为所选择的iso文件,修改好文件目录
<domain type='kvm'>
<name>test</name>
<memory>8388608</memory>
<currentMemory>8388608</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='cdrom'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/home/qcow2/test.qcow2'/>
<target dev='hda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/home/iso/CentOS-7-2.iso'/>
<target dev='hdb' bus='ide'/>
</disk>
<interface type='bridge'>
<source bridge='virbr0'/>
<model type="virtio"/>
</interface>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen = '0.0.0.0' keymap='en-us'/>
</devices>
</domain>
4.创建虚拟机
a. virsh define test.xml #定义xml文件
b. virsh start test #启动test虚拟机
5.使用VNC登录然后安装(此过程也是iso写入qcow2的过程)
c.virsh vncdisplay test #查看vnc端口
d. 使用VNC客户端登录虚拟机按Centos(Windows一样)步骤安装,直至安装成功。
e. 如果是windows镜像,需要安装virtio驱动
安装完毕后会发现网络连接不上,这是网卡驱动未更新的原因,
需要右键点击计算机——管理——设备管理器,会发现有感叹号的2个文件,右键点击以太网络适配器,选择更新驱动,选择手动安装,进入
E:/virtio-win/NetKVM/w2k8R2/amd64, 安装完毕后网络会自动连接上
6.关闭虚拟机(建议在虚拟机内部执行关机操作,否则有可能导致蓝屏)
virsh destroy test
7. 此test.qcow2就是我们所需要的镜像文件
8.上传镜像至glance
glance image-create --name centos_test --disk-format=qcow2 --container-format=bare --is-public=True --file=/home/qcow2/test.qcow2
#上传名字为centos_test的镜像(和test.qcow2一模一样)
上传完毕后使用 glance image-list 命令进行查看是否成功
相关文章推荐
- 微软镜像下载
- 什么是OpenStack 开源的云计算管理平台项目
- 简述SQL Server 2005数据库镜像相关知识
- SQL Server 2005 镜像构建手册(sql2005数据库同步镜像方案)
- SQL Server误区30日谈 第7天 一个实例多个镜像和日志传送延迟
- SQL Server中避免触发镜像SUSPEND的N种方法
- SQLServer 镜像功能完全实现
- 图片旋转、鼠标滚轮缩放、镜像、切换图片js代码
- 使用RSYNC在服务器间镜像或者备份目录和文件
- SQL Server误区30日谈 第11天 镜像在检测到故障后瞬间就能故障转移
- python图像处理之镜像实现方法
- openstack(juno版)使用rsyslog转发日志
- OpenStack Murano Dashboard(Kilo)安装
- Openstack Murano(Kilo) 网络排错
- Openstack Murano(kilo)二次开发之添加Volume
- Openstack Horizon(kilo)二次开发之匿名访问View
- Ubuntu源码安装Openstack(一)
- Ubuntu源码安装Openstack(二)
- openstack开发之--zabbix被坑的地方
- vmware下安装rhel6.7