CentOS 7
Sponsored Link

OpenStack Mitaka (三鷹) : インスタンスを起動する
2016/04/12
 
仮想マシンインスタンスを起動します。
[1] 仮想マシンインスタンスに割り当てるメモリ容量やストレージ容量等々を指定して (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 |
+--------------------------------------+---------+--------+--------+
| 087d827e-3c60-41fb-8592-a234a3bf15c5 | CentOS7 | ACTIVE |        |
+--------------------------------------+---------+--------+--------+

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

[root@dlp ~(keystone)]#
nova boot --flavor 2 --image CentOS7 --security-groups default CentOS_7

+--------------------------------------+------------------------------------------------+
| Property                             | Value                                          |
+--------------------------------------+------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                         |
| OS-EXT-AZ:availability_zone          |                                                |
| OS-EXT-SRV-ATTR:host                 | -                                              |
| OS-EXT-SRV-ATTR:hostname             | centos-7                                       |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                              |
| OS-EXT-SRV-ATTR:instance_name        | instance-00000001                              |
| OS-EXT-SRV-ATTR:kernel_id            |                                                |
| OS-EXT-SRV-ATTR:launch_index         | 0                                              |
| OS-EXT-SRV-ATTR:ramdisk_id           |                                                |
| OS-EXT-SRV-ATTR:reservation_id       | r-6ezp4mtg                                     |
| OS-EXT-SRV-ATTR:root_device_name     | -                                              |
| OS-EXT-SRV-ATTR:user_data            | -                                              |
| 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                            | JcXGw3Uz7xgF                                   |
| config_drive                         |                                                |
| created                              | 2016-04-12T13:27:01Z                           |
| description                          | -                                              |
| flavor                               | m1.small (2)                                   |
| hostId                               |                                                |
| host_status                          |                                                |
| id                                   | 58968e9b-6d9c-4a2e-84d3-cad5b4a4a14b           |
| image                                | CentOS7 (087d827e-3c60-41fb-8592-a234a3bf15c5) |
| key_name                             | -                                              |
| locked                               | False                                          |
| metadata                             | {}                                             |
| name                                 | CentOS_7                                       |
| os-extended-volumes:volumes_attached | []                                             |
| progress                             | 0                                              |
| security_groups                      | default                                        |
| status                               | BUILD                                          |
| tenant_id                            | c70760f08db7408e908c7d035eae109a               |
| updated                              | 2016-04-12T13:27:01Z                           |
| user_id                              | a8ecde7bd78c430d903ff7aa7672559e               |
+--------------------------------------+------------------------------------------------+

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

[root@dlp ~(keystone)]#
nova list

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

[root@dlp ~(keystone)]#
nova list

+-----------+----------+--------+------------+-------------+--------------------+
| ID        | Name     | Status | Task State | Power State | Networks           |
+-----------+----------+--------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+-----------+----------+--------+------------+-------------+--------------------+

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

[root@dlp ~(keystone)]#
ping 10.1.0.2

[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_seq=1 ttl=64 time=0.476 ms
64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.378 ms

--- 10.1.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.378/0.427/0.476/0.049 ms

# SSH でログイン

[root@dlp ~(keystone)]#
ssh 10.1.0.2

The authenticity of host '10.1.0.2 (10.1.0.2)' can't be established.
ECDSA key fingerprint is 65:14:3a:1b:38:a9:04:ef:ea:d0:54:32:b4:4c:f1:46.
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.
root@10.1.0.2's password:    
# インストール時に設定した root パスワード

Last login: Tue Apr 12 22:20:02 2016
[root@centos-7 ~]#    
# ログインできた

[3] インターネットから取得した仮想マシンイメージを利用中でパスワードが不明な場合は、SSH鍵を登録することでログイン可能です。
# キーペア作成

[root@dlp ~(keystone)]#
ssh-keygen -f mykey -q -N ""

# 公開鍵登録

[root@dlp ~(keystone)]#
openstack keypair create --public-key mykey.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 6a:45:27:e4:f2:d0:61:e3:cd:af:10:c7:4f:f9:f0:51 |
| name        | mykey                                           |
| user_id     | f9c0838d5fcf4a87ba2e0b1653faa6d0                |
+-------------+-------------------------------------------------+

[root@dlp ~(keystone)]#
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 6a:45:27:e4:f2:d0:61:e3:cd:af:10:c7:4f:f9:f0:51 |
+-------+-------------------------------------------------+

# キーを指定してインスタンス作成・起動

[root@dlp ~(keystone)]#
nova boot --flavor 2 --image CentOS7 --security-groups default --key-name mykey CentOS_7
[root@dlp ~(keystone)]#
nova list

+-----------+----------+--------+------------+-------------+--------------------+
| ID        | Name     | Status | Task State | Power State | Networks           |
+-----------+----------+--------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+-----------+----------+--------+------------+-------------+--------------------+

# 起動後はキーを指定してログイン

[root@dlp ~(keystone)]#
ssh -i mykey 10.1.0.2
[root@centos-7 ~]#    
# ログインできた

[4] 一旦作成して起動した仮想マシンインスタンスを停止/起動する場合は、以下のように nova コマンドで制御できます。
[root@dlp ~(keystone)]#
nova list

+-----------+----------+--------+------------+-------------+--------------------+
| ID        | Name     | Status | Task State | Power State | Networks           |
+-----------+----------+--------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+-----------+----------+--------+------------+-------------+--------------------+

# インスタンス停止

[root@dlp ~(keystone)]#
nova stop CentOS_7

Request to stop server CentOS_7 has been accepted.
[root@dlp ~(keystone)]#
nova list

+-----------+----------+---------+------------+-------------+--------------------+
| ID        | Name     | Status  | Task State | Power State | Networks           |
+-----------+----------+---------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | SHUTOFF | -          | Shutdown    | network01=10.1.0.2 |
+-----------+----------+---------+------------+-------------+--------------------+

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

[root@dlp ~(keystone)]#
nova start CentOS_7

Request to start server CentOS_7 has been accepted.
[root@dlp ~(keystone)]#
nova list

+-----------+----------+--------+------------+-------------+--------------------+
| ID        | Name     | Status | Task State | Power State | Networks           |
+-----------+----------+--------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+-----------+----------+--------+------------+-------------+--------------------+
[5] VNC コンソールを取得して Web ブラウザでのアクセスも可能です。
[root@dlp ~(keystone)]#
nova list

+-----------+----------+--------+------------+-------------+--------------------+
| ID        | Name     | Status | Task State | Power State | Networks           |
+-----------+----------+--------+------------+-------------+--------------------+
| 58968e9b- | CentOS_7 | ACTIVE | -          | Running     | network01=10.1.0.2 |
+-----------+----------+--------+------------+-------------+--------------------+

[root@dlp ~(keystone)]#
nova get-vnc-console CentOS_7 novnc

+-------+--------------------------------------------------------------------------------+
| Type  | Url                                                                            |
+-------+--------------------------------------------------------------------------------+
| novnc | http://10.0.0.30:6080/vnc_auto.html?token=67e01967-8c31-47aa-a2a7-8c6ae8ed7415 |
+-------+--------------------------------------------------------------------------------+
[6] get-vnc-console で表示された URL にアクセスすると、インスタンスにアクセスして操作可能です。
関連コンテンツ
 
Tweet