开发者社区> terry.zeng> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

openstack 命令行管理十八 - instance管理 (备忘)

简介: Openstak 中, 常用 nova 命令对实例进行管理 常见管理方法有,  创建, 删除,  更改(resize flavor, 冷/热迁移), 查询 等   列出当前 tenant 中的实例 首先需要载入 keystone 验证信息 [root@gz-controller-209131 ~(keystone_admin)]# cat keystonerc_admin
+关注继续查看

Openstak 中, 常用 nova 命令对实例进行管理

常见管理方法有,  创建, 删除,  更改(resize flavor, 冷/热迁移), 查询 等

 

列出当前 tenant 中的实例

首先需要载入 keystone 验证信息

[root@gz-controller-209131 ~(keystone_admin)]# cat keystonerc_admin
export OS_USERNAME=admin
export OS_TENANT_NAME=admin
export OS_PASSWORD=你的openstack密码
export OS_AUTH_URL=http://240.70.115.80:5000/v2.0/    <- keystone 连接方法
export PS1='[\u@\h \W(keystone_admin)]\$ '

使用 source 命令导入验证信息
[root@gz-controller-209131 ~(keystone_admin)]# source keystonerc_admin


命令帮助

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova help | grep -E 'boot|list|delete|stop|remove'
    absolute-limits     Print a list of absolute limits for a user
    agent-delete        Delete existing agent build.
    agent-list          List all builds.
    aggregate-delete    Delete the aggregate.
    aggregate-list      Print a list of all aggregates.
    aggregate-remove-host
    availability-zone-list
    boot                Boot a new server.
    cloudpipe-list      Print a list of all cloudpipe instances.
    delete              Immediately shut down and delete specified server(s).
    dns-delete          Delete the specified DNS entry.
    dns-delete-domain   Delete the specified DNS domain.
    dns-domains         Print a list of available dns domains.
    dns-list            List current DNS entries for domain and ip or domain
    flavor-access-list  Print access information about the given flavor.
    flavor-access-remove
    flavor-delete       Delete a specific flavor
    flavor-list         Print a list of available 'flavors' (sizes of
    floating-ip-bulk-delete
                        Bulk delete floating ips by range.
    floating-ip-bulk-list
    floating-ip-delete  De-allocate a floating IP.
    floating-ip-list    List floating ips for this tenant.
    floating-ip-pool-list
    host-list           List all hosts by service.
    hypervisor-list     List hypervisors.
    image-delete        Delete specified image(s).
    image-list          Print a list of available images to boot from.
    interface-list      List interfaces attached to a server.
    keypair-delete      Delete keypair given by its name.
    keypair-list        Print a list of keypairs for a user
    list                List active servers.
    list-secgroup       List Security Group(s) of a server.
    network-list        Print a list of available networks.
    quota-delete        Delete quota for a tenant/user so their quota will
    rate-limits         Print a list of rate limits for a user
    reboot              Reboot a server.
    rebuild             Shutdown, re-image, and re-boot a server.
    remove-fixed-ip     Remove an IP address from a server.
    remove-floating-ip  DEPRECATED, use floating-ip-disassociate instead.
    remove-secgroup     Remove a Security Group from a server.
    secgroup-delete     Delete a security group.
    secgroup-delete-group-rule
    secgroup-delete-rule
    secgroup-list       List security groups for the current tenant.
    secgroup-list-rules
    server-group-delete
    server-group-list   Print a list of all server groups.
    service-list        Show a list of all running services. Filter by host &
    stop                Stop a server.
    usage-list          List usage data for all tenants.
    volume-delete       Remove volume(s).
    volume-list         List all the volumes.
    volume-snapshot-delete
    volume-snapshot-list
    volume-type-delete  Delete a specific flavor
    volume-type-list    Print a list of available 'volume types'.
    instance-action-list
    force-delete        Force delete a server.
    restore             Restore a soft-deleted server.
    net-delete          Delete a network
    net-list            List networks
    baremetal-interface-list
    baremetal-interface-remove
    baremetal-node-delete
    baremetal-node-list
                        Print list of available baremetal nodes.
    migration-list      Print a list of migrations.
    list-extensions     List all the os-api extensions that are available.



创建主机相关帮助

[root@station140 ~(keystone_admin)]# nova boot
usage: nova boot [--flavor <flavor>] [--image <image>]
                 [--image-with <key=value>] [--boot-volume <volume_id>]
                 [--snapshot <snapshot_id>] [--num-instances <number>]
                 [--meta <key=value>] [--file <dst-path=src-path>]
                 [--key-name <key-name>] [--user-data <user-data>]
                 [--availability-zone <availability-zone>]
                 [--security-groups <security-groups>]
                 [--block-device-mapping <dev-name=mapping>]
                 [--block-device key1=value1[,key2=value2...]]
                 [--swap <swap_size>]
                 [--ephemeral size=<size>[,format=<format>]]
                 [--hint <key=value>]
                 [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid>]
                 [--config-drive <value>] [--poll]
                 <name>


列出flavor-list

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova flavor-list
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name            | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| 05a60192-4e43-40ae-a2c7-d37d7e9a81b1 | 2core-8g-40g    | 8192      | 40   | 0         | 2048 | 2     | 1.0         | True      |
| 1012                                 | normal_1core    | 2048      | 20   | 0         | 1024 | 1     | 1.0         | False     |
| 12266e3a-a1fc-4f6a-83f8-fc841abce59e | b2c_allinone_8G | 8192      | 40   | 0         | 1024 | 4     | 1.0         | True      |
| 3017f87a-a3b2-46ef-8d37-ad341919b74c | 8core-8g        | 8192      | 40   | 0         | 2048 | 8     | 1.0         | True      |
| 43664714-1c93-4e7a-adbd-9e47a6a932fa | 2core-2g        | 2048      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| 5c88939b-8807-4821-9718-5bafecc1daa2 | 2core-8g        | 8192      | 20   | 0         | 2048 | 2     | 1.0         | True      |
| 76269352-5050-4095-b4f3-3ea86cb2879c | 2core-2g-40g    | 2048      | 40   | 0         | 2048 | 2     | 1.0         | True      |
| 8d20b341-d0a2-47e2-acf7-73e64d76a8fe | 4core-8g        | 8192      | 40   | 0         | 2048 | 4     | 1.0         | True      |
| 989f6219-3231-45b5-bcfd-daf87ac07705 | 8core-16g       | 16384     | 40   | 0         | 2048 | 8     | 1.0         | True      |
| 9bb5f019-0c7c-41fc-a3ed-e6e44413a3d3 | 8core-32g       | 32768     | 40   | 0         | 2048 | 8     | 1.0         | True      |
| a009164a-f9fe-47fc-9876-e27dbcef1040 | mysql_db        | 4096      | 20   | 0         | 1024 | 4     | 1.0         | True      |
| bfaefcff-f01b-42fc-bdec-1e5c9fa3c0a1 | b2c_allinone    | 4096      | 40   | 0         | 1024 | 2     | 1.0         | True      |
| ced08277-a79f-491f-97eb-275d5271777e | b2c_web         | 2048      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| dc98e6d6-143f-42c2-9482-ee6efb04ff7e | 4core-4g        | 4096      | 40   | 0         | 1024 | 4     | 1.0         | True      |
| de61ffb3-b1fe-46ec-99c5-390e5280e6d7 | 4core-16g       | 16384     | 40   | 0         | 2048 | 4     | 1.0         | True      |
| edd174c2-7ce1-445d-86b0-3d10705a12b1 | 2core-4g        | 4096      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| f43fe47d-0be6-4c8f-ba0e-cdfa8fea04e0 | b2c_web_1core   | 2048      | 20   | 0         | 1024 | 1     | 1.0         | True      |
| ff40b4a3-fd79-444b-884b-6447e5dc3265 | 2core-4g-40g    | 4096      | 40   | 0         | 2048 | 2     | 1.0         | True      |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+


列出镜像命名

[root@hh-yun-puppet-129021 ~(keystone_admin)]# glance image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'
ID                                                       Name
04135fe1-14d8-4480-a638-189ed93ea620       Centos5.8_2.9.4_old
c6ce9208-70d4-4b67-ad0a-a82927dcd5b7           Centos5.8_2.9.5
8f9686dc-3286-41ab-8a03-8a107aa56b27        Centos5.8_2.9.5_v1
e624e961-52a4-4c8f-81c4-809355707147           Centos5.8_2.9.6
a1e93465-b3ab-456e-ab30-24ed6d77c11f   centos5.8_test_anquan05
f1739787-c454-4001-9253-c7c5d437aff5             Centos6.3_1.3
f87f65e3-24ff-44c0-8858-9662334679e4      Centos6.3_x86_64_1.2
764b2022-0ecf-4013-b68a-898e9c31fb46     Centos6.6_x86_64_1.10
2250a24b-c83d-4c6b-882f-87415a46ea83     Centos6.6_x86_64_1.12
301db4ff-a46f-4235-8f85-5414797377c5      Centos6.6_x86_64_1.6
3043d3e7-c565-44c1-ad5d-8efcb5e3bfe1       Centos65_x86_64_2.6
5aa770b3-8636-4532-9ffd-e1b0dca982be      Centos7_Generic_1503
dd684f6d-2bf7-489a-97dd-af04c4758d62             pdns_20140430
4fc0d2a3-b8e0-4d6b-9490-39c82a330c1b         pdns_20140430_old
0c47db9c-5f74-4544-8ada-0894c1d2c20c                      Win7
ec67eb1a-0789-4233-8b02-a6fd7cec12a1       windows-server-2012
4c91c621-c809-4989-a474-da87b5a49401       windows_server_2008
a7996093-9ae6-4dc0-b711-52f03b3a0663  windows_server_2008_v0.1
9eb26d0d-eedb-44ad-b826-03316423d167  windows_server_2012_v1.2
ebaf276d-be8b-44a8-87ff-df623bda5467  windows_server_2012_v1.3
e7905995-bc7c-4594-93d0-f989a18916fe  windows_server_2012_v1.4

等价命令

nova image-list | grep -v "+" | awk '{printf "%-35s %25s\n",  $2,$4}'


列出 secgroup

[root@station140 ~(keystone_admin)]# nova secgroup-list
+--------------------------------------+---------+--------------------+
| Id                                   | Name    | Description        |
+--------------------------------------+---------+--------------------+
| 91a191a6-b89e-4f87-99c0-0fb985985978 | default | default            |
| 6966a8e4-0980-40ad-a409-baac65b60287 | terry   | allow ping and ssh |
+--------------------------------------+---------+--------------------+


列出可用网络

[root@hh-yun-puppet-129021 ~(keystone_admin)]# neutron  net-list
+--------------------------------------+------------+------------------------------------------------------+
| id                                   | name       | subnets                                              |
+--------------------------------------+------------+------------------------------------------------------+
| 0007150e-b600-4ea6-841d-79261bf10af8 | QA_NET     | ecc5f5a4-1fd7-4428-9351-6809ada3ad08 10.199.160.0/19 |
| 1e984167-3d90-49c0-91ad-b3910326fa5b | OPS_NET    | c2844b96-c26b-483d-b7fe-c2c37ff75cec 10.199.134.0/24 |
| 2530bdb0-8910-47d8-bcd5-696325c0cf7e | DMZ5_NET   | 35267c69-b8f1-4e5f-9784-5d49db020944 10.199.52.0/24  |
| 36c8028c-3ddb-44fb-b232-8eed3ee1c357 | DMZ1_NET   | 6b70aad7-3547-4d8d-9ab6-d73d080db88f 10.199.48.0/24  |
| 56886b13-e1a5-4213-8456-3616875a6a45 | MOBILE_NET | b18f5475-d334-4726-9508-b161e5998aed 10.199.144.0/20 |
| 594a0802-d2df-4aa1-9b49-3a0c4caa55c0 | DMZ3_NET   | 1bda2357-268f-4683-b21b-d1f69da62a9b 10.199.50.0/24  |
| a46f6060-bfd2-44af-b90c-858ca62f19da | MGMT_NET   | 91f2dc9f-9500-4615-989f-0d1562ab3c02 10.199.132.0/24 |
| bd780fa9-33fb-4757-887c-c1821630a15b | DMZ4_NET   | af474d04-baa0-4410-ac6f-3d7d282b95d6 10.199.51.0/24  |
| c3a26318-9741-4067-bd29-49124ac40970 | DMZ6_NET   | 2ec35a77-db91-4a9b-9497-ae3bef74035e 10.199.53.0/24  |
| d107fe05-0fe9-4fea-9325-4cf2d0825101 | DEV_NET    | b0bd1964-ef05-4aec-a602-9dc6a97ef9fd 10.199.192.0/18 |
| db1786d1-b8c8-4d27-a4d1-6890d6162557 | QATOOL_NET | b986aeff-f3ba-4f18-9138-f39a6fef323d 10.199.133.0/24 |
| e302ca3a-dc19-4387-90ef-f5eb188e98cd | TEST_NET   | 1b2ea04c-060a-4f6e-a8d6-66754f90c530 10.199.64.0/22  |
| f49a7526-ccbc-4d65-8169-433d19733887 | DMZ2_NET   | d3c4da60-6ef1-4c1a-965a-036639ab62f1 10.199.49.0/24  |
+--------------------------------------+------------+------------------------------------------------------+

 

启动第一个实例 (只有一个网卡)

[root@hh-yun-puppet-129021 ~(keystone_admin)]#  nova boot --flavor 2core-2g --image Centos6.6_x86_64_1.12  --security-groups default --nic net-id=d107fe05-0fe9-4fea-9325-4cf2d0825101 terry.gz.vclound.com --availability_zone develop-zone
+--------------------------------------+--------------------------------------------------------------+
| Property                             | Value                                                        |
+--------------------------------------+--------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                       |
| OS-EXT-AZ:availability_zone          | nova                                                         |
| OS-EXT-SRV-ATTR:host                 | -                                                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                            |
| OS-EXT-SRV-ATTR:instance_name        | instance-00017faf                                            |
| 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                            | tNMSsUoA7vcy                                                 |  <- root 密码
| availability_zone                    | develop-zone                                                 |  <- 云主机将会被创建在 develop-zone 中
| config_drive                         |                                                              |
| created                              | 2016-03-14T07:40:44Z                                         |
| flavor                               | 2core-2g (43664714-1c93-4e7a-adbd-9e47a6a932fa)              |
| hostId                               |                                                              |
| id                                   | 7dcfee9a-9338-489b-a335-215b8441d67b                         |
| image                                | Centos6.6_x86_64_1.12 (2250a24b-c83d-4c6b-882f-87415a46ea83) |
| key_name                             | -                                                            |
| metadata                             | {}                                                           |
| name                                 | terry.gz.vclound.com                                         | <- 主机名
| os-extended-volumes:volumes_attached | []                                                           |
| progress                             | 0                                                            |
| security_groups                      | default                                                      |
| status                               | BUILD                                                        |
| tenant_id                            | bb0b51d166254dc99bc7462c0ac002ff                             | <- 云主机 uuid
| updated                              | 2016-03-14T07:40:44Z                                         |
| user_id                              | 226e71f1c1aa4bae85485d1d17b6f0ae                             |
+--------------------------------------+--------------------------------------------------------------+


查询明细信息

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova show 486c00a7-e7f8-4bc5-b346-4bef8510832a
+--------------------------------------+--------------------------------------------------------------+
| Property                             | Value                                                        |
+--------------------------------------+--------------------------------------------------------------+
| DEV_NET network                      | 10.199.198.167                                               |  <- 云主机 ip 地址
| OS-DCF:diskConfig                    | MANUAL                                                       |
| OS-EXT-AZ:availability_zone          | develop-zone                                                 |
| OS-EXT-SRV-ATTR:host                 | hh-yun-compute-130238.vclound.com                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | hh-yun-compute-130238.vclound.com                            |  <- 物理机
| OS-EXT-SRV-ATTR:instance_name        | instance-00017fa5                                            |
| OS-EXT-STS:power_state               | 0                                                            |
| OS-EXT-STS:task_state                | spawning                                                     |  
| OS-EXT-STS:vm_state                  | building                                                     |  <- 云主机状态
| OS-SRV-USG:launched_at               | -                                                            |
| OS-SRV-USG:terminated_at             | -                                                            |
| accessIPv4                           |                                                              |
| accessIPv6                           |                                                              |
| availability_zone                    | develop-zone                                                 |  <- zone
| config_drive                         |                                                              |
| created                              | 2016-03-14T04:56:10Z                                         |
| flavor                               | 2core-2g (43664714-1c93-4e7a-adbd-9e47a6a932fa)              |
| hostId                               | c522176438f370bc97e823844364a051949cd49e22f86832ca6768f6     |  <- 云主机 uuid
| id                                   | 486c00a7-e7f8-4bc5-b346-4bef8510832a                         |
| image                                | Centos6.6_x86_64_1.12 (2250a24b-c83d-4c6b-882f-87415a46ea83) |  <- images
| key_name                             | -                                                            |
| metadata                             | {}                                                           |
| name                                 | terry.gz.vclound.com                                         |  <- 主机名
| os-extended-volumes:volumes_attached | []                                                           |
| progress                             | 0                                                            |
| security_groups                      | default                                                      |
| status                               | BUILD                                                        |
| tenant_id                            | bb0b51d166254dc99bc7462c0ac002ff                             |
| updated                              | 2016-03-14T04:56:21Z                                         |
| user_id                              | 226e71f1c1aa4bae85485d1d17b6f0ae                             |
+--------------------------------------+--------------------------------------------------------------+

下面显示为正常运行中的 instance

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova list --name terry.gz.vclound.com
+--------------------------------------+----------------------+--------+------------+-------------+------------------------+
| ID                                   | Name                 | Status | Task State | Power State | Networks               |
+--------------------------------------+----------------------+--------+------------+-------------+------------------------+
| 486c00a7-e7f8-4bc5-b346-4bef8510832a | terry.gz.vclound.com | ACTIVE | -          | Running     | DEV_NET=10.199.198.167 |
+--------------------------------------+----------------------+--------+------------+-------------+------------------------+ 

列出主机部分信息

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova list  --fields "networks,name,status" --name terry.gz.vclound.com
+--------------------------------------+------------------------+----------------------+--------+
| ID                                   | Networks               | Name                 | Status |
+--------------------------------------+------------------------+----------------------+--------+
| 486c00a7-e7f8-4bc5-b346-4bef8510832a | DEV_NET=10.199.198.167 | terry.gz.vclound.com | ACTIVE |
+--------------------------------------+------------------------+----------------------+--------+


注: fields 需使用小写进行定义


关闭主机

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova stop 486c00a7-e7f8-4bc5-b346-4bef8510832a

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova list  --fields "networks,name,status" --name terry.gz.vclound.com
+--------------------------------------+------------------------+----------------------+---------+
| ID                                   | Networks               | Name                 | Status  |
+--------------------------------------+------------------------+----------------------+---------+
| 486c00a7-e7f8-4bc5-b346-4bef8510832a | DEV_NET=10.199.198.167 | terry.gz.vclound.com | SHUTOFF |
+--------------------------------------+------------------------+----------------------+---------+

删除主机

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova delete 486c00a7-e7f8-4bc5-b346-4bef8510832a

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova list  --fields "networks,name,status" --name terry.gz.vclound.com
+----+----------+------+--------+
| ID | Networks | Name | Status |
+----+----------+------+--------+
+----+----------+------+--------+

冷迁移主机或者改变主机 flavor 方法

列出 flavor

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova flavor-list
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name            | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+
| 05a60192-4e43-40ae-a2c7-d37d7e9a81b1 | 2core-8g-40g    | 8192      | 40   | 0         | 2048 | 2     | 1.0         | True      |
| 1012                                 | normal_1core    | 2048      | 20   | 0         | 1024 | 1     | 1.0         | False     |
| 12266e3a-a1fc-4f6a-83f8-fc841abce59e | b2c_allinone_8G | 8192      | 40   | 0         | 1024 | 4     | 1.0         | True      |
| 3017f87a-a3b2-46ef-8d37-ad341919b74c | 8core-8g        | 8192      | 40   | 0         | 2048 | 8     | 1.0         | True      |
| 43664714-1c93-4e7a-adbd-9e47a6a932fa | 2core-2g        | 2048      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| 5c88939b-8807-4821-9718-5bafecc1daa2 | 2core-8g        | 8192      | 20   | 0         | 2048 | 2     | 1.0         | True      |
| 76269352-5050-4095-b4f3-3ea86cb2879c | 2core-2g-40g    | 2048      | 40   | 0         | 2048 | 2     | 1.0         | True      |
| 8d20b341-d0a2-47e2-acf7-73e64d76a8fe | 4core-8g        | 8192      | 40   | 0         | 2048 | 4     | 1.0         | True      |
| 989f6219-3231-45b5-bcfd-daf87ac07705 | 8core-16g       | 16384     | 40   | 0         | 2048 | 8     | 1.0         | True      |
| 9bb5f019-0c7c-41fc-a3ed-e6e44413a3d3 | 8core-32g       | 32768     | 40   | 0         | 2048 | 8     | 1.0         | True      |
| a009164a-f9fe-47fc-9876-e27dbcef1040 | mysql_db        | 4096      | 20   | 0         | 1024 | 4     | 1.0         | True      |
| bfaefcff-f01b-42fc-bdec-1e5c9fa3c0a1 | b2c_allinone    | 4096      | 40   | 0         | 1024 | 2     | 1.0         | True      |
| ced08277-a79f-491f-97eb-275d5271777e | b2c_web         | 2048      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| dc98e6d6-143f-42c2-9482-ee6efb04ff7e | 4core-4g        | 4096      | 40   | 0         | 1024 | 4     | 1.0         | True      |
| de61ffb3-b1fe-46ec-99c5-390e5280e6d7 | 4core-16g       | 16384     | 40   | 0         | 2048 | 4     | 1.0         | True      |
| edd174c2-7ce1-445d-86b0-3d10705a12b1 | 2core-4g        | 4096      | 20   | 0         | 1024 | 2     | 1.0         | True      |
| f43fe47d-0be6-4c8f-ba0e-cdfa8fea04e0 | b2c_web_1core   | 2048      | 20   | 0         | 1024 | 1     | 1.0         | True      |
| ff40b4a3-fd79-444b-884b-6447e5dc3265 | 2core-4g-40g    | 4096      | 40   | 0         | 2048 | 2     | 1.0         | True      |
+--------------------------------------+-----------------+-----------+------+-----------+------+-------+-------------+-----------+


参考主机当前状态

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova show 7dcfee9a-9338-489b-a335-215b8441d67b | grep -E 'hypervisor_hostname|vm_state|flavor|task_state'
| OS-EXT-SRV-ATTR:hypervisor_hostname  | hh-yun-compute-130238.vclound.com                            |
| OS-EXT-STS:task_state                | -                                                            |
| OS-EXT-STS:vm_state                  | active                                                       |
| flavor                               | 2core-2g (43664714-1c93-4e7a-adbd-9e47a6a932fa)              |

当前云主机在物理机 hh-yun-compute-130238 上创建,  处于开机状态,  当前使用了 b2c_web_1core 的主机类型,

迁移, 重定义 flavor

nova resize 7dcfee9a-9338-489b-a335-215b8441d67b b2c_allinone

再次查询主机状态

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova show 7dcfee9a-9338-489b-a335-215b8441d67b | grep -E 'hypervisor_hostname|vm_state|flavor|task_state'
| OS-EXT-SRV-ATTR:hypervisor_hostname  | hh-yun-compute-130238.vclound.com                            |
| OS-EXT-STS:task_state                | resize_migrating                                             |
| OS-EXT-STS:vm_state                  | active                                                       |
| flavor                               | 2core-2g (43664714-1c93-4e7a-adbd-9e47a6a932fa)              |
当前主机处于 resize_migrating 状态


待完成迁移后, 再次查询状态

[root@hh-yun-puppet-129021 ~(keystone_admin)]# nova show 7dcfee9a-9338-489b-a335-215b8441d67b | grep -E 'hypervisor_hostname|vm_state|flavor|task_state'
| OS-EXT-SRV-ATTR:hypervisor_hostname  | hh-yun-compute-130214.vclound.com                            |
| OS-EXT-STS:task_state                | -                                                            |
| OS-EXT-STS:vm_state                  | active                                                       |
| flavor                               | 2core-4g (edd174c2-7ce1-445d-86b0-3d10705a12b1)              |

可见, 主机 flavor 已经发生改变, 另外, 云主机已经被迁移到  hh-yun-compute-130214 主机上,

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
openStack vm备份
由于VM是可能存在于不同节点上,所以当一个计算节点挂掉后,可以把挂掉的节点运行的VM在新的节点上继续运行。 虽然快照功能可以做恢复使用,但是毕竟快照只能恢复固定时间的VM,所以虚拟机备份很重要!对做好热备份有很大的帮助!   注:以测试集群为例,把c01上的vm1备份到c02上面   步骤: 1.首先,查看待备份vm1的信息:      在目录“/var/lib/nova/instances/$VM_ID/”下面有如下文件:       console.log  disk  libvirt.xml      其中,disk里面没有包含数据,只是一个包含vm基本信息的文件。
792 0
openstack 管理 - 索引(备忘)
命令行管理介绍 openstack 命令行管理一 - br-ex 网络设定 (备忘) openstack 命令行管理二 - 镜像管理 (备忘) openstack 命令行管理三 - tenant 管理 (备忘) openstack 命令行管理四 - 资源管理 (备忘) openstack 命令行管理五 - 磁盘配额管理(备忘) openstack 命令行管理六 - 用户管理
1802 0
openstack instance bootmgr is missing 问题 修复
qemu-img convert -c disk 4bcf3ea091bd79e244fc433857b89c75646e1a06 -O qcow2 wang-t-testing.qcow2
697 0
openstack kvm 虚拟机磁盘差异衍生
1, openstack虚拟实例备份之--多镜像格式多镜像文件合并为一个镜像文件衍生-差异镜像文件    /var/lib/nova/instances/b0abc22f-1a73-4079-b1bc-2aa28f43b952/disk衍生基本镜像文件    /var/lib/nova/instan...
755 0
openstack 命令行管理八 - 服务管理 (备忘)
 帮助 [root@station140 tmp(keystone_admin)]# keystone help | grep service service-create Add service to Service Catalog. service-delete Delete service from Service Catalog.
1211 0
openstack 命令行管理十一 - 安全组管理 (备忘)
 参考官方资料 You must modify the rules for the default security group because users cannot access instances that use the default group from any IP address outside the cloud. You can modify the rul
1331 0
openstack 命令行管理四 - 资源管理 (备忘)
 配额用于对每个 tenants 进行限制, 如浮动 IP, 内存, CPU, 磁盘, 密钥, 安全规则, 云硬盘等 资源管理帮助 [root@station140 ~(keystone_admin)]# nova help | grep quota quota-class-show List the quotas for a quota class.
1233 0
openstack 命令行管理十三 - 外部网络[外部连接专用]管理 (备忘)
 创建公网 [root@station140 ~(network_admin)]# neutron net-create --router:external=true pub1 Created a new network: +---------------------------+--------------------------------------+ | Field
1435 0
openstack 命令行管理十四 - 路由管理 (备忘)
 帮助 [root@station140 ~(network_admin)]# neutron help | grep route l3-agent-list-hosting-router List L3 agents hosting a router. l3-agent-router-add Add a router to a L3 agent.
1621 0
openstack 命令行管理三 - tenant 管理 (备忘)
Openstack 中, 以租户作为云主机隔离的单位   project 等同于 tenant OpenStack Compute Service (nova) 作为认证时候, 称为 project OpenStack Identity Service (keystone) 作为认证时候, 称为 tenant   在管理 openstack 时候, 需要添加独立的 proj
1485 0
+关注
terry.zeng
怕麻烦
192
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载