简体   繁体   English

OpenStack:使用原始磁盘格式启动实例

[英]OpenStack: launch instance with raw disk format

I have some headache with my OpenStack. 我对OpenStack感到有些头痛。 What i'm trying to do is to create instance which disk is in RAW format instead of default qcow. 我正在尝试创建实例的磁盘为RAW格式,而不是默认的qcow。

My disk image from which I'm trying to create the instance is in raw format too. 我尝试从中创建实例的磁盘映像也是原始格式。 I've created the image via: 我通过以下方式创建了图像:

openstack image create --public --disk-format raw --container-format bare --file CentOS-7-x86_64-GenericCloud-1710.raw CentOS_7_raw

But when I launch instance from it I see that the disk is converted to Qcow2(v3) format. 但是,当我从中启动实例时,我看到磁盘已转换为Qcow2(v3)格式。

Is there any possibility to run an instance with raw format disk? 是否有可能使用原始格式的磁盘运行实例?

  1. Upload image to glance: 上传图片一目了然:

     # openstack image create --public --disk-format raw --container-format bare --file CentOS-7-x86_64-GenericCloud-1710.raw CentOS_7_raw +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | 9d9cf225d36976b25eba247cb5f85d89 | | container_format | bare | | created_at | 2017-11-13T20:27:39Z | | disk_format | raw | | file | /v2/images/8a18ee68-1d9e-4a2a-8277-ff29035d7011/file | | id | 8a18ee68-1d9e-4a2a-8277-ff29035d7011 | | min_disk | 0 | | min_ram | 0 | | name | CentOS_7_raw | | owner | 253f0c717bba45f8adf5c530b7194069 | | protected | False | | schema | /v2/schemas/image | | size | 8589934592 | | status | active | | tags | | | updated_at | 2017-11-13T20:28:01Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ 
  2. Change /etc/nova/nova.conf . 更改/etc/nova/nova.conf Update images_type parameter to raw : images_type参数更新为raw

     # VM Images format. If default is specified, then use_cow_images flag is used # instead of this one. (string value) # Allowed values: raw, qcow2, lvm, rbd, ploop, default #images_type=default images_type=raw 
  3. Restart nova: 重新启动nova:

     # openstack-service restart nova # openstack-service status nova MainPID=1485 Id=openstack-nova-api.service ActiveState=active MainPID=1500 Id=openstack-nova-cert.service ActiveState=active MainPID=1509 Id=openstack-nova-compute.service ActiveState=active MainPID=1483 Id=openstack-nova-conductor.service ActiveState=active MainPID=1525 Id=openstack-nova-consoleauth.service ActiveState=active MainPID=1481 Id=openstack-nova-novncproxy.service ActiveState=active MainPID=1511 Id=openstack-nova-scheduler.service ActiveState=active 
  4. Create instance: 创建实例:

     # nova boot --image 8a18ee68-1d9e-4a2a-8277-ff29035d7011 --nic net-id=e6db9b9e-4782-44dc-8d99-6bdb9744793d --key openstack --config-drive=True --flavor 3 raw +--------------------------------------+-----------------------------------------------------+ | Property | Value | +--------------------------------------+-----------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | instance-00000558 | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | adminPass | CTXhRYZv8bc3 | | config_drive | True | | created | 2017-11-13T20:36:15Z | | flavor | m1.medium (3) | | hostId | | | id | 0d7aaf0a-0b29-4c6e-b049-270beab7d9c2 | | image | CentOS_7_raw (8a18ee68-1d9e-4a2a-8277-ff29035d7011) | | key_name | openstack | | metadata | {} | | name | raw | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | 253f0c717bba45f8adf5c530b7194069 | | updated | 2017-11-13T20:36:15Z | | user_id | f8a7f21341624657b81c882431966265 | +--------------------------------------+-----------------------------------------------------+ 
  5. Check status: 检查状态:

     # nova list +--------------------------------------+------+--------+------------+-------------+-------------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+------+--------+------------+-------------+-------------------------+ | 0d7aaf0a-0b29-4c6e-b049-270beab7d9c2 | raw | ACTIVE | - | Running | network-1=192.168.0.139 | +--------------------------------------+------+--------+------------+-------------+-------------------------+ 
  6. Check image file: 检查图像文件:

     # qemu-img info /var/lib/nova/instances/0d7aaf0a-0b29-4c6e-b049-270beab7d9c2/disk image: /var/lib/nova/instances/0d7aaf0a-0b29-4c6e-b049-270beab7d9c2/disk file format: raw virtual size: 40G (42949672960 bytes) disk size: 8.0G # ls -alh /var/lib/nova/instances/0d7aaf0a-0b29-4c6e-b049-270beab7d9c2/disk -rw-r--r--. 1 qemu qemu 40G Nov 13 20:51 /var/lib/nova/instances/0d7aaf0a-0b29-4c6e-b049-270beab7d9c2/disk 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM