Openstack Autostartのリスト

Openstackで起動したVMがAutostartか気になったので確認。

Autostartかどうかは以下のディレクトリを見ることでわかる
/etc/libvirt/qemu/autostart

Packstackで起動したVMをみたがautostartにはなっていないよう

[shell]
[root@compute2 ~(keystone_admin)]# nova list
+————————————–+—————+——–+————+————-+————————————————+
| ID | Name | Status | Task State | Power State | Networks |
+————————————–+—————+——–+————+————-+————————————————+
| de512459-7c26-49f0-a8eb-9d98ca7f7b5d | Ubuntu | ACTIVE | – | Running | mgmt=192.168.1.1; |
+————————————–+—————+——–+————+————-+————————————————+
[root@compute2 ~(keystone_admin)]#
[root@compute2 ~(keystone_admin)]# nova show vCPE
+————————————–+———————————————————-+
| Property | Value |
+————————————–+———————————————————-+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | compute2 |
| OS-EXT-SRV-ATTR:host | compute2.example.com |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute2.example.com |
| OS-EXT-SRV-ATTR:instance_name | instance-00000047 |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | – |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2016-01-21T11:07:01.000000 |
| OS-SRV-USG:terminated_at | – |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2016-01-21T11:06:38Z |
| flavor | ubuntu (319b6c10-d496-4d2b-826f-73c448ed1378) |
| hostId | ed33f37b7b9d3776ad9aa97aa3542ba17b23296f976463038c0ac013 |
| id | de512459-7c26-49f0-a8eb-9d98ca7f7b5d |
| image | ubuntu (c3348809-d668-49c5-87b2-2170aa20a0c4) |
| key_name | admin-key |
| metadata | {} |
| mgmt network | 192.168.1.1 |
| name | Ubuntu |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default, default, default |
| status | ACTIVE |
| tenant_id | 0878842049044c09922ee918778b266f |
| updated | 2016-01-21T11:07:01Z |
| user_id | 915392655a75417886dcd2c9e4e25600 |
+————————————–+———————————————————-+
[root@compute2 ~(keystone_admin)]#
[root@compute2 ~(keystone_admin)]# virsh list
Id 名前 状態
—————————————————-
85 instance-00000047 実行中

[root@compute2 ~(keystone_admin)]#
[root@compute2 ~(keystone_admin)]# ls /etc/libvirt/qemu/autostart/
[root@compute2 ~(keystone_admin)]#
[/shell]

Openstack computeノード削除

OpenstackのComputeノードの削除の方法がなかったのでメモ。

  • Centos/Junoで確認。
    ただし、正しいドキュメントがないので、少々不安な手順

削除したいコンピュートノードの確認

[root@controller ~(keystone_admin)]# nova service-list
+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Binary           | Host       | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| nova-consoleauth | controller | internal | enabled | up    | 2016-02-10T02:00:17.000000 | -               |
| nova-scheduler   | controller | internal | enabled | up    | 2016-02-10T02:00:17.000000 | -               |
| nova-conductor   | controller | internal | enabled | up    | 2016-02-10T02:00:17.000000 | -               |
| nova-cert        | controller | internal | enabled | up    | 2016-02-10T02:00:16.000000 | -               |
| nova-compute     | compute2   | compute2 | enabled | up    | 2016-02-10T02:00:18.000000 | -               |
| nova-compute     | compute1   | compute1 | enabled | up    | 2016-02-10T02:00:18.000000 | -               |
+------------------+------------+----------+---------+-------+----------------------------+-----------------+

コンピュートノードのDisable

[root@controller ~(keystone_admin)]# nova-manage service disable --host=compute1 --service=nova-compute

コンピュートノードをDB上から削除

[root@controller ~(keystone_admin)]# mysql -u root -p
MariaDB [(none)] use nova;
MariaDB [nova] select id, hypervisor_hostname  from compute_nodes;
+----+-----------------------+
| id | hypervisor_hostname   |
+----+-----------------------+
|  1 | compute2              |
|  2 | compute1              |
+----+-----------------------+
1 row in set (0.00 sec)
MariaDB [nova] delete from compute_nodes where hypervisor_hostname='compute1'
MariaDB [nova] 
MariaDB [nova] select id,host from services;
+----+--------------+
| id | host         |
+----+--------------+
|  6 | compute1     |
|  5 | compute2     |
|  4 | controller   |
|  3 | controller   |
|  1 | controller   |
|  2 | controller   |
+----+--------------+
5 rows in set (0.00 sec)

MariaDB [nova] delete from services where host='compute1'
MariaDB [nova] 

OpenstackのAffinity

Openstackのaffinityについて

Icehouseからaffinityをサポートしているので、動作を確認。
Affinity/Anti-affinityはFilterとして実装されており、動作は以下の通り。

Affinityは同じサーバ上にVMを作成する

Anti-affinityは異なるサーバ上にVMを作成する
どのホストにも同じグループのVMが存在し、作成できない場合にはErrorとなる
有効化はnova.confからscheduler_default_filtersAffinityFilterを追加

nova.conf

nova/nova.conf:scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter

Affinity用のサーバグループの作成は以下のコマンド

# nova server-group-create --policy affinity test-affinity
+--------------------------------------+---------------+---------------+---------+----------+
| Id                                   | Name          | Policies      | Members | Metadata |
+--------------------------------------+---------------+---------------+---------+----------+
| 979912fe-a558-46e5-b3d2-1022104cd5b8 | test-affinity | [u'affinity'] | []      | {}       |
+--------------------------------------+---------------+---------------+---------+----------+

Anti-affinity用のサーバグループの作成は以下のコマンド

# nova server-group-create --policy anti-affinity test-anti-affinity
+--------------------------------------+--------------------+--------------------+---------+----------+
| Id                                   | Name               | Policies           | Members | Metadata |
+--------------------------------------+--------------------+--------------------+---------+----------+
| dacf95e9-e1d5-4ec9-ae6a-c45ea87f417d | test-anti-affinity | [u'anti-affinity'] | []      | {}       |
+--------------------------------------+--------------------+--------------------+---------+----------+

作成したサーバグループの確認は以下のコマンド

# nova server-group-list
+--------------------------------------+--------------------+--------------------+---------+----------+
| Id                                   | Name               | Policies           | Members | Metadata |
+--------------------------------------+--------------------+--------------------+---------+----------+
| 979912fe-a558-46e5-b3d2-1022104cd5b8 | test-affinity      | [u'affinity']      | []      | {}       |
| dacf95e9-e1d5-4ec9-ae6a-c45ea87f417d | test-anti-affinity | [u'anti-affinity'] | []      | {}       |
+--------------------------------------+--------------------+--------------------+---------+----------+

NovaのVM作成コマンドは以下の通り

# nova boot --flavor m1.tiny --image ubuntu --hint group=test-anti-affinity ubuntu-test