OpenStack通过ISO镜像安装系统

1、上传镜像

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack image create "centos8"  --disk-format iso --container-format bare --public --file ~/Downloads/CentOS-8.1.1911-x86_64-dvd1.iso
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                                                                                                                                                                                                                                                                         |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 8d0573c5fb5444007936b652d8c6724d                                                                                                                                                                                                                                                                                                                                                                                                              |
| container_format | bare                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| created_at       | 2020-03-16T12:48:07Z                                                                                                                                                                                                                                                                                                                                                                                                                          |
| disk_format      | iso                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| file             | /v2/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/file                                                                                                                                                                                                                                                                                                                                                                                          |
| id               | 0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af                                                                                                                                                                                                                                                                                                                                                                                                          |
| min_disk         | 0                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| min_ram          | 0                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| name             | centos8                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| owner            | 5df4e0c1c68647ef800e7904d455b58d                                                                                                                                                                                                                                                                                                                                                                                                              |
| properties       | direct_url='rbd://ec41ddb8-4400-4595-8687-21293e28204d/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/snap', locations='[{u'url': u'rbd://ec41ddb8-4400-4595-8687-21293e28204d/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/snap', u'metadata': {}}]', os_hash_algo='sha512', os_hash_value='4adc991714e23196f0eb4e01b993658175dce2726d1c9794f7b38a8449ee521a20be80921de5a8cf51a3b66a56391c43a371480d16b5d8d0196cfd9140a19be6', os_hidden='False' |
| protected        | False                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| schema           | /v2/schemas/image                                                                                                                                                                                                                                                                                                                                                                                                                             |
| size             | 7554990080                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| status           | active                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| tags             |                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| updated_at       | 2020-03-16T14:15:34Z                                                                                                                                                                                                                                                                                                                                                                                                                          |
| virtual_size     | None                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| visibility       | public                                                                                                                                                                                                                                                                                                                                                                                                                                        |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 

2、创建实例

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack server create --flavor DT-L-1c1g40gD --image 'ISO CentOS 8.1.1911' \
--nic net-id=24333c1d-001b-4898-9c30-994a20b57cb1,v4-fixed-ip=172.30.200.205 \
--nic net-id=58ba4366-ecc5-46f6-8898-8b8e743797d6,v4-fixed-ip=172.25.200.205 \
--nic net-id=67ca0cc2-68f9-4aee-b059-4666e2721dfa,v4-fixed-ip=172.20.200.205 \
--security-group d9386462-0eae-43c1-b815-f999fa3cd833 \
--key-name lookback \
'测试CentOS-8-ISO镜像'
+-------------------------------------+------------------------------------------------------------+
| Field                               | Value                                                      |
+-------------------------------------+------------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                     |
| OS-EXT-AZ:availability_zone         | nova                                                       |
| OS-EXT-SRV-ATTR:host                | None                                                       |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                                       |
| OS-EXT-SRV-ATTR:instance_name       | instance-000008bc                                          |
| 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                           | 5z2hq3zJesxk                                               |
| config_drive                        |                                                            |
| created                             | 2020-03-16T14:26:32Z                                       |
| flavor                              | DT-L-1c1g40gD (101)                                        |
| hostId                              |                                                            |
| id                                  | 2a25cc0a-8d71-481b-911c-669cdcbabf7a                       |
| image                               | ISO CentOS 8.1.1911 (0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af) |
| key_name                            | lookback                                                   |
| name                                | 测试CentOS-8-ISO镜像                                       |
| progress                            | 0                                                          |
| project_id                          | 5df4e0c1c68647ef800e7904d455b58d                           |
| properties                          |                                                            |
| security_groups                     | name='d9386462-0eae-43c1-b815-f999fa3cd833'                |
| status                              | BUILD                                                      |
| updated                             | 2020-03-16T14:26:34Z                                       |
| user_id                             | e885c093b3144cc6abcd19ff1c300730                           |
| volumes_attached                    |                                                            |
+-------------------------------------+------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 

3、添加空白的卷作为系统安装盘

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack volume create --size 40 --bootable 测试CentOS-8-ISO镜像 
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2020-03-16T14:24:48.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 5cbf6fff-df8c-4ca0-a94b-0154c838dca8 |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | 测试CentOS-8-ISO镜像                 |
| properties          |                                      |
| replication_status  | None                                 |
| size                | 40                                   |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | None                                 |
| updated_at          | None                                 |
| user_id             | e885c093b3144cc6abcd19ff1c300730     |
+---------------------+--------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 

4、将新建的空白卷添加到刚才创建的实例中

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack server add volume '测试CentOS-8-ISO镜像' '测试CentOS-8-ISO镜像' --device /dev/vda

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack server show 测试CentOS-8-ISO镜像
+-------------------------------------+------------------------------------------------------------------+
| Field                               | Value                                                            |
+-------------------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                           |
| OS-EXT-AZ:availability_zone         | nova                                                             |
| OS-EXT-SRV-ATTR:host                | 1063745-compute6                                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | 1063745-compute6.dtops.cc                                        |
| OS-EXT-SRV-ATTR:instance_name       | instance-000008bc                                                |
| OS-EXT-STS:power_state              | Running                                                          |
| OS-EXT-STS:task_state               | None                                                             |
| OS-EXT-STS:vm_state                 | active                                                           |
| OS-SRV-USG:launched_at              | 2020-03-16T14:27:29.000000                                       |
| OS-SRV-USG:terminated_at            | None                                                             |
| accessIPv4                          |                                                                  |
| accessIPv6                          |                                                                  |
| addresses                           | NET-A=172.30.200.205; NET-B=172.25.200.205; NET-C=172.20.200.205 |
| config_drive                        |                                                                  |
| created                             | 2020-03-16T14:26:32Z                                             |
| flavor                              | DT-L-1c1g40gD (101)                                              |
| hostId                              | b890e0492d59bc71d847d4c861303f16c5e4ee82865f0a80634ef6a8         |
| id                                  | 2a25cc0a-8d71-481b-911c-669cdcbabf7a                             |
| image                               | ISO CentOS 8.1.1911 (0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af)       |
| key_name                            | lookback                                                         |
| name                                | 测试CentOS-8-ISO镜像                                             |
| progress                            | 0                                                                |
| project_id                          | 5df4e0c1c68647ef800e7904d455b58d                                 |
| properties                          |                                                                  |
| security_groups                     | name='放行进出公网'                                              |
|                                     | name='放行进出公网'                                              |
|                                     | name='放行进出公网'                                              |
| status                              | ACTIVE                                                           |
| updated                             | 2020-03-16T14:27:29Z                                             |
| user_id                             | e885c093b3144cc6abcd19ff1c300730                                 |
| volumes_attached                    | id='5cbf6fff-df8c-4ca0-a94b-0154c838dca8'                        |
+-------------------------------------+------------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 
[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack volume show 5cbf6fff-df8c-4ca0-a94b-0154c838dca8
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                          | Value                                                                                                                                                                                                                                                                                                                   |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attachments                    | [{'server_id': '2a25cc0a-8d71-481b-911c-669cdcbabf7a', 'attachment_id': '40038bf8-e4a0-4e78-ab1d-cf7c61f25087', 'attached_at': '2020-03-16T14:29:00.000000', 'host_name': '1063745-compute6', 'volume_id': '5cbf6fff-df8c-4ca0-a94b-0154c838dca8', 'device': '/dev/vda', 'id': '5cbf6fff-df8c-4ca0-a94b-0154c838dca8'}] |
| availability_zone              | nova                                                                                                                                                                                                                                                                                                                    |
| bootable                       | true                                                                                                                                                                                                                                                                                                                    |
| consistencygroup_id            | None                                                                                                                                                                                                                                                                                                                    |
| created_at                     | 2020-03-16T14:24:48.000000                                                                                                                                                                                                                                                                                              |
| description                    | None                                                                                                                                                                                                                                                                                                                    |
| encrypted                      | False                                                                                                                                                                                                                                                                                                                   |
| id                             | 5cbf6fff-df8c-4ca0-a94b-0154c838dca8                                                                                                                                                                                                                                                                                    |
| migration_status               | None                                                                                                                                                                                                                                                                                                                    |
| multiattach                    | False                                                                                                                                                                                                                                                                                                                   |
| name                           | 测试CentOS-8-ISO镜像                                                                                                                                                                                                                                                                                                    |
| os-vol-host-attr:host          | 1063708-controller1@ceph#ceph                                                                                                                                                                                                                                                                                           |
| os-vol-mig-status-attr:migstat | None                                                                                                                                                                                                                                                                                                                    |
| os-vol-mig-status-attr:name_id | None                                                                                                                                                                                                                                                                                                                    |
| os-vol-tenant-attr:tenant_id   | 5df4e0c1c68647ef800e7904d455b58d                                                                                                                                                                                                                                                                                        |
| properties                     |                                                                                                                                                                                                                                                                                                                         |
| replication_status             | None                                                                                                                                                                                                                                                                                                                    |
| size                           | 40                                                                                                                                                                                                                                                                                                                      |
| snapshot_id                    | None                                                                                                                                                                                                                                                                                                                    |
| source_volid                   | None                                                                                                                                                                                                                                                                                                                    |
| status                         | in-use                                                                                                                                                                                                                                                                                                                  |
| type                           | None                                                                                                                                                                                                                                                                                                                    |
| updated_at                     | 2020-03-16T14:29:00.000000                                                                                                                                                                                                                                                                                              |
| user_id                        | e885c093b3144cc6abcd19ff1c300730                                                                                                                                                                                                                                                                                        |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack image show 0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 8d0573c5fb5444007936b652d8c6724d                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| container_format | bare                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| created_at       | 2020-03-16T12:48:07Z                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| disk_format      | iso                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| file             | /v2/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/file                                                                                                                                                                                                                                                                                                                                                                                                                              |
| id               | 0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| min_disk         | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| min_ram          | 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| name             | ISO CentOS 8.1.1911                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| owner            | 5df4e0c1c68647ef800e7904d455b58d                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| properties       | description='CentOS 8.1.1911 ISO镜像', direct_url='rbd://ec41ddb8-4400-4595-8687-21293e28204d/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/snap', locations='[{'url': 'rbd://ec41ddb8-4400-4595-8687-21293e28204d/images/0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af/snap', 'metadata': {}}]', os_hash_algo='sha512', os_hash_value='4adc991714e23196f0eb4e01b993658175dce2726d1c9794f7b38a8449ee521a20be80921de5a8cf51a3b66a56391c43a371480d16b5d8d0196cfd9140a19be6', os_hidden='False' |
| protected        | False                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| schema           | /v2/schemas/image                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| size             | 7554990080                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| status           | active                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| tags             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| updated_at       | 2020-03-16T14:22:36Z                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| virtual_size     | None                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| visibility       | public                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 

5、安装完毕之后,取消卷和之前的实例联系,并生成所需镜像

[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack server list --name='测试CentOS-8-ISO镜像'       
+--------------------------------------+----------------------+--------+------------------------------------------------------------------+---------------------+---------------+
| ID                                   | Name                 | Status | Networks                                                         | Image               | Flavor        |
+--------------------------------------+----------------------+--------+------------------------------------------------------------------+---------------------+---------------+
| 2a25cc0a-8d71-481b-911c-669cdcbabf7a | 测试CentOS-8-ISO镜像 | ACTIVE | NET-A=172.30.200.205; NET-B=172.25.200.205; NET-C=172.20.200.205 | ISO CentOS 8.1.1911 | DT-L-1c1g40gD |
+--------------------------------------+----------------------+--------+------------------------------------------------------------------+---------------------+---------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack server show '测试CentOS-8-ISO镜像'              
+-------------------------------------+------------------------------------------------------------------+
| Field                               | Value                                                            |
+-------------------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                           |
| OS-EXT-AZ:availability_zone         | nova                                                             |
| OS-EXT-SRV-ATTR:host                | 1063745-compute6                                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | 1063745-compute6.dtops.cc                                        |
| OS-EXT-SRV-ATTR:instance_name       | instance-000008bc                                                |
| OS-EXT-STS:power_state              | Running                                                          |
| OS-EXT-STS:task_state               | None                                                             |
| OS-EXT-STS:vm_state                 | active                                                           |
| OS-SRV-USG:launched_at              | 2020-03-16T14:27:29.000000                                       |
| OS-SRV-USG:terminated_at            | None                                                             |
| accessIPv4                          |                                                                  |
| accessIPv6                          |                                                                  |
| addresses                           | NET-A=172.30.200.205; NET-B=172.25.200.205; NET-C=172.20.200.205 |
| config_drive                        |                                                                  |
| created                             | 2020-03-16T14:26:32Z                                             |
| flavor                              | DT-L-1c1g40gD (101)                                              |
| hostId                              | b890e0492d59bc71d847d4c861303f16c5e4ee82865f0a80634ef6a8         |
| id                                  | 2a25cc0a-8d71-481b-911c-669cdcbabf7a                             |
| image                               | ISO CentOS 8.1.1911 (0655e8c9-4e5c-4189-b3c5-e5d56e6ca7af)       |
| key_name                            | lookback                                                         |
| name                                | 测试CentOS-8-ISO镜像                                             |
| progress                            | 0                                                                |
| project_id                          | 5df4e0c1c68647ef800e7904d455b58d                                 |
| properties                          |                                                                  |
| security_groups                     | name='放行进出公网'                                              |
|                                     | name='放行进出公网'                                              |
|                                     | name='放行进出公网'                                              |
| status                              | ACTIVE                                                           |
| updated                             | 2020-03-16T14:27:29Z                                             |
| user_id                             | e885c093b3144cc6abcd19ff1c300730                                 |
| volumes_attached                    | id='5cbf6fff-df8c-4ca0-a94b-0154c838dca8'                        |
+-------------------------------------+------------------------------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ openstack volume list --name '测试CentOS-8-ISO镜像'
+--------------------------------------+----------------------+--------+------+-----------------------------------------------+
| ID                                   | Name                 | Status | Size | Attached to                                   |
+--------------------------------------+----------------------+--------+------+-----------------------------------------------+
| 5cbf6fff-df8c-4ca0-a94b-0154c838dca8 | 测试CentOS-8-ISO镜像 | in-use |   40 | Attached to 测试CentOS-8-ISO镜像 on /dev/vda  |
+--------------------------------------+----------------------+--------+------+-----------------------------------------------+
[lookback@LookdeMacBook-Pro ~/OpenStack]$ 
openstack image create --volume 5cbf6fff-df8c-4ca0-a94b-0154c838dca8 IMAGE_NAME
lookback
  • 本文由 发表于 2020年3月17日05:46:18
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: