改变主机的大小

改变主机的大小

通过改变主机的规格来改变主机的大小

  1. 显示你的主机的信息,包括主机的大小,即主机规格属性的值

    $ openstack server show myCirrosServer
    +--------------------------------------+----------------------------------------------------------+
    | Field                                | Value                                                    |
    +--------------------------------------+----------------------------------------------------------+
    | OS-DCF:diskConfig                    | AUTO                                                     |
    | OS-EXT-AZ:availability_zone          | nova                                                     |
    | OS-EXT-SRV-ATTR:host                 | node-7.domain.tld                                        |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | node-7.domain.tld                                        |
    | OS-EXT-SRV-ATTR:instance_name        | instance-000000f3                                        |
    | OS-EXT-STS:power_state               | 1                                                        |
    | OS-EXT-STS:task_state                | None                                                     |
    | OS-EXT-STS:vm_state                  | active                                                   |
    | OS-SRV-USG:launched_at               | 2016-10-26T01:13:15.000000                               |
    | OS-SRV-USG:terminated_at             | None                                                     |
    | accessIPv4                           |                                                          |
    | accessIPv6                           |                                                          |
    | addresses                            | admin_internal_net=192.168.111.139                       |
    | config_drive                         | True                                                     |
    | created                              | 2016-10-26T01:12:38Z                                     |
    | flavor                               | m1.small (2)                                             |
    | hostId                               | d815539ce1a8fad3d597c3438c13f1229d3a2ed66d1a75447845a2f3 |
    | id                                   | 67bc9a9a-5928-47c4-852c-3631fef2a7e8                     |
    | image                                | cirros-test (dc5ec4b8-5851-4be8-98aa-df7a9b8f538f)       |
    | key_name                             | None                                                     |
    | name                                 | myCirrosServer                                           |
    | os-extended-volumes:volumes_attached | []                                                       |
    | progress                             | 0                                                        |
    | project_id                           | c08367f25666480f9860c6a0122dfcc4                         |
    | properties                           |                                                          |
    | security_groups                      | [{u'name': u'default'}]                                  |
    | status                               | ACTIVE                                                   |
    | updated                              | 2016-10-26T01:13:00Z                                     |
    | user_id                              | 0209430e30924bf9b5d8869990234e44                         |
    +--------------------------------------+----------------------------------------------------------+
    

    主机大小(规格)为``m1.small (2)``

  2. 用以下命令列出所有可用的主机规格

    $ 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      |
    +-----+-----------+-------+------+-----------+-------+-----------+
    
  3. To resize the server, use the openstack server resize command and add the server ID or name and the new flavor. For example:

    $ openstack server resize --flavor 4 myCirrosServer
    

    注解

    By default, the openstack server resize command gives the guest operating system a chance to perform a controlled shutdown before the instance is powered off and the instance is resized. The shutdown behavior is configured by the shutdown_timeout parameter that can be set in the nova.conf file. Its value stands for the overall period (in seconds) a guest operating system is allowed to complete the shutdown. The default timeout is 60 seconds. See Description of Compute configuration options for details.

    可以为每个镜像单独设置操作系统关机超时时间。在镜像的metadata中,``os_shutdown_timeout``用于指定该镜像操作系统类型所需的关机超时时间。

  4. 显示你的服务器状态

    $ openstack server list
    +----------------------+----------------+--------+-----------------------------------------+
    | ID                   | Name           | Status | Networks                                |
    +----------------------+----------------+--------+-----------------------------------------+
    | 67bc9a9a-5928-47c... | myCirrosServer | RESIZE | admin_internal_net=192.168.111.139      |
    +----------------------+----------------+--------+-----------------------------------------+
    

    当resize完成时,状态变成VERIFY_RESIZE。

  5. 确认调整大小,比如:

    $ openstack server resize --confirm 67bc9a9a-5928-47c4-852c-3631fef2a7e8
    

    服务器的状态变成ACTIVE

  6. 如果调整失败或未按预期运行,你可以恢复调整大小。例如:

    $ openstack server resize --revert 67bc9a9a-5928-47c4-852c-3631fef2a7e8
    

    服务器的状态变成ACTIVE

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.