OpenStack扩容内存硬盘配置

2023-02-24 17:26:21 浏览数 (3)

实验说明:

本文介绍把OpenStack中一个实例扩容内存和硬盘的步骤,实际整个过程是对实例做冷迁移来达到配置扩容。

实例扩容前配置:c2m4d101

实例扩容后配置:c4m8d150

OpenStack 实例扩容配置操作

步骤:

获取admin用户权限

命令:source admin-openrc

获取实例ID

命令:nova list --all

代码语言:javascript复制
# nova list --all
 -------------------------------------- ------ ---------------------------------- --------- ------------ ------------- ----------------------- 
| ID                                   | Name | Tenant ID                        | Status  | Task State | Power State | Networks              |
 -------------------------------------- ------ ---------------------------------- --------- ------------ ------------- ----------------------- 
| 5d5f3e84-606f-4763-b659-cf5da1f45862 | 1    | 76e5e27da0ea44b39339f219f9a3ea4b | SHUTOFF | -          | Shutdown    | vlan192=10.10.192.142 |
 -------------------------------------- ------ ---------------------------------- --------- ------------ ------------- ----------------------- 

获取到实例ID为 5d5f3e84-606f-4763-b659-cf5da1f45862

查看实例现在配置

命令:nova show 5d5f3e84-606f-4763-b659-cf5da1f45862

代码语言:javascript复制
# nova show  5d5f3e84-606f-4763-b659-cf5da1f45862 
 -------------------------------------- --------------------------------------------------------------------- 
| Property                             | Value                                                               |
 -------------------------------------- --------------------------------------------------------------------- 
| OS-DCF:diskConfig                    | AUTO                                                                |
| OS-EXT-AZ:availability_zone          | nova                                                                |
| OS-EXT-SRV-ATTR:host                 | compute1                                                            |
| OS-EXT-SRV-ATTR:hostname             | 1                                                                   |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | compute1                                                            |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000042                                                   |
| OS-EXT-SRV-ATTR:kernel_id            |                                                                     |
| OS-EXT-SRV-ATTR:launch_index         | 0                                                                   |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                                                     |
| OS-EXT-SRV-ATTR:reservation_id       | r-cfsk20p6                                                          |
| OS-EXT-SRV-ATTR:root_device_name     | /dev/vda                                                            |
| OS-EXT-SRV-ATTR:user_data            | -                                                                   |
| OS-EXT-STS:power_state               | 4                                                                   |
| OS-EXT-STS:task_state                | -                                                                   |
| OS-EXT-STS:vm_state                  | stopped                                                             |
| OS-SRV-USG:launched_at               | 2021-12-07T10:17:18.000000                                          |
| OS-SRV-USG:terminated_at             | -                                                                   |
| accessIPv4                           |                                                                     |
| accessIPv6                           |                                                                     |
| config_drive                         | True                                                                |
| created                              | 2021-11-26T13:45:29Z                                                |
| description                          | -                                                                   |
| flavor:disk                          | 101                                                                 |
| flavor:ephemeral                     | 0                                                                   |
| flavor:extra_specs                   | {}                                                                  |
| flavor:original_name                 | c2m4d101                                                            |
| flavor:ram                           | 4096                                                                |
| flavor:swap                          | 0                                                                   |
| flavor:vcpus                         | 2                                                                   |
| hostId                               | 3578ea6c69855c946effdbeefa65af0082717e20f9f5d681e03e474e            |
| host_status                          | UP                                                                  |
| id                                   | 5d5f3e84-606f-4763-b659-cf5da1f45862                                |
| image                                | CentOS-7.4-x86_64-2021-08-21 (8810b721-65ee-429d-b40e-0de4de737af1) |
| key_name                             | -                                                                   |
| locked                               | False                                                               |
| metadata                             | {}                                                                  |
| name                                 | 1                                                                   |
| os-extended-volumes:volumes_attached | []                                                                  |
| security_groups                      | default                                                             |
| status                               | SHUTOFF                                                             |
| tags                                 | []                                                                  |
| tenant_id                            | 76e5e27da0ea44b39339f219f9a3ea4b                                    |
| updated                              | 2021-12-07T10:22:18Z                                                |
| user_id                              | e8449e95fcfe42369f9e75e77309c369                                    |
| vlan192 network                      | 10.10.192.142                                                       |
 -------------------------------------- --------------------------------------------------------------------- 

从上面可以看到该实例现在配置是c2m4d101,状态为SHUTOFF

获取实例类型ID

命令:openstack flavor list

代码语言:javascript复制
# openstack flavor list
 -------------------------------------- ----------- ------- ------ ----------- ------- ----------- 
| ID                                   | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
 -------------------------------------- ----------- ------- ------ ----------- ------- ----------- 
| 1520e952-4ed9-4a4c-ba03-237693e0e879 | c6m10d100 | 10240 |  100 |         0 |     6 | True      |
| 41e69056-48d8-48ab-902d-94863cbacfec | c4m8d80   |  8192 |   80 |         0 |     4 | True      |
| 5420bbbb-33de-4764-bc78-d45cb93d4849 | c2m4d101  |  4096 |  101 |         0 |     2 | True      |
| 5cc1ee41-b3c6-499a-8941-b2dd28f5136e | c4m10d50  | 10200 |   50 |         0 |     4 | True      |
| 919e5c1e-7703-497f-9576-eaee29959a08 | c2m2d20   |  2048 |   20 |         0 |     2 | True      |
| c56fe138-af89-4b48-b1e8-0be6366d4fe6 | c2m4d20   |  4096 |   20 |         0 |     2 | True      |
| dcc7c785-833d-47b9-8582-46d96ea75b24 | c4m8d150  |  8192 |  150 |         0 |     4 | True      |
| ffe7444a-b3d4-4e08-b206-59e778486e09 | c4m8d50   |  8096 |   50 |         0 |     4 | True      |
 -------------------------------------- ----------- ------- ------ ----------- ------- ----------- 

我们需要扩容到c4m8d150的实例类型,id为dcc7c785-833d-47b9-8582-46d96ea75b24

执行扩容

命令:nova resize --poll 5d5f3e84-606f-4763-b659-cf5da1f45862 dcc7c785-833d-47b9-8582-46d96ea75b24

代码语言:javascript复制
# nova resize --poll 5d5f3e84-606f-4763-b659-cf5da1f45862   dcc7c785-833d-47b9-8582-46d96ea75b24

Server resizing... 100% complete
Finished
查看实例配置和状态
代码语言:javascript复制
# nova show  5d5f3e84-606f-4763-b659-cf5da1f45862                                               
 -------------------------------------- --------------------------------------------------------------------- 
| Property                             | Value                                                               |
 -------------------------------------- --------------------------------------------------------------------- 
| OS-DCF:diskConfig                    | AUTO                                                                |
| OS-EXT-AZ:availability_zone          | nova                                                                |
| OS-EXT-SRV-ATTR:host                 | compute1                                                            |
| OS-EXT-SRV-ATTR:hostname             | 1                                                                   |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | compute1                                                            |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000042                                                   |
| OS-EXT-SRV-ATTR:kernel_id            |                                                                     |
| OS-EXT-SRV-ATTR:launch_index         | 0                                                                   |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                                                     |
| OS-EXT-SRV-ATTR:reservation_id       | r-cfsk20p6                                                          |
| OS-EXT-SRV-ATTR:root_device_name     | /dev/vda                                                            |
| OS-EXT-SRV-ATTR:user_data            | -                                                                   |
| OS-EXT-STS:power_state               | 4                                                                   |
| OS-EXT-STS:task_state                | -                                                                   |
| OS-EXT-STS:vm_state                  | resized                                                             |
| OS-SRV-USG:launched_at               | 2021-12-07T14:48:19.000000                                          |
| OS-SRV-USG:terminated_at             | -                                                                   |
| accessIPv4                           |                                                                     |
| accessIPv6                           |                                                                     |
| config_drive                         | True                                                                |
| created                              | 2021-11-26T13:45:29Z                                                |
| description                          | -                                                                   |
| flavor:disk                          | 150                                                                 |
| flavor:ephemeral                     | 0                                                                   |
| flavor:extra_specs                   | {}                                                                  |
| flavor:original_name                 | c4m8d150                                                            |
| flavor:ram                           | 8192                                                                |
| flavor:swap                          | 0                                                                   |
| flavor:vcpus                         | 4                                                                   |
| hostId                               | 3578ea6c69855c946effdbeefa65af0082717e20f9f5d681e03e474e            |
| host_status                          | UP                                                                  |
| id                                   | 5d5f3e84-606f-4763-b659-cf5da1f45862                                |
| image                                | CentOS-7.4-x86_64-2021-08-21 (8810b721-65ee-429d-b40e-0de4de737af1) |
| key_name                             | -                                                                   |
| locked                               | False                                                               |
| metadata                             | {}                                                                  |
| name                                 | 1                                                                   |
| os-extended-volumes:volumes_attached | []                                                                  |
| progress                             | 0                                                                   |
| security_groups                      | default                                                             |
| status                               | VERIFY_RESIZE                                                       |
| tags                                 | []                                                                  |
| tenant_id                            | 76e5e27da0ea44b39339f219f9a3ea4b                                    |
| updated                              | 2021-12-07T14:48:19Z                                                |
| user_id                              | e8449e95fcfe42369f9e75e77309c369                                    |
| vlan192 network                      | 10.10.192.142                                                       |
 -------------------------------------- --------------------------------------------------------------------- 

从上可以看到实际已经扩容到c4m8d150,状态为VERIFY_RESIZE

最后确认迁移

命令:nova resize-confirm <实例ID>

代码语言:javascript复制
# nova resize-confirm 5d5f3e84-606f-4763-b659-cf5da1f45862

执行这一步之后再查看实际状态nova show <实例id> 就可以看到状态已经变为SHUTOFF,表示扩容已经成功

0 人点赞