Anda dapat boot instance dari volume bukan image.
Untuk menyelesaikan tugas ini, gunakan parameter ini pada perintah: openstack server create:
Tugas | openstack server create parameter | Informasi |
---|---|---|
Boot sebuah instance dari sebuah image dan menghubungkan volume non-bootable. | --block-device-mapping |
Boot instance dari image dan menghubungkan volume non-bootable |
Membuat volume dari sebuah image dan boot sebuah instance dari volume tersebut. | --volume |
Membuat volume dari image dan boot instance |
Boot from an existing source volume or snapshot. | --volume |
Membuat volume dari image dan boot instance |
Catatan
Untuk menghubungkan volume pada instance berjalan, lihat :ref: Attach_a_volume_to_an_instance.
Membuat volume non-bootable dan menghubungkan dimana volume ke sebuah instance dimana Anda boot dari sebuah image.
Untuk membuat volume non-bootable, jangan menciptakannya dari sebuah image. Volume harus sepenuhnya kosong tanpa tabel partisi dan tidak ada sistem file.
Membuat volume non-bootable.
$ openstack volume create --size 8 my-volume
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| consistencygroup_id | None |
| created_at | 2017-06-10T13:45:19.588269 |
| description | None |
| encrypted | False |
| id | e77b30a9-2c1b-4f3a-b161-e09685296a83 |
| migration_status | None |
| multiattach | False |
| name | my-volume |
| properties | |
| replication_status | disabled |
| size | 8 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| type | lvmdriver-1 |
| updated_at | None |
| user_id | 07a3f50419714d90b55edb6505b7cc1d |
+---------------------+--------------------------------------+
Daftar volume.
$ openstack volume list
+--------------------------------------+--------------+-----------+------+-------------+
| ID | Display Name | Status | Size | Attached to |
+--------------------------------------+--------------+-----------+------+-------------+
| e77b30a9-2c1b-4f3a-b161-e09685296a83 | my-volume | available | 8 | |
+--------------------------------------+--------------+-----------+------+-------------+
Boot an instance from an image and attach the empty volume to the
instance, use the --block-device-mapping
parameter.
Sebagai contoh:
$ openstack server create --flavor FLAVOR --image IMAGE \
--block-device-mapping DEV-NAME=ID:TYPE:SIZE:DELETE_ON_TERMINATE \
NAME
Parameter adalah:
--flavor
The flavor ID or name.
--image
The image ID or name.
--block-device-mapping
DEV-NAME=ID:TYPE:SIZE:DELETE_ON_TERMINATE
The device name to attch the volume when the instance is booted.
ID dari objek sumber.
Which type object to create the volume.
volume
chooses volume to create. snapshot
chooses snapshot
to create.
The size(GB) of the volume that is created.
What to do with the volume when the instance is terminated.
false
does not delete the volume. true
deletes the
volume.
NAME
. Nama untuk server.
$ openstack server create --flavor 2 --image c76cf108-1760-45aa-8559-28176f2c0530 \
--block-device-mapping \
myVolumeAttach=e77b30a9-2c1b-4f3a-b161-e09685296a83:volume:8:false \
myInstanceWithVolume
+--------------------------------------+--------------------------------------------+
| Field | Value |
+--------------------------------------+--------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | instance-00000004 |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | UAwJJ7FZWxmA |
| config_drive | |
| created | 2017-06-10T13:50:47Z |
| flavor | m1.small (2) |
| hostId | |
| id | 555cf3e2-9ba3-46bf-9aa5-0a0c73d5b538 |
| image | cirros-0.3.5-x86_64-uec (c76cf108-1760-... |
| key_name | None |
| name | InstanceWithVolume |
| os-extended-volumes:volumes_attached | [{u'id': u'e77b30a9-2c1b-4f3a-b161-e096... |
| progress | 0 |
| project_id | ff903e4825c74f8dbc1aea6432e4f2fd |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| updated | 2017-06-10T13:50:48Z |
| user_id | 07a3f50419714d90b55edb6505b7cc1d |
+--------------------------------------+--------------------------------------------+
Anda dapat membuat volume dari sebuah image, volume, atau snapshot yang ada. Prosedur ini menunjukkan Anda bagaimana untuk membuat volume dari sebuah image, dan menggunakan volume untuk boot sebuah instance.
Daftar image yang tersedia.
$ openstack image list
+-----------------+---------------------------------+--------+
| ID | Name | Status |
+-----------------+---------------------------------+--------+
| dfcd8407-486... | Fedora-x86_64-20-20131211.1-sda | active |
| c76cf108-176... | cirros-0.3.5-x86_64-uec | active |
| 02d6b27f-40b... | cirros-0.3.5-x86_64-uec-kernel | active |
| 47b90a42-8f4... | cirros-0.3.5-x86_64-uec-ramdisk | active |
+-----------------+---------------------------------+--------+
Perhatikan ID dari image yang ingin Anda gunakan untuk membuat volume.
Jika Anda ingin membuat volume ke backend penyimpanan tertentu, Anda perlu menggunakan image yang memiliki properti cinder_img_volume_type. Dalam hal ini, volume baru akan dibuat sebagai tipe volume *storage_backend1 *.
$ openstack image show dfcd8407-4865-4d82-93f3-7fef323a5951
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | eb9139e4942121f22bbc2afc0400b2a4 |
| container_format | bare |
| created_at | 2017-06-10T06:46:26Z |
| disk_format | qcow2 |
| file | /v2/images/dfcd8407-4865-4d82-93f3-7fef323a5951/file |
| id | dfcd8407-4865-4d82-93f3-7fef323a5951 |
| min_disk | 0 |
| min_ram | 0 |
| name | Fedora-x86_64-20-20131211.1-sda |
| owner | 5ed8a204e27d462a8709bc8ec491e873 |
| protected | False |
| schema | /v2/schemas/image |
| size | 25165824 |
| status | active |
| tags | |
| updated_at | 2017-06-10T13:36:55Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
Daftar rasa yang tersedia.
$ openstack flavor list
+-----+-----------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is_Public |
+-----+-----------+-------+------+-----------+-------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | 1 | True |
| 2 | m1.small | 2048 | 20 | 0 | 1 | True |
| 3 | m1.medium | 4096 | 40 | 0 | 2 | True |
| 4 | m1.large | 8192 | 80 | 0 | 4 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | 8 | True |
+-----+-----------+-------+------+-----------+-------+-----------+
Perhatikan ID dari rasa yang ingin Anda gunakan untuk membuat volume.
Buat volume bootable dari sebuah image. Cinder membuat bootable volume saat parameter --image
dilewatkan.
$ openstack volume create --image IMAGE_ID --size SIZE_IN_GB bootable_volume
Create a VM from previously created bootable volume,
use the --volume
parameter. The volume is not
deleted when the instance is terminated.
$ openstack server create --flavor 2 --volume VOLUME_ID \
myInstanceFromVolume
+--------------------------------------+----------------------------------+
| Field | Value |
+--------------------------------------+----------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | instance-00000005 |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | dizZcBMnWH8i |
| config_drive | |
| created | 2017-06-10T14:15:10Z |
| flavor | m1.small (2) |
| hostId | |
| id | 7074c21a-22b3-4e91-9ea1-6a22c... |
| image | |
| key_name | None |
| name | myInstanceFromVolume |
| os-extended-volumes:volumes_attached | [{u'id': u'3da01e5a-7d81-4a34... |
| progress | 0 |
| project_id | ff903e4825c74f8dbc1aea6432e4f2fd |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| updated | 2017-06-10T14:15:11Z |
| user_id | 07a3f50419714d90b55edb6505b7cc1d |
+--------------------------------------+----------------------------------+
Daftar volume untuk melihat volume bootable dan yang melekat instance myInstanceFromVolume
.
$ openstack volume list
+---------------------+-----------------+--------+------+---------------------------------+
| ID | Display Name | Status | Size | Attached to |
+---------------------+-----------------+--------+------+---------------------------------+
| 3da01e5a-7d81-4a34- | bootable_volume | in-use | 2 | Attached to myInstanceFromVolume|
| a182-1958d10f7758 | | | | on /dev/vda |
+---------------------+-----------------+--------+------+---------------------------------+
To attach swap or ephemeral disk to an instance, you need create new flavor first. This procedure shows you how to boot an instance with a 512 MB swap disk and 2 GB ephemeral disk.
Create a new flavor.
$ openstack flavor create --vcpus 1 --ram 64 --disk 1 \
--swap 512 --ephemeral 2 my_flavor
Catatan
Flavor mendefinisikan swap maksimum dan ukuran disk ephemeral (tidal kekal). Anda tidak dapat melebihi nilai-nilai maksimum.
Create a server with 512 MB swap disk and 2 GB ephemeral disk.
$ openstack server create --image IMAGE_ID --flavor \
my_flavor NAME
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.