Openstack運用メンテナンス実戦シリーズ(10)のnova指定computeノードとIPアドレス
1.背景需要
Openstackでは、novaはopenstack仮想マシンのライフサイクルの管理を担当し、neutronは仮想マシンのネットワーク管理を担当します.デフォルトでは、novaはnova-schedulerスケジューリングアルゴリズムに基づいて、最適なcomputeノードを選択し、neutronのアドレスプールからipアドレスを仮想マシンに割り当てます.これにより、仮想マシンの作成プロセスが完了します.
しかし、いくつかの特殊なシーンでは、同じ業務の仮想マシンのように、通じないcomputeノードに落ちて、仮想マシンに既存のipアドレスを割り当てることを望んでいる場合、nova内蔵のスケジューリングでは実現しにくい場合や、いくつかのアプリケーションシーンでは、企業のCMDB連動に基づいて、同じ業務の仮想マシンをopenstack novaに散らばっている異なるノードを、これによりdown機の確率を低減し、故障の発生を低減する.ここでは、指定したcomputeノードにinstanceを作成し、固定ipアドレスを割り当てる例を示します.
2.instanceを作成するための基本情報の取得ミラーイメージid取得
2.コースflavor idを取得
3.セキュリティグループidの取得
4.keypairの取得
5.neutronネットワークid番号の取得
6.coomputeのホスト名とzone名を取得する
3.指定したcomputeノードで仮想マシンを起動し、固定ipアドレスを指定する
構成の検証
4.まとめ
以上の方法はopenstackの日常的な次元で使用され、一般的には使用を推奨せず、nova内蔵のスケジューリングアルゴリズムを使用して完了することを推奨します.本人は実际の仕事の中で、いつもcompute机械を指定してipの需要を指定します.
5.付録
付録はnova bootの使い方に関するパラメータを提供しています
[root@controller ~]# nova help boot
usage: nova boot [--flavor] [--image ]
[--image-with] [--boot-volume ]
[--snapshot] [--num-instances ]
[--meta] [--file ]
[--key-name] [--user-data ]
[--availability-zone]
[--security-groups]
[--block-device-mapping]
[--block-device key1=value1[,key2=value2...]]
[--swap]
[--ephemeral size=[,format=]]
[--hint]
[--nic]
[--config-drive] [--poll]
Boot a new server.
Positional arguments:
Name for the new server
Optional arguments:
--flavor Name or ID of flavor (see 'nova flavor-list').
--image Name or ID of image (see 'nova image-list').
--image-with
Image metadata property (see 'nova image-show').
--boot-volume
Volume ID to boot from.
--snapshot
Snapshot ID to boot from (will create a volume).
--num-instances
boot multiple servers at a time (limited by quota).
--meta Record arbitrary key/value metadata to/meta.js on the
new server. Can be specified multiple times.
--file
Store arbitrary files from locally to path> on the new server. You may store up to 5 files.
--key-name
Key name of keypair that should be created earlier
with the command keypair-add
--user-data
user data file to pass to be exposed by the metadata
server.
--availability-zone
The availability zone for server placement.
--security-groups
Comma separated list of security group names.
--block-device-mapping
Block device mapping in the format name>=:::.
--block-device key1=value1[,key2=value2...]
Block device mapping with the keys: id=image_id,
snapshot_id or volume_id, source=source type (image,
snapshot, volume or blank), dest=destination type of
the block device (volume or local), bus=device's bus,
device=name of the device (e.g. vda, xda, ...),
size=size of the block device in GB, format=device
will be formatted (e.g. swap, ext3, ntfs, ...),
bootindex=integer used for ordering the boot disks,
type=device type (e.g. disk, cdrom, ...) and
shutdown=shutdown behaviour (either preserve or
remove).
--swap Create and attach a local swap block device of
MB.
--ephemeral size=[,format=]
Create and attach a local ephemeral block device of
GB and format it to .
--hint Send arbitrary key/value pairs to the scheduler for
custom use.
--nic
Create a NIC on the server. Specify option multiple
times to create multiple NICs. net-id: attach NIC to
network with this UUID (required if no port-id), v4
-fixed-ip: IPv4 fixed address for NIC (optional),
port-id: attach NIC to port with this UUID (required
if no net-id)
--config-drive
Enable config drive
--poll Blocks while server builds so progress can be
reported.
本文は“Happy実験室”のブログから出て、転載して作者と連絡してください!
Openstackでは、novaはopenstack仮想マシンのライフサイクルの管理を担当し、neutronは仮想マシンのネットワーク管理を担当します.デフォルトでは、novaはnova-schedulerスケジューリングアルゴリズムに基づいて、最適なcomputeノードを選択し、neutronのアドレスプールからipアドレスを仮想マシンに割り当てます.これにより、仮想マシンの作成プロセスが完了します.
しかし、いくつかの特殊なシーンでは、同じ業務の仮想マシンのように、通じないcomputeノードに落ちて、仮想マシンに既存のipアドレスを割り当てることを望んでいる場合、nova内蔵のスケジューリングでは実現しにくい場合や、いくつかのアプリケーションシーンでは、企業のCMDB連動に基づいて、同じ業務の仮想マシンをopenstack novaに散らばっている異なるノードを、これによりdown機の確率を低減し、故障の発生を低減する.ここでは、指定したcomputeノードにinstanceを作成し、固定ipアドレスを割り当てる例を示します.
2.instanceを作成するための基本情報の取得
[root@controller ~]# glance image-list
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
| 37aaedc7-6fe6-4fc8-b110-408d166b8e51 | cirrors | qcow2 | bare | 13200896 | active | # instance image id
| ff0f7d03-a553-4357-a819-c74e913d649f | win2k8 | qcow2 | bare | 3391881216 | active |
+--------------------------------------+--------------------------+-------------+------------------+-------------+--------+
2.コースflavor idを取得
[root@controller ~]# nova flavor-list
+--------------------------------------+------------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+------------------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.large | 8192 | 100 | 10 | | 4 | 1.0 | True |
| 10 | V.GF1 | 8192 | 10 | 0 | | 4 | 1.0 | True | # flavor id
3.セキュリティグループidの取得
[root@controller ~]# nova secgroup-list
+--------------------------------------+---------+-------------+
| Id | Name | Description |
+--------------------------------------+---------+-------------+
| 663468d9-73b1-4b04-8d4c-dac1bf21a94d | default | default | #secgroup id
+--------------------------------------+---------+-------------+
4.keypairの取得
[root@controller ~]# nova keypair-list
+------+-------------------------------------------------+
| Name | Fingerprint |
+------+-------------------------------------------------+
| KEY | 15:63:f2:de:74:53:a1:03:eb:36:27:e6:d9:00:41:22 | #keypair
+------+-------------------------------------------------+
5.neutronネットワークid番号の取得
[root@controller ~]# neutron net-list
+--------------------------------------+---------------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+---------------+-------------------------------------------------------+
| 99c68a93-336a-4605-aa78-343d41ca1206 | vmTest | 79cb82a1-eac1-4311-8e6d-badcabd22e44 192.168.100.0/24 | # id
+--------------------------------------+---------------+-------------------------------------------------------+
6.coomputeのホスト名とzone名を取得する
[root@controller ~]# nova service-list
+------------------+-------------------------+-------------------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+-------------------------+-------------------+---------+-------+----------------------------+-----------------+
| nova-conductor | ChuangYiYuan_10_16_2_8 | internal | enabled | up | 2016-01-23T04:54:58.000000 | - |
| nova-cert | ChuangYiYuan_10_16_2_8 | internal | enabled | up | 2016-01-23T04:54:52.000000 | - |
| nova-consoleauth | ChuangYiYuan_10_16_2_8 | internal | enabled | up | 2016-01-23T04:54:57.000000 | - |
| nova-scheduler | ChuangYiYuan_10_16_2_8 | internal | enabled | up | 2016-01-23T04:54:57.000000 | - |
| nova-compute | ChuangYiYuan_10_16_2_11 | ChuangYiYuanZone1 | enabled | up | 2016-01-23T04:54:56.000000 | - | # compute
| nova-compute | ChuangYiYuan_10_16_2_14 | ChuangYiYuanZone1 | enabled | up | 2016-01-23T04:54:56.000000 | - |
3.指定したcomputeノードで仮想マシンを起動し、固定ipアドレスを指定する
[root@controller ~]# nova boot --flavor 10 \ #flavor
--image 37aaedc7-6fe6-4fc8-b110-408d166b8e51 \ # id
--key-name KEY \ #KEY
--availability-zone ChuangYiYuanZone1:ChuangYiYuan_10_16_2_11 \ # instance
--security-groups 663468d9-73b1-4b04-8d4c-dac1bf21a94d \ #
--nic net-id=99c68a93-336a-4605-aa78-343d41ca1206,v4-fixed-ip=192.168.100.200 happyblog_blog_51cto_com # IP
+--------------------------------------+------------------------------------------------+
| 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-000001f9 |
| 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 | 4T3vpfaXPTZe |
| config_drive | |
| created | 2016-01-23T04:44:51Z |
| flavor | V.GF1 (10) |
| hostId | |
| id | 3f694eaf-aa87-456a-99ce-90dd9f4e45ee |
| image | cirrors (37aaedc7-6fe6-4fc8-b110-408d166b8e51) |
| key_name | KEY |
| metadata | {} |
| name | happyblog_blog_51cto_com |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | 663468d9-73b1-4b04-8d4c-dac1bf21a94d |
| status | BUILD |
| tenant_id | 842ab3268a2c47e6a4b0d8774de805ae |
| updated | 2016-01-23T04:44:52Z |
| user_id | bc5e46fc4204497185ae3ca6f8b7affb |
+--------------------------------------+------------------------------------------------+
構成の検証
[root@controller ~]# nova list | grep 3f694eaf-aa87-456a-99ce-90dd9f4e45ee
| 3f694eaf-aa87-456a-99ce-90dd9f4e45ee | happyblog_blog_51cto_com | ACTIVE | - | Running | vmTest=192.168.100.200 | ChuangYiYuan_10_16_2_11 |
[root@controller ~]# nova show 3f694eaf-aa87-456a-99ce-90dd9f4e45ee
+--------------------------------------+----------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | ChuangYiYuanZone1 |
| OS-EXT-SRV-ATTR:host | ChuangYiYuan_10_16_2_11 | # compute
| OS-EXT-SRV-ATTR:hypervisor_hostname | ChuangYiYuan_10_16_2_11 |
| OS-EXT-SRV-ATTR:instance_name | instance-000001f9 |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2016-01-23T04:45:06.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2016-01-23T04:44:51Z |
| flavor | V.GF1 (10) |
| hostId | b3a37b586ae2847a0b18c58ff7693b41762fa0bf6a3cc363c862761a |
| id | 3f694eaf-aa87-456a-99ce-90dd9f4e45ee |
| image | cirrors (37aaedc7-6fe6-4fc8-b110-408d166b8e51) |
| key_name | KEY |
| metadata | {} |
| name | happyblog_blog_51cto_com |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | ACTIVE |
| tenant_id | 842ab3268a2c47e6a4b0d8774de805ae |
| updated | 2016-01-23T04:45:07Z |
| user_id | bc5e46fc4204497185ae3ca6f8b7affb |
| vmTest network | 192.168.100.200 | # ip ,good,
+--------------------------------------+----------------------------------------------------------+
4.まとめ
以上の方法はopenstackの日常的な次元で使用され、一般的には使用を推奨せず、nova内蔵のスケジューリングアルゴリズムを使用して完了することを推奨します.本人は実际の仕事の中で、いつもcompute机械を指定してipの需要を指定します.
5.付録
付録はnova bootの使い方に関するパラメータを提供しています
[root@controller ~]# nova help boot
usage: nova boot [--flavor
[--image-with
[--snapshot
[--meta
[--key-name
[--availability-zone
[--security-groups
[--block-device-mapping
[--block-device key1=value1[,key2=value2...]]
[--swap
[--ephemeral size=
[--hint
[--nic
[--config-drive
Boot a new server.
Positional arguments:
Optional arguments:
--flavor
--image Name or ID of image (see 'nova image-list').
--image-with
Image metadata property (see 'nova image-show').
--boot-volume
Volume ID to boot from.
--snapshot
Snapshot ID to boot from (will create a volume).
--num-instances
boot multiple servers at a time (limited by quota).
--meta
new server. Can be specified multiple times.
--file
Store arbitrary files from
--key-name
Key name of keypair that should be created earlier
with the command keypair-add
--user-data
user data file to pass to be exposed by the metadata
server.
--availability-zone
The availability zone for server placement.
--security-groups
Comma separated list of security group names.
--block-device-mapping
Block device mapping in the format
--block-device key1=value1[,key2=value2...]
Block device mapping with the keys: id=image_id,
snapshot_id or volume_id, source=source type (image,
snapshot, volume or blank), dest=destination type of
the block device (volume or local), bus=device's bus,
device=name of the device (e.g. vda, xda, ...),
size=size of the block device in GB, format=device
will be formatted (e.g. swap, ext3, ntfs, ...),
bootindex=integer used for ordering the boot disks,
type=device type (e.g. disk, cdrom, ...) and
shutdown=shutdown behaviour (either preserve or
remove).
--swap
--ephemeral size=
Create and attach a local ephemeral block device of
--hint
custom use.
--nic
Create a NIC on the server. Specify option multiple
times to create multiple NICs. net-id: attach NIC to
network with this UUID (required if no port-id), v4
-fixed-ip: IPv4 fixed address for NIC (optional),
port-id: attach NIC to port with this UUID (required
if no net-id)
--config-drive
Enable config drive
--poll Blocks while server builds so progress can be
reported.
本文は“Happy実験室”のブログから出て、転載して作者と連絡してください!