Ubuntu 12.04
Sponsored Link

OpenStack Havana - インスタンスを起動する2013/11/22

 
仮想マシンインスタンスを起動してみます。
[1] まずは、仮想マシンインスタンスが内部で利用するネットワークを作成しておきます。
# nova-manage network create --label (任意の名前) --dns1 (参照するDNS) --fixed_range_v4=(内部ネットワークの範囲)

root@dlp ~(keystone)#
nova-manage network create --label network01 --dns1 10.0.0.10 --fixed_range_v4=10.1.0.0/24

root@dlp ~(keystone)#
nova-manage network list

id   IPv4           IPv6   start address   DNS1        DNS2    VlanID   project   uuid
1    10.1.0.0/24    None   10.1.0.2        10.0.0.10   None    None     None      a02b7b6d-1fb1-
[2] 起動した仮想マシンインスタンスにSSHで接続できるように、デフォルトセキュリティグループにポート許可の設定をしておきます。
# SSH 許可

root@dlp ~(keystone)#
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

# ICMP 許可

root@dlp ~(keystone)#
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+

root@dlp ~(keystone)#
nova secgroup-list-rules default

+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range  | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp         | 22        | 22      | 0.0.0.0/0 |              |
| icmp        | -1        | -1      | 0.0.0.0/0 |              |
+-------------+-----------+---------+-----------+--------------+
[3] 仮想マシンインスタンスに割り当てるメモリ容量やストレージ容量等々を指定して (flavor)、 インスタンスを作成して起動します。
# デフォルトの flavor 一覧

root@dlp ~(keystone)#
nova flavor-list

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

# 登録されているイメージ

root@dlp ~(keystone)#
nova image-list

+--------------------------------------+-------------+--------+--------+
| ID                                   | Name        | Status | Server |
+--------------------------------------+-------------+--------+--------+
| 424a8c60-8cde-4601-9cdf-65da03062ab4 | Ubuntu13.10 | ACTIVE |        |
+--------------------------------------+-------------+--------+--------+

# インスタンス作成・起動

root@dlp ~(keystone)#
nova boot --flavor 2 --image Ubuntu13.10 --security_group default Ubuntu_Saucy

+--------------------------------------+--------------------------------------+
| Property                             | Value                                |
+--------------------------------------+--------------------------------------+
| OS-EXT-STS:task_state                | scheduling                           |
| image                                | Ubuntu13.10                          |
| OS-EXT-STS:vm_state                  | building                             |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000004                    |
| OS-SRV-USG:launched_at               | None                                 |
| flavor                               | m1.small                             |
| id                                   | e4eddb40-a07e-42b0-8c35-0a37b90a027b |
| security_groups                      | [{u'name': u'default'}]              |
| user_id                              | 7dacb8c4d511463d9bfb35f209ecb833     |
| OS-DCF:diskConfig                    | MANUAL                               |
| accessIPv4                           |                                      |
| accessIPv6                           |                                      |
| progress                             | 0                                    |
| OS-EXT-STS:power_state               | 0                                    |
| OS-EXT-AZ:availability_zone          | nova                                 |
| config_drive                         |                                      |
| status                               | BUILD                                |
| updated                              | 2013-11-22T05:45:33Z                 |
| hostId                               |                                      |
| OS-EXT-SRV-ATTR:host                 | None                                 |
| OS-SRV-USG:terminated_at             | None                                 |
| key_name                             | None                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                 |
| name                                 | Ubuntu_Saucy                         |
| adminPass                            | 7HSy5eBtSGpL                         |
| tenant_id                            | efa4897fa0314da9b983d20ceaf81a96     |
| created                              | 2013-11-22T05:45:32Z                 |
| os-extended-volumes:volumes_attached | []                                   |
| metadata                             | {}                                   |
+--------------------------------------+--------------------------------------+

# 動作確認 (起動直後しばらくは「BUILD」ステータスとなっている)

root@dlp ~(keystone)#
nova list

+------------+--------------+--------+------------+-------------+--------------------+
| ID         | Name         | Status | Task State | Power State | Networks           |
+------------+--------------+--------+------------+-------------+--------------------+
| e4eddb40-a | Ubuntu_Saucy | BUILD  | spawning   | NOSTATE     | network01=10.1.0.2 |
+------------+--------------+--------+------------+-------------+--------------------+
[4] 起動した仮想マシンインスタンスにログインできるか確認してみます。
# 起動後しばらくすると以下のように「ACTIVE」ステータスとなる

root@dlp ~(keystone)#
nova list

+------------+--------------+--------+------------+-------------+--------------------+
| ID         | Name         | Status | Task State | Power State | Networks           |
+------------+--------------+--------+------------+-------------+--------------------+
| e4eddb40-a | Ubuntu_Saucy | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+--------------+--------+------------+-------------+--------------------+

# 以下のように応答が返ってくればOK

root@dlp ~(keystone)#
ping 10.1.0.2

PING 10.1.0.2 (10.1.0.2) 56(84) bytes of data.
64 bytes from 10.1.0.2: icmp_req=1 ttl=64 time=0.431 ms
64 bytes from 10.1.0.2: icmp_req=2 ttl=64 time=0.267 ms
^C
--- 10.1.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.267/0.349/0.431/0.082 ms

# SSH でログイン

root@dlp ~(keystone)#
ssh ubuntu@10.1.0.2

The authenticity of host '10.1.0.2 (10.1.0.2)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:bd:a5:06.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.0.2' (ECDSA) to the list of known hosts.
ubuntu@10.1.0.2's password:
Last login: Fri Nov 22 13:10:55 2013
ubuntu@ubuntu:~$    
# ログインできた

[5] 一旦作成して起動した仮想マシンインスタンスを停止する場合は、 仮想マシンインスタンス内から shutdown コマンドを打てばもちろん停止できますが、 以下のように nova コマンドでも制御できます。
root@dlp ~(keystone)#
nova list

+------------+--------------+--------+------------+-------------+--------------------+
| ID         | Name         | Status | Task State | Power State | Networks           |
+------------+--------------+--------+------------+-------------+--------------------+
| e4eddb40-a | Ubuntu_Saucy | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+--------------+--------+------------+-------------+--------------------+

# インスタンス停止

root@dlp ~(keystone)#
nova stop Ubuntu_Saucy

root@dlp ~(keystone)#
nova list

+------------+--------------+---------+------------+-------------+--------------------+
| ID         | Name         | Status  | Task State | Power State | Networks           |
+------------+--------------+---------+------------+-------------+--------------------+
| e4eddb40-a | Ubuntu_Saucy | SHUTOFF | None       | Shutdown    | network01=10.1.0.2 |
+------------+--------------+---------+------------+-------------+--------------------+

# インスタンスを再度起動する

root@dlp ~(keystone)#
nova start Ubuntu_Saucy

root@dlp ~(keystone)#
nova list

+------------+--------------+--------+------------+-------------+--------------------+
| ID         | Name         | Status | Task State | Power State | Networks           |
+------------+--------------+--------+------------+-------------+--------------------+
| e4eddb40-a | Ubuntu_Saucy | ACTIVE | None       | Running     | network01=10.1.0.2 |
+------------+--------------+--------+------------+-------------+--------------------+
関連コンテンツ