OpenStack Havana - Run Instance2013/10/22 |
Create and Run Virtual Machine Instance.
|
|
[1] | Create a network which instances use in OpenStack internal system. |
# nova-manage network create --label (any name) --dns1 (DNS server) --fixed_range_v4=(internal range) [root@dlp ~(keystone)]# nova-manage network create --label network01 --dns1 10.0.0.10 --fixed_range_v4=10.1.0.0/24 [root@dlp ~(keystone)]# nova-manage network list id IPv4 IPv6 start address DNS1 DNS2 VlanID project uuid 1 10.1.0.0/24 None 10.1.0.2 10.0.0.10 None None None a02b7b6d-1fb1- |
[2] | Change default security rules to access to instances with SSH. |
# permit SSH [root@dlp ~(keystone)]# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | tcp | 22 | 22 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ # permit ICMP [root@dlp ~(keystone)]# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | icmp | -1 | -1 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+[root@dlp ~(keystone)]# nova secgroup-list-rules default +-------------+-----------+---------+-----------+--------------+ | IP Protocol | From Port | To Port | IP Range | Source Group | +-------------+-----------+---------+-----------+--------------+ | tcp | 22 | 22 | 0.0.0.0/0 | | | icmp | -1 | -1 | 0.0.0.0/0 | | +-------------+-----------+---------+-----------+--------------+ |
[3] | Specify flavor (memory or disk) and create an instance and boot it. |
# default flavor list [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 | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+ # confirm virtual image [root@dlp ~(keystone)]# nova image-list +--------------------------------------+---------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------+--------+--------+ | 46042f47-c307-4fce-af0d-a1b2c14d6d78 | CentOS6 | ACTIVE | | +--------------------------------------+---------+--------+--------+ # create and boot an instance [root@dlp ~(keystone)]# nova boot --flavor 2 --image CentOS6 --security_group default CentOS_64 +--------------------------------------+--------------------------------------+ | Property | Value | +--------------------------------------+--------------------------------------+ | OS-EXT-STS:task_state | scheduling | | image | CentOS6 | | OS-EXT-STS:vm_state | building | | OS-EXT-SRV-ATTR:instance_name | instance-00000003 | | OS-SRV-USG:launched_at | None | | flavor | m1.small | | id | 081bba5e-0a88-4ae5-9757-645f682d172b | | security_groups | [{u'name': u'default'}] | | user_id | 279ade4f97014020b0e7855f2f72e40f | | OS-DCF:diskConfig | MANUAL | | accessIPv4 | | | accessIPv6 | | | progress | 0 | | OS-EXT-STS:power_state | 0 | | OS-EXT-AZ:availability_zone | nova | | config_drive | | | status | BUILD | | updated | 2013-10-22T13:55:47Z | | hostId | | | OS-EXT-SRV-ATTR:host | None | | OS-SRV-USG:terminated_at | None | | key_name | None | | OS-EXT-SRV-ATTR:hypervisor_hostname | None | | name | CentOS_64 | | adminPass | sC68kbDrrCgE | | tenant_id | 97be94660c2043e58fee407bc9cde0d5 | | created | 2013-10-22T13:55:47Z | | os-extended-volumes:volumes_attached | [] | | metadata | {} | +--------------------------------------+--------------------------------------+ # confirm status [root@dlp ~(keystone)]# nova list +------------+-----------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +------------+-----------+--------+------------+-------------+--------------------+ | 081bba5e-0 | CentOS_64 | BUILD | spawning | NOSTATE | network01=10.1.0.2 | +------------+-----------+--------+------------+-------------+--------------------+ |
[4] | Login to the Instance just booted. |
# after few minutes later, the Status turns "ACTIVE" like follows [root@dlp ~(keystone)]# nova list +------------+-----------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +------------+-----------+--------+------------+-------------+--------------------+ | 081bba5e-0 | CentOS_64 | ACTIVE | None | Running | network01=10.1.0.2 | +------------+-----------+--------+------------+-------------+--------------------+ # it's OK if answer replys like follows [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.278 ms 64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.433 ms ^C --- 10.1.0.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1652ms rtt min/avg/max/mdev = 0.278/0.355/0.433/0.079 ms # login with 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. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:6b:9e:a6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.1.0.2' (RSA) to the list of known hosts. root@10.1.0.2's password: # the root password you set during virtual machine installation Last login: Tue Oct 22 12:42:21 2013 [root@centos-64 ~]# # just logined normally |
[5] | If you'd like to stop an instance, it's possible to shutdown in instance with shutdown command off course, but it's also possible to control with nova command like follows. |
[root@dlp ~(keystone)]# nova list +------------+-----------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +------------+-----------+--------+------------+-------------+--------------------+ | 081bba5e-0 | CentOS_64 | ACTIVE | None | Running | network01=10.1.0.2 | +------------+-----------+--------+------------+-------------+--------------------+ # stop instance [root@dlp ~(keystone)]# nova stop CentOS_64 [root@dlp ~(keystone)]# nova list +------------+-----------+---------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +------------+-----------+---------+------------+-------------+--------------------+ | 081bba5e-0 | CentOS_64 | SHUTOFF | None | Shutdown | network01=10.1.0.2 | +------------+-----------+---------+------------+-------------+--------------------+ # start instance again [root@dlp ~(keystone)]# nova start CentOS_64 [root@dlp ~(keystone)]# nova list +------------+-----------+--------+------------+-------------+--------------------+ | ID | Name | Status | Task State | Power State | Networks | +------------+-----------+--------+------------+-------------+--------------------+ | 081bba5e-0 | CentOS_64 | ACTIVE | None | Running | network01=10.1.0.2 | +------------+-----------+--------+------------+-------------+--------------------+ |
Sponsored Link |