OpenStack Newton : インスタンスを起動する2016/11/15 |
仮想マシンインスタンスを起動します。
|
|
[1] | 仮想マシンインスタンスに割り当てるメモリ容量やストレージ容量等々を指定して (flavor)、 インスタンスを作成して起動します。 |
# flavor 作成 root@dlp ~(keystone)# openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 10 m1.small +----------------------------+----------+ | Field | Value | +----------------------------+----------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 10 | | id | 0 | | name | m1.small | | os-flavor-access:is_public | True | | properties | | | ram | 2048 | | rxtx_factor | 1.0 | | swap | | | vcpus | 1 | +----------------------------+----------+[root@dlp ~(keystone)]# openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+ # 登録されているイメージ root@dlp ~(keystone)# openstack image list +--------------------------------------+------------+--------+ | ID | Name | Status | +--------------------------------------+------------+--------+ | 7d0cf100-6017-448c-9a6b-5bcf20d93f73 | Ubuntu1604 | active | +--------------------------------------+------------+--------+ # インスタンス作成・起動 root@dlp ~(keystone)# openstack server create --flavor m1.small --image Ubuntu1604 --security-group default Ubuntu_1604 +--------------------------------------+---------------------------------------+ | Field | Value | +--------------------------------------+---------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | None | | OS-EXT-SRV-ATTR:hypervisor_hostname | None | | OS-EXT-SRV-ATTR:instance_name | | | OS-EXT-STS:power_state | NOSTATE | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | None | | OS-SRV-USG:terminated_at | None | | accessIPv4 | | | accessIPv6 | | | addresses | | | adminPass | xJJwHb7JPhFk | | config_drive | | | created | 2016-11-18T01:51:33Z | | flavor | m1.small (0) | | hostId | | | id | 85f58053-c095-4f07-ae4a-d953ff2d6f9e | | image | Ubuntu1604 (7d0cf100-6017-448c-9a6b- | | | 5bcf20d93f73) | | key_name | None | | name | Ubuntu_1604 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | project_id | 1b8227c2c89e4f1cbcbbb9f6060b0416 | | properties | | | security_groups | [{u'name': u'default'}] | | status | BUILD | | updated | 2016-11-18T01:51:33Z | | user_id | b48cbdf1975f4fd3987f83a100cc9162 | +--------------------------------------+---------------------------------------+ # 動作確認 (起動直後しばらくは「BUILD」ステータスとなっている) root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | BUILD | network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+ |
[2] | 起動した仮想マシンインスタンスにログインできるか確認します。 |
# 起動後しばらくすると以下のように「ACTIVE」ステータスとなる root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+ # 以下のように応答が返ってくればOK root@dlp ~(keystone)# ping 10.1.0.5 PING 10.1.0.5 (10.1.0.5) 56(84) bytes of data. 64 bytes from 10.1.0.5: icmp_seq=1 ttl=64 time=0.593 ms 64 bytes from 10.1.0.5: icmp_seq=2 ttl=64 time=0.668 ms --- 10.1.0.5 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.593/0.630/0.668/0.045 ms # イメージ設定の際、SSHパスワード認証を許可にした場合はパスワード認証ログイン可能 root@dlp ~(keystone)# ssh ubuntu@10.1.0.5
The authenticity of host '10.1.0.5 (10.1.0.5)' can't be established.
ECDSA key fingerprint is SHA256:NoqFVWmGttBMBLbGJpCKEXP0I3fnvSPS87R2/apPJZY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.0.5' (ECDSA) to the list of known hosts.
ubuntu@10.1.0.5's password:
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Last login: Fri Nov 18 10:36:51 2016
ubuntu@ubuntu-1604:~$ # ログインできた |
[3] | イメージ設定の際に SSH パスワード認証を許可にしなかった場合や、インターネットから取得した仮想マシンイメージを利用中の場合は、SSH 鍵を登録することでログイン可能です。 |
# キーペア作成 root@dlp ~(keystone)# ssh-keygen -q -N "" # 公開鍵登録 root@dlp ~(keystone)# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | 85:09:a8:2d:dd:4f:1d:b0:17:e8:98:36:10:9d:19:31 | | name | mykey | | user_id | b48cbdf1975f4fd3987f83a100cc9162 | +-------------+-------------------------------------------------+root@dlp ~(keystone)# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 85:09:a8:2d:dd:4f:1d:b0:17:e8:98:36:10:9d:19:31 | +-------+-------------------------------------------------+ # キーを指定してインスタンス作成・起動 root@dlp ~(keystone)# openstack server create --flavor m1.small --image Ubuntu1604 --security-group default --key-name mykey Ubuntu16_04_1
openstack server list +-----------------+---------------+---------+-------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------------+---------------+---------+-------------------+------------+ | 59e49a9d-946b-4 | Ubuntu16_04_1 | ACTIVE | network01=10.1.0. | Ubuntu1604 | | a63-bf72-534455 | | | 6 | | | cc84ea | | | | | +-----------------+---------------+---------+-------------------+------------+ # 起動後はキーを指定してデフォルトユーザー「ubuntu」でログイン root@dlp ~(keystone)# ssh -i mykey ubuntu@10.1.0.6
# ログインできた |
[4] | 一旦作成して起動した仮想マシンインスタンスを停止/起動する場合は、以下のように openstack コマンドで制御できます。 |
root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+ # インスタンス停止 root@dlp ~(keystone)# openstack server stop Ubuntu_1604 root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | SHUTOFF| network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+ # インスタンスを再度起動する root@dlp ~(keystone)# openstack server start Ubuntu_1604 root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+ |
[5] | VNC コンソールを取得して Web ブラウザでのアクセスも可能です。 |
root@dlp ~(keystone)# openstack server list +--------------------+-------------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------+-------------+--------+--------------------+------------+ | 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 | | -ae4a-d953ff2d6f9e | | | | | +--------------------+-------------+--------+--------------------+------------+root@dlp ~(keystone)# openstack console url show Ubuntu_1604 +-------+----------------------------------------------------------------------+ | Field | Value | +-------+----------------------------------------------------------------------+ | type | novnc | | url | http://10.0.0.30:6080/vnc_auto.html?token=cc1ca31e-b29c-4671-94cc- | | | e8ea093b73de | +-------+----------------------------------------------------------------------+ |
[6] | get-vnc-console で表示された URL にアクセスすると、インスタンスにアクセスして操作可能です。 |
Sponsored Link |