[root@controller01 ~]# nova resize help
usage: nova resize [--forcehost <forcehost>] [--poll] <server> <flavor>
error: too few arguments
Try 'nova help resize' for more information.
[root@controller01 ~]# nova help resize
usage: nova resize [--forcehost <forcehost>] [--poll] <server> <flavor>
Resize a server.
Positional arguments:
<server> Name or ID of server.
<flavor> Name or ID of new flavor.
Optional arguments:
--forcehost <forcehost> forcehost set vm to compute node
--poll Report the server resize progress until it
completes.
[root@controller01 ~]# nova resize --forcehost controller01 --poll 0ce3bfa6-a2eb-4367-9a13-28f7d621060a m1.medium
Resize 的作用是调整 instance 的 vCPU、内存和磁盘资源。
Instance 需要多少资源是定义在 flavor 中的,resize 操作是通过为 instance 选择新的 flavor 来调整资源的分配。
因为 instance 需要分配的资源发生了变化,在 resize 之前需要借助 nova-scheduler 重新为 instance 选择一个合适的计算节点,如果选择的节点与当前节点不是同一个,那么就需要做 Migrate。
所以本质上讲:
Resize 是在 Migrate 的同时应用新的 flavor。
Migrate 可以看做是 resize 的一个特例: flavor 没发生变化的 resize,这也是为什么 migrate 实际上是在执行 resize 操作。
[root@controller01 ~]# nova migrate --poll --forcehost controller02 qing1
Server migrating... 100% complete
Finished
迁移是指将虚拟机从一个计算节点迁移到另外一个节点上。冷迁移是相对热迁移而言,区别在于冷迁移过程中虚拟机是关机或处于不可用状态,而热迁移则需要保证虚拟机时刻运行。
主机聚合是来分配物理资源的,首先要明白nova scheduler默认是按照正常的算法平均和衡量权重后分配的。
打比方你有100台物理机做为计算节点,默认nova scheduler是按照正常的算法平均和衡量权重后分配的,但有时100台中有30台的cpu和内存很好,我想留给vip用户,这时我就可以使用主机聚合把30台特别的配置的计算节点划入这个聚合,然后配合flavor的可见度,就可以达到我要的效果,其实底层就是会影响nova scheduler的filter中的算法,
nova+name | 作用 |
---|---|
aggregate-add-host | Add the host to the specified aggregate. |
aggregate-create | Create a new aggregate with the specified |
aggregate-delete | Delete the aggregate. |
aggregate-details | Show details of the specified aggregate. |
aggregate-list | Print a list of all aggregates. |
aggregate-remove-host | Remove the specified host from the specified aggregate. |
aggregate-set-metadata | Update the metadata associated with the aggregate. |
aggregate-update | Update the aggregate’s name and optionally |
[root@controller01 ~]# nova aggregate-set-metadata 4 key=vip
Metadata has been successfully updated for aggregate 4.
+----+------+-------------------+----------------+-----------+
| Id | Name | Availability Zone | Hosts | Metadata |
+----+------+-------------------+----------------+-----------+
| 4 | qing | - | 'controller01' | 'key=vip' |
+----+------+-------------------+----------------+-----------+
[root@controller02 ~]# nova keypair-list
+-----------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+-----------+------+-------------------------------------------------+
| test | ssh | 10:0d:ed:77:66:f3:c1:00:8e:43:a1:70:27:86:b8:9b |
+-----------+------+-------------------------------------------------+
[root@controller02 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "/root/.ssh/id_rsa" failed: passphrase is too short (minimum five characters)
[root@controller02 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 这里输入文件的名称
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 这里输入密码
Enter same passphrase again: 重复密码
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:7ulTUSo3mEY1AzoON/hUlNNbYsblMppTdtyU0hiHjKE root@controller02
The key's randomart image is:
+---[RSA 2048]----+
| .+*==o=o. |
| . o+.B=B+o |
| o *.E*=*+.. |
| * o==*+ |
| o.So o |
| . .. |
| .. |
| ... |
| .+. |
+----[SHA256]-----+
nova keypair-add --pub-key /root/.ssh/id_rsa.pub test
[root@controller01 ~]# nova flavor-key qos-test set quota:vif_outbound_average=1024
[root@controller01 ~]# nova flavor-key qos-test set quota:vif_inbound_average=2048
virsh dumpxml instance-0000005e
[root@ceph21581 ~]# nova instance-action-list c1f83234-9ef0-450e-9c2c-b5259e882ad9
+----------------+------------------------------------------+---------+----------------------------+
| Action | Request_ID | Message | Start_Time |
+----------------+------------------------------------------+---------+----------------------------+
| create | req-105be0b2-6ba1-4d11-a521-8fc36e3366c8 | - | 2020-02-18T11:13:56.000000 |
| stop | req-0c465db3-8573-4f6a-9d94-73eb1875ccf6 | - | 2020-02-18T11:17:44.000000 |
| confirmResize | req-e7092186-c3a2-43a7-8ce5-e1079c38c88f | - | 2020-02-18T11:19:32.000000 |
| migrate | req-e7092186-c3a2-43a7-8ce5-e1079c38c88f | - | 2020-02-18T11:19:32.000000 |
| start | req-9225549d-d6e5-487c-ba81-337d9c12dafb | - | 2020-02-18T11:20:05.000000 |
| live-migration | req-ce1b2eac-8465-44f3-889e-e2ce25fa7729 | - | 2020-02-18T11:20:21.000000 |
| reboot | req-7a839fac-a130-49a3-aef0-145b3b9c6d1c | - | 2020-02-19T01:18:00.000000 |
| reboot | req-4ed41b5b-7679-4a8d-9767-003181e8e139 | - | 2020-02-19T01:18:55.000000 |
| live-migration | req-1face3eb-a4ec-46cf-939f-a5298090348c | - | 2020-02-19T04:25:03.000000 |
+----------------+------------------------------------------+---------+----------------------------+