OpenStack Mitaka (三鷹) : インスタンスを起動する2016/05/20 |
仮想マシンインスタンスを起動します。
|
|
[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 | +--------------------------------------+------------+--------+--------+ | 14679af9-2662-46ea-a40e-37820d1af5f4 | Ubuntu1604 | ACTIVE | | +--------------------------------------+------------+--------+--------+ # インスタンス作成・起動 root@dlp ~(keystone)# nova boot --flavor 2 --image Ubuntu1604 --security-groups default Ubuntu_1604 +--------------------------------------+---------------------------------------------------+ | Property | Value | +--------------------------------------+---------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hostname | ubuntu-1604 | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | instance-00000003 | | 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-x1om1f5u | | 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 | HgZRyvrKGQQ9 | | config_drive | | | created | 2016-05-20T12:52:12Z | | description | - | | flavor | m1.small (2) | | hostId | | | host_status | | | id | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | | image | Ubuntu1604 (14679af9-2662-46ea-a40e-37820d1af5f4) | | key_name | - | | locked | False | | metadata | {} | | name | Ubuntu_1604 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | 61bb62a97e394b8db8f95aa05a678771 | | updated | 2016-05-20T12:52:13Z | | user_id | 45bb5ebf547f4be2a21bf4a07c83ad85 | +--------------------------------------+---------------------------------------------------+ # 動作確認 (起動直後しばらくは「BUILD」ステータスとなっている) root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | BUILD | spawning | NOSTATE | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ |
[2] | 起動した仮想マシンインスタンスにログインできるか確認します。 |
# 起動後しばらくすると以下のように「ACTIVE」ステータスとなる root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | - | Running | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ # 以下のように応答が返ってくればOK root@dlp ~(keystone)# ping 10.1.0.2 64 bytes from 10.1.0.2: icmp_seq=1 ttl=64 time=0.301 ms 64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.232 ms --- 10.1.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.232/0.266/0.301/0.038 ms # 仮想マシンインストールで追加したユーザーで SSH ログイン root@dlp ~(keystone)# ssh xerus@10.1.0.2
The authenticity of host '10.1.0.2 (10.1.0.2)' can't be established.
ECDSA key fingerprint is 9e:7d:63:ad:c8:96:67:f3:0f:f3:bc:fc:62:81:08:63.
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.
xerus@10.1.0.2's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-22-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Fri May 20 21:36:22 2016
xerus@ubuntu:~$ # ログインできた |
[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 | b0:ff:b1:db:cd:ae:42:9d:e0:aa:81:9f:c9:87:55:1e | | name | mykey | | user_id | 45bb5ebf547f4be2a21bf4a07c83ad85 | +-------------+-------------------------------------------------+root@dlp ~(keystone)# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | b0:ff:b1:db:cd:ae:42:9d:e0:aa:81:9f:c9:87:55:1e | +-------+-------------------------------------------------+ # キーを指定してインスタンス作成・起動 root@dlp ~(keystone)# nova boot --flavor 2 --image Ubuntu1604 --security-groups default --key-name mykey Ubuntu16_04_1
nova list +--------------------------------------+---------------+---------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+---------------+---------+------------+-------------+--------------------+ | c778a47b-9879-42bb-a949-1e9e26cbb35f | Ubuntu16_04_1 | ACTIVE | - | Running | network01=10.1.0.6 | +--------------------------------------+---------------+---------+------------+-------------+--------------------+ # 起動後はキーを指定してデフォルトユーザー「ubuntu」でログイン root@dlp ~(keystone)# ssh -i mykey ubuntu@10.1.0.6
# ログインできた |
[4] | 一旦作成して起動した仮想マシンインスタンスを停止/起動する場合は、以下のように nova コマンドで制御できます。 |
root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | - | Running | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ # インスタンス停止 root@dlp ~(keystone)# nova stop Ubuntu_1604 Request to stop server Ubuntu_1604 has been accepted. root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | SHUTOFF | - | Running | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ # インスタンスを再度起動する root@dlp ~(keystone)# nova start Ubuntu_1604 Request to start server Ubuntu_1604 has been accepted. root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | - | Running | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ |
[5] | VNC コンソールを取得して Web ブラウザでのアクセスも可能です。 |
root@dlp ~(keystone)# nova list +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+-------------+--------+------------+-------------+--------------------+ | 80dacb2a-ec4d-4e06-a3bf-a5bef8be491f | Ubuntu_1604 | ACTIVE | - | Running | network01=10.1.0.2 | +--------------------------------------+-------------+--------+------------+-------------+--------------------+root@dlp ~(keystone)# nova get-vnc-console Ubuntu_1604 novnc +-------+--------------------------------------------------------------------------------+ | Type | Url | +-------+--------------------------------------------------------------------------------+ | novnc | http://10.0.0.30:6080/vnc_auto.html?token=9a44fd6f-cfe2-4593-9be1-93ae80244e7b | +-------+--------------------------------------------------------------------------------+ |
[6] | get-vnc-console で表示された URL にアクセスすると、インスタンスにアクセスして操作可能です。 |
Sponsored Link |
|