OpenStack Newton : インスタンスを起動する2016/10/22 |
仮想マシンインスタンスを起動します。
|
|
[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 | +--------------------------------------+---------+--------+ | 255cfee5-ba9d-4f8d-8ef7-c65dbe65b8ee | CentOS7 | active | +--------------------------------------+---------+--------+ # インスタンス作成・起動 [root@dlp ~(keystone)]# openstack server create --flavor m1.small --image CentOS7 --security-group default CentOS_7 +--------------------------------------+------------------------------------------------+ | 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 | mu5N6CUkNXBg | | config_drive | | | created | 2016-10-22T14:02:39Z | | flavor | m1.small (0) | | hostId | | | id | 4b80dce6-f3eb-4591-b924-37c719042c4e | | image | CentOS7 (255cfee5-ba9d-4f8d-8ef7-c65dbe65b8ee) | | key_name | None | | name | CentOS_7 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | project_id | 150e205a8791426e8028a94699fb8848 | | properties | | | security_groups | [{u'name': u'default'}] | | status | BUILD | | updated | 2016-10-22T14:02:40Z | | user_id | 0a28ee66b05f4c7b9709f316c5109e0a | +--------------------------------------+------------------------------------------------+ # 動作確認 (起動直後しばらくは「BUILD」ステータスとなっている) [root@dlp ~(keystone)]# openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | 4b80dce6- | CentOS_7 | BUILD | network01=10.1.0.2 | CentOS7 | +-----------+----------+--------+--------------------+------------+ |
[2] | 起動した仮想マシンインスタンスにログインできるか確認します。 |
# 起動後しばらくすると以下のように「ACTIVE」ステータスとなる [root@dlp ~(keystone)]# openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | 4b80dce6- | CentOS_7 | ACTIVE | network01=10.1.0.2 | CentOS7 | +-----------+----------+--------+--------------------+------------+ # 以下のように応答が返ってくれば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_seq=1 ttl=64 time=1.28 ms 64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.264 ms --- 10.1.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.264/0.776/1.288/0.512 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 11:e4:76:69:b9:e4:a1:63:79:be:d3:77:8d:76:63:51. 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: Sat Oct 22 16:10:57 2016[root@centos-7 ~]# # ログインできた |
[3] | インターネットから取得した仮想マシンイメージを利用中でパスワードが不明な場合は、SSH鍵を登録することでログイン可能です。 |
# キーペア作成 [root@dlp ~(keystone)]# ssh-keygen -q -N "" # 公開鍵登録 [root@dlp ~(keystone)]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | ba:3b:60:3d:d5:d2:92:0c:6f:d6:1d:85:d8:ff:83:a7 | | name | mykey | | user_id | 0a28ee66b05f4c7b9709f316c5109e0a | +-------------+-------------------------------------------------+[root@dlp ~(keystone)]# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | ba:3b:60:3d:d5:d2:92:0c:6f:d6:1d:85:d8:ff:83:a7 | +-------+-------------------------------------------------+ # キーを指定してインスタンス作成・起動 [root@dlp ~(keystone)]# openstack server create --flavor m1.small --image CentOS7 --security-group default --key-name mykey CentOS_7
openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | ade80a2d- | CentOS_7 | ACTIVE | network01=10.1.0.3 | CentOS7 | +-----------+----------+--------+--------------------+------------+ # 起動後はキーを指定してログイン [root@dlp ~(keystone)]# ssh -i mykey 10.1.0.3
# ログインできた |
[4] | 一旦作成して起動した仮想マシンインスタンスを停止/起動する場合は、以下のように start/stop コマンドで制御できます。 |
[root@dlp ~(keystone)]# openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | 4b80dce6- | CentOS_7 | ACTIVE | network01=10.1.0.2 | CentOS7 | +-----------+----------+--------+--------------------+------------+ # インスタンス停止 [root@dlp ~(keystone)]# openstack server stop CentOS_7 [root@dlp ~(keystone)]# openstack server list +-----------+----------+---------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+---------+--------------------+------------+ | 4b80dce6- | CentOS_7 | SHUTOFF | network01=10.1.0.2 | CentOS7 | +-----------+----------+---------+--------------------+------------+ # インスタンスを再度起動する [root@dlp ~(keystone)]# openstack server start CentOS_7 [root@dlp ~(keystone)]# openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | 4b80dce6- | CentOS_7 | ACTIVE | network01=10.1.0.2 | CentOS7 | +-----------+----------+--------+--------------------+------------+ |
[5] | VNC コンソールを取得して Web ブラウザでのアクセスも可能です。 |
[root@dlp ~(keystone)]# openstack server list +-----------+----------+--------+--------------------+------------+ | ID | Name | Status | Networks | Image Name | +-----------+----------+--------+--------------------+------------+ | 4b80dce6- | CentOS_7 | ACTIVE | network01=10.1.0.2 | CentOS7 | +-----------+----------+--------+--------------------+------------+[root@dlp ~(keystone)]# openstack console url show CentOS_7 +-------+---------------------------------------------------------------------------------+ | Field | Value | +-------+---------------------------------------------------------------------------------+ | type | novnc | | url | http://10.0.0.30:6080/vnc_auto.html?token=d6723851-dfde-4c8a-9b9f-0aa5c2b6916b | +-------+---------------------------------------------------------------------------------+ |
[6] | 上記コマンドで表示された URL にアクセスすると、インスタンスにアクセスして操作可能です。 |
Sponsored Link |