OpenStack Newton : Boot Instances2017/07/02 |
Create and Start Virtual Machine Instance.
|
|
[1] | Specify the flavor (memory or disk) and create an instance and boot it. |
# create 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 | +----+----------+------+------+-----------+-------+-----------+ # show the list of images root@dlp ~(keystone)# openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 2a339775-723f-489d-ab6d-66308c750918 | Debian9 | active | +--------------------------------------+---------+--------+ # show the list of network root@dlp ~(keystone)# openstack network list +--------------------------------------+------------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+------------+--------------------------------------+ | ea530136-b1f8-4cd7-adc4-a6d91743b2ba | sharednet1 | 297b8142-70d1-4386-93f4-da04b12a6b74 | +--------------------------------------+------------+--------------------------------------+
root@dlp ~(keystone)#
netID=`openstack network list | grep sharednet1 | awk '{ print $2 }'` # create and boot an instance root@dlp ~(keystone)# openstack server create --flavor m1.small --image Debian9 --security-group default --nic net-id=$netID Debian_9 +--------------------------------------+------------------------------------------------+ | 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 | F2gU8piKq6Yt | | config_drive | | | created | 2017-07-03T06:16:33Z | | flavor | m1.small (0) | | hostId | | | id | 79c861f1-94ef-46ef-ad52-c063a9049993 | | image | Debian9 (2a339775-723f-489d-ab6d-66308c750918) | | key_name | None | | name | Debian_9 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | project_id | 5d0a67ea1741404aa057d1fdb6e4e1be | | properties | | | security_groups | [{u'name': u'default'}] | | status | BUILD | | updated | 2017-07-03T06:16:34Z | | user_id | 44ca10f3a8c440ca95487202b50eedbe | +--------------------------------------+------------------------------------------------+ # show status ([BUILD] status is shown when building instance) root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | BUILD | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+ # when starting noramlly, the status turns to [ACTIVE] root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | ACTIVE | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+ |
[2] | Configure security settings like follows to access with SSH and ICMP. |
# permit ICMP root@dlp ~(keystone)# openstack security group rule create --protocol icmp --ingress default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-07-03T06:18:58Z | | description | | | direction | ingress | | ethertype | IPv4 | | headers | | | id | 3db99a54-9020-4fd7-a314-c88d14f8aee8 | | port_range_max | None | | port_range_min | None | | project_id | 5d0a67ea1741404aa057d1fdb6e4e1be | | project_id | 5d0a67ea1741404aa057d1fdb6e4e1be | | protocol | icmp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | 68ceee9b-79e8-43c7-b3f8-94f338b41f97 | | updated_at | 2017-07-03T06:18:58Z | +-------------------+--------------------------------------+ # permit SSH root@dlp ~(keystone)# openstack security group rule create --protocol tcp --dst-port 22:22 default +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | created_at | 2017-07-03T06:19:20Z | | description | | | direction | ingress | | ethertype | IPv4 | | headers | | | id | 40959fe3-67eb-4a40-9aad-7b6fcf97882c | | port_range_max | 22 | | port_range_min | 22 | | project_id | 5d0a67ea1741404aa057d1fdb6e4e1be | | project_id | 5d0a67ea1741404aa057d1fdb6e4e1be | | protocol | tcp | | remote_group_id | None | | remote_ip_prefix | 0.0.0.0/0 | | revision_number | 1 | | security_group_id | 68ceee9b-79e8-43c7-b3f8-94f338b41f97 | | updated_at | 2017-07-03T06:19:20Z | +-------------------+--------------------------------------+root@dlp ~(keystone)# openstack security group rule list +-----------+-------------+-----------+------------+--------------------------------------+-----------------+ | ID | IP Protocol | IP Range | Port Range | Remote Security Group | Security Group | +-----------+-------------+-----------+------------+--------------------------------------+-----------------+ | 20b862df- | None | None | | 68ceee9b-79e8-43c7-b3f8-94f338b41f97 | 68ceee9b-79e8-4 | | 3db99a54- | icmp | 0.0.0.0/0 | | None | 68ceee9b-79e8-4 | | 40959fe3- | tcp | 0.0.0.0/0 | 22:22 | None | 68ceee9b-79e8-4 | | 7f9525d6- | None | None | | 68ceee9b-79e8-43c7-b3f8-94f338b41f97 | 68ceee9b-79e8-4 | | 7fb6255b- | None | None | | None | 68ceee9b-79e8-4 | | dc087e27- | None | None | | None | 68ceee9b-79e8-4 | +-----------+-------------+-----------+------------+--------------------------------------+-----------------+ |
[3] | Login to instance with SSH. |
root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | ACTIVE | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+root@dlp ~(keystone)# ping 10.0.0.208 PING 10.0.0.208 (10.0.0.208) 56(84) bytes of data. 64 bytes from 10.0.0.208: icmp_seq=1 ttl=64 time=1.33 ms 64 bytes from 10.0.0.208: icmp_seq=2 ttl=64 time=0.806 ms 64 bytes from 10.0.0.208: icmp_seq=3 ttl=64 time=0.780 ms ^C --- 10.0.0.208 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 0.741/0.915/1.333/0.242 msroot@dlp ~(keystone)# ssh debian@10.0.0.208 The authenticity of host '10.0.0.208 (10.0.0.208)' can't be established. ECDSA key fingerprint is SHA256:bTg2kfBSCHnTgZ+ioacbzWvr010+mvRjCfigDgjeQVE. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.0.208' (ECDSA) to the list of known hosts. debian@10.0.0.208's password: # the one you set during installation Linux debian-9 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.debian@debian-9:~$ # just logined |
[4] | If you using a virtual machine image provided from internet and do not know any password for login, Add SSH key-pair to login like follows. For self-created image, if you installed [cloud-init] package and enable [cloud-init] service in it, it's possible to set SSH key-pair for it. The default user of cloud-init setting for SSH is [debian] user. |
# create key-pair root@dlp ~(keystone)# ssh-keygen -q -N "" Enter file in which to save the key (/root/.ssh/id_rsa): # add public key root@dlp ~(keystone)# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey +-------------+-------------------------------------------------+ | Field | Value | +-------------+-------------------------------------------------+ | fingerprint | 83:c6:77:3f:c7:cd:59:5d:1b:e0:87:fa:b9:cf:df:c4 | | name | mykey | | user_id | 44ca10f3a8c440ca95487202b50eedbe | +-------------+-------------------------------------------------+root@dlp ~(keystone)# openstack keypair list +-------+-------------------------------------------------+ | Name | Fingerprint | +-------+-------------------------------------------------+ | mykey | 83:c6:77:3f:c7:cd:59:5d:1b:e0:87:fa:b9:cf:df:c4 | +-------+-------------------------------------------------+ # run instance with key root@dlp ~(keystone)# openstack server create --flavor m1.small --image Debian9 --security-group default --nic net-id=$netID --key-name mykey Debian_90
openstack server list +--------------------------------------+-----------+---------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+-----------+---------+-----------------------+------------+ | 1475f09e-6d22-4cae-9110-4e3172329ece | Debian_90 | ACTIVE | sharednet1=10.0.0.202 | Debian9 | | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | SHUTOFF | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+-----------+---------+-----------------------+------------+ # login with key root@dlp ~(keystone)# ssh -i mykey debian@10.0.0.202
Warning: Identity file mykey not accessible: No such file or directory.
The authenticity of host '10.0.0.202 (10.0.0.202)' can't be established.
ECDSA key fingerprint is SHA256:2Ju1wWswMRawZsnnywRoAc9ueEcHbZLzRzVBuKzQIwQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.202' (ECDSA) to the list of known hosts.
Linux debian-90 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
debian@debian-90:~$ # just logined
|
[5] | If you'd like to stop an instance, it's also possible to control with openstack command like follows. |
root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | ACTIVE | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+ # stop instance root@dlp ~(keystone)# openstack server stop Debian_9 root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+---------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+---------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | SHUTOFF | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+---------+-----------------------+------------+ # start instance root@dlp ~(keystone)# openstack server start Debian_9 root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | ACTIVE | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+ |
[6] | It's possible to access with Web browser to get VNC console. |
root@dlp ~(keystone)# openstack server list +--------------------------------------+----------+--------+-----------------------+------------+ | ID | Name | Status | Networks | Image Name | +--------------------------------------+----------+--------+-----------------------+------------+ | 79c861f1-94ef-46ef-ad52-c063a9049993 | Debian_9 | ACTIVE | sharednet1=10.0.0.208 | Debian9 | +--------------------------------------+----------+--------+-----------------------+------------+root@dlp ~(keystone)# openstack console url show Debian_9 +-------+--------------------------------------------------------------------------------+ | Field | Value | +-------+--------------------------------------------------------------------------------+ | type | novnc | | url | http://10.0.0.30:6080/vnc_auto.html?token=d5e4a94f-3a04-4caa-bba3-fd78b3035270 | +-------+--------------------------------------------------------------------------------+ |
[7] | Access to the URL which was displayed by the command above. |
Sponsored Link |
|